GroupsController.cs 1.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794
  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. #endregion
  1654. #region 团组&签证
  1655. /// <summary>
  1656. /// 根据团组Id获取签证客户信息List
  1657. /// </summary>
  1658. /// <param name="dto">请求dto</param>
  1659. /// <returns></returns>
  1660. [HttpPost]
  1661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1662. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1663. {
  1664. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1665. if (groupData.Code != 0)
  1666. {
  1667. return Ok(JsonView(false, groupData.Msg));
  1668. }
  1669. return Ok(JsonView(groupData.Data));
  1670. }
  1671. /// <summary>
  1672. /// IOS获取团组签证拍照上传进度01(团组列表)
  1673. /// </summary>
  1674. /// <param name="dto">请求dto</param>
  1675. /// <returns></returns>
  1676. [HttpPost]
  1677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1678. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1679. {
  1680. if (dto == null)
  1681. {
  1682. return Ok(JsonView(false, "参数为空"));
  1683. }
  1684. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1685. return Ok(JsonView(visaList));
  1686. }
  1687. /// <summary>
  1688. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1689. /// </summary>
  1690. /// <returns></returns>
  1691. [HttpPost]
  1692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1693. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1694. {
  1695. if (dto == null)
  1696. {
  1697. return Ok(JsonView(false, "请求错误:"));
  1698. }
  1699. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1700. return Ok(JsonView(list));
  1701. }
  1702. /// <summary>
  1703. /// IOS获取团组签证拍照上传进度03(相册)
  1704. /// </summary>
  1705. /// <returns></returns>
  1706. [HttpPost]
  1707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1708. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1709. {
  1710. if (dto == null)
  1711. {
  1712. return Ok(JsonView(false, "请求错误:"));
  1713. }
  1714. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1715. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1716. list.ForEach(s => s.url = url);
  1717. return Ok(JsonView(list));
  1718. }
  1719. /// <summary>
  1720. /// IOS获取团组签证拍照上传进度04(图片上传)
  1721. /// </summary>
  1722. /// <param name="dto"></param>
  1723. /// <returns></returns>
  1724. [HttpPost]
  1725. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1726. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1727. {
  1728. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1729. //if (!string.IsNullOrEmpty(result))
  1730. //{
  1731. //}
  1732. //else {
  1733. // return Ok(JsonView(false, "上传失败"));
  1734. //}
  1735. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1736. int sucNum = 0;
  1737. try
  1738. {
  1739. foreach (var item in dto.base64DataList)
  1740. {
  1741. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1742. string result = DecodeBase64ToImage(item, imageName);
  1743. if (!string.IsNullOrEmpty(result))
  1744. {
  1745. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1746. pic.CreateUserId = dto.CreateUserId;
  1747. pic.PicName = imageName;
  1748. pic.PicPath = result;
  1749. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1750. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1751. if (insertResult > 0)
  1752. {
  1753. sucNum++;
  1754. }
  1755. }
  1756. }
  1757. }
  1758. catch (Exception ex)
  1759. {
  1760. return Ok(JsonView(false, ex.Message));
  1761. }
  1762. string msg = string.Format(@"成功上传{0}张", sucNum);
  1763. return Ok(JsonView(true, msg));
  1764. }
  1765. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  1766. {
  1767. string filename = "";//声明一个string类型的相对路径
  1768. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1769. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1770. try//会有异常抛出,try,catch一下
  1771. {
  1772. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1773. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1774. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1775. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1776. //文件名称
  1777. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1778. //上传的文件的路径
  1779. string filePath = "";
  1780. if (!Directory.Exists(fileDir))
  1781. {
  1782. Directory.CreateDirectory(fileDir);
  1783. }
  1784. //上传的文件的路径
  1785. filePath = fileDir + filename;
  1786. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1787. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1788. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1789. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1790. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1791. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1792. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1793. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1794. bitmap.Dispose();
  1795. }
  1796. catch (Exception e)
  1797. {
  1798. string massage = e.Message;
  1799. Logs("IOS图片上传Error:" + massage);
  1800. //filename = e.Message;
  1801. }
  1802. return filename;//返回相对路径
  1803. }
  1804. /// <summary>
  1805. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1806. /// </summary>
  1807. /// <param name="dto"></param>
  1808. /// <returns></returns>
  1809. [HttpPost]
  1810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1811. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1812. {
  1813. if (dto == null)
  1814. {
  1815. return Ok(JsonView(false, "请求错误:"));
  1816. }
  1817. string msg = "参数错误";
  1818. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1819. {
  1820. try
  1821. {
  1822. //_delegationVisaRep.BeginTran();
  1823. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1824. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1825. .Where(s => s.Id == dto.visaProgressCustomerId)
  1826. .ExecuteCommandAsync();
  1827. if (updCount > 0 && dto.publishCode == 1)
  1828. {
  1829. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1830. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1831. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1832. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1833. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1834. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1835. if (groupData == null)
  1836. {
  1837. _delegationVisaRep.RollbackTran();
  1838. }
  1839. string title = string.Format(@"[签证进度更新]");
  1840. string content = string.Format(@"测试文本");
  1841. bool rst = await _message.AddMsg(new MessageDto()
  1842. {
  1843. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1844. IssuerId = dto.publisher,
  1845. Title = title,
  1846. Content = content,
  1847. ReleaseTime = DateTime.Now,
  1848. UIdList = new List<int> {
  1849. 234
  1850. }
  1851. });
  1852. if (rst)
  1853. {
  1854. return Ok(JsonView(true, "发送通知成功"));
  1855. }
  1856. }
  1857. //_delegationVisaRep.CommitTran();
  1858. }
  1859. catch (Exception)
  1860. {
  1861. //_delegationVisaRep.RollbackTran();
  1862. }
  1863. }
  1864. return Ok(JsonView(true, msg));
  1865. }
  1866. #endregion
  1867. #region 团组任务分配
  1868. /// <summary>
  1869. /// 团组任务分配初始化
  1870. /// </summary>
  1871. /// <returns></returns>
  1872. [HttpPost]
  1873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1874. public async Task<IActionResult> GetTaskAssignmen()
  1875. {
  1876. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1877. if (groupData.Code != 0)
  1878. {
  1879. return Ok(JsonView(false, groupData.Msg));
  1880. }
  1881. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1882. }
  1883. /// <summary>
  1884. /// 团组任务分配查询
  1885. /// </summary>
  1886. /// <param name="dto"></param>
  1887. /// <returns></returns>
  1888. [HttpPost]
  1889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1890. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1891. {
  1892. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1893. if (groupData.Code != 0)
  1894. {
  1895. return Ok(JsonView(false, groupData.Msg));
  1896. }
  1897. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1898. }
  1899. /// <summary>
  1900. /// 团组任务分配操作
  1901. /// </summary>
  1902. /// <param name="dto"></param>
  1903. /// <returns></returns>
  1904. [HttpPost]
  1905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1906. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1907. {
  1908. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1909. if (groupData.Code != 0)
  1910. {
  1911. return Ok(JsonView(false, groupData.Msg));
  1912. }
  1913. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1914. }
  1915. /// <summary>
  1916. /// 团组任务分配
  1917. /// 批量分配
  1918. /// 查询团组
  1919. /// </summary>
  1920. /// <param name="dto"></param>
  1921. /// <returns></returns>
  1922. [HttpPost]
  1923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1924. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1925. {
  1926. //参数验证
  1927. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1928. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1929. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1930. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1931. }
  1932. /// <summary>
  1933. /// 团组任务分配
  1934. /// 批量分配
  1935. /// </summary>
  1936. /// <param name="dto"></param>
  1937. /// <returns></returns>
  1938. [HttpPost]
  1939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1940. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1941. {
  1942. //参数验证
  1943. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1944. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1945. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1946. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1947. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1948. }
  1949. #endregion
  1950. #region 团组费用审核
  1951. /// <summary>
  1952. /// 费用审核
  1953. /// 团组列表 Page
  1954. /// </summary>
  1955. /// <param name="_dto">团组列表请求dto</param>
  1956. /// <returns></returns>
  1957. [HttpPost]
  1958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1959. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1960. {
  1961. #region 参数验证
  1962. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1963. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1964. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1965. #region 页面操作权限验证
  1966. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1967. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1968. #endregion
  1969. #endregion
  1970. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1971. {
  1972. string sqlWhere = string.Empty;
  1973. if (_dto.IsSure == 0) //未完成
  1974. {
  1975. sqlWhere += string.Format(@" And IsSure = 0");
  1976. }
  1977. else if (_dto.IsSure == 1) //已完成
  1978. {
  1979. sqlWhere += string.Format(@" And IsSure = 1");
  1980. }
  1981. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1982. {
  1983. string tj = _dto.SearchCriteria;
  1984. 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}%')",
  1985. tj, tj, tj, tj, tj);
  1986. }
  1987. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1988. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1989. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1990. From (
  1991. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1992. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1993. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1994. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1995. From Grp_DelegationInfo gdi
  1996. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1997. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1998. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1999. Where gdi.IsDel = 0 {0}
  2000. ) temp ", sqlWhere);
  2001. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2002. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2003. var _view = new
  2004. {
  2005. PageFuncAuth = pageFunAuthView,
  2006. Data = _DelegationList
  2007. };
  2008. return Ok(JsonView(true, "查询成功!", _view, total));
  2009. }
  2010. else
  2011. {
  2012. return Ok(JsonView(false, "查询失败"));
  2013. }
  2014. }
  2015. /// <summary>
  2016. /// 获取团组费用审核
  2017. /// </summary>
  2018. /// <param name="_dto"></param>
  2019. /// <returns></returns>
  2020. [HttpPost]
  2021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2022. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2023. {
  2024. try
  2025. {
  2026. #region 参数验证
  2027. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2028. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2029. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2030. #region 页面操作权限验证
  2031. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2032. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2033. #endregion
  2034. #endregion
  2035. var _view = new Grp_CreditCardPaymentView();
  2036. var clientNameList = getSimplClientList(_dto.DiId);
  2037. #region 费用清单
  2038. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2039. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2040. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2041. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2042. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2043. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2044. /*
  2045. * 76://酒店预订
  2046. */
  2047. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2048. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2049. /*
  2050. * 79://车/导游地接
  2051. */
  2052. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2053. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2054. /*
  2055. * 80: //签证
  2056. */
  2057. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2058. /*
  2059. *81: //邀请/公务活动
  2060. */
  2061. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2062. /*
  2063. * 82: //团组客户保险
  2064. */
  2065. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2066. /*
  2067. * Lable = 85 机票预订
  2068. */
  2069. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2070. /*
  2071. * 85 机票预定
  2072. */
  2073. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2074. /*
  2075. * 98 其他款项
  2076. */
  2077. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2078. /*
  2079. * 285:收款退还
  2080. */
  2081. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2082. /*
  2083. * 1015: //超支费用
  2084. */
  2085. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2086. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2087. /*
  2088. * 币种信息
  2089. */
  2090. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2091. /*
  2092. * 车/导游地接 费用类型
  2093. */
  2094. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2095. /*
  2096. * 车/导游地接 费用类型
  2097. */
  2098. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2099. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2100. /*
  2101. * 用户信息
  2102. */
  2103. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2104. /*
  2105. * 费用模块
  2106. */
  2107. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2108. string priceModule = string.Empty;
  2109. if (sdPriceName != null)
  2110. {
  2111. priceModule = sdPriceName.Name;
  2112. }
  2113. /*
  2114. * 成本信息
  2115. */
  2116. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2117. decimal _groupRate = 0.0000M;
  2118. string _groupCurrencyCode = "-";
  2119. if (groupCost != null)
  2120. {
  2121. _groupRate = groupCost.Rate;
  2122. if (int.TryParse(groupCost.Currency, out int _currency))
  2123. {
  2124. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2125. }
  2126. else _groupCurrencyCode = groupCost.Currency;
  2127. }
  2128. string costContentSql = $"Select * From Grp_GroupCost";
  2129. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2130. //处理日期为空的天数
  2131. for (int i = 0; i < groupCostDetails.Count; i++)
  2132. if (i != 0)
  2133. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2134. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2135. /*
  2136. * 处理详情数据
  2137. */
  2138. foreach (var entity in entityList)
  2139. {
  2140. var _detail = new Grp_CreditCardPaymentDetailView();
  2141. _detail.Id = entity.Id;
  2142. _detail.PriceName = priceModule;
  2143. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2144. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2145. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2146. //处理金额
  2147. if (entity.CTable == 1015)
  2148. {
  2149. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2150. if (czInfo != null)
  2151. {
  2152. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2153. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2154. }
  2155. }
  2156. /*
  2157. * 应付款金额
  2158. */
  2159. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2160. string PaymentCurrency_WaitPay = "Unknown";
  2161. string hotelCurrncyCode = "Unknown";
  2162. string hotelCurrncyName = "Unknown";
  2163. if (sdPaymentCurrency_WaitPay != null)
  2164. {
  2165. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2166. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2167. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2168. if (hotelCurrncyCode.Equals("CNY"))
  2169. {
  2170. entity.DayRate = 1.0000M;
  2171. }
  2172. }
  2173. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2174. /*
  2175. * 此次付款金额
  2176. */
  2177. decimal CurrPayStr = 0.00M,
  2178. OriginalCurrPay = 0.00M;
  2179. if (entity.PayPercentage == 0)
  2180. {
  2181. if (entity.PayThenMoney != 0)
  2182. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2183. }
  2184. else
  2185. {
  2186. if (entity.PayMoney != 0)
  2187. {
  2188. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2189. }
  2190. }
  2191. //if (_dto.Label == 79)
  2192. //{
  2193. // string original = string.Empty;
  2194. // if (hotelCurrncyCode.Equals("CNY"))
  2195. // {
  2196. // OriginalCurrPay = CurrPayStr;
  2197. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2198. // }
  2199. // else
  2200. // {
  2201. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2202. // //760 EUR(7600.00 CNY)
  2203. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2204. // }
  2205. //}
  2206. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2207. string original = string.Empty;
  2208. if (hotelCurrncyCode.Equals("CNY"))
  2209. {
  2210. OriginalCurrPay = CurrPayStr;
  2211. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2212. }
  2213. else
  2214. {
  2215. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2216. //760 EUR(7600.00 CNY)
  2217. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2218. }
  2219. /*
  2220. * 剩余尾款
  2221. */
  2222. decimal BalanceStr = 0;
  2223. if (CurrPayStr != 0)
  2224. {
  2225. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2226. BalanceStr = 0;
  2227. else
  2228. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2229. }
  2230. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2231. /*
  2232. * Bus名称
  2233. */
  2234. _detail.BusName = "待增加";
  2235. /*
  2236. *费用所属
  2237. */
  2238. switch (entity.CTable)
  2239. {
  2240. case 76://酒店预订
  2241. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2242. if (hotelReservations != null)
  2243. {
  2244. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2245. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2246. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2247. string roomFeeStr = "", roomFeestr1 = "";
  2248. //是否比较房型价格
  2249. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2250. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2251. roomFeeStr += $"<br/>";
  2252. var roomTotal = 0.00M;
  2253. if (hotelReservations.SingleRoomPrice > 0)
  2254. {
  2255. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  2256. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2257. //__isSingle = true;
  2258. roomTotal += fee;
  2259. }
  2260. if (hotelReservations.DoubleRoomPrice > 0)
  2261. {
  2262. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  2263. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2264. // __isDouble = true;
  2265. roomTotal += fee;
  2266. }
  2267. if (hotelReservations.SuiteRoomPrice > 0)
  2268. {
  2269. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2270. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2271. //__isSuite = true;
  2272. roomTotal += fee;
  2273. }
  2274. if (hotelReservations.OtherRoomPrice > 0)
  2275. {
  2276. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2277. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2278. //__isOther = true;
  2279. roomTotal += fee;
  2280. }
  2281. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2282. else roomFeeStr += " 0.00 * 0";
  2283. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2284. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2285. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2286. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2287. /*
  2288. * 费用类型
  2289. * 1:房费
  2290. * 2:早餐
  2291. * 3:地税
  2292. * 4:城市税
  2293. * </summary>
  2294. */
  2295. //地税
  2296. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2297. if (governmentRentData != null)
  2298. {
  2299. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2300. governmentRentFee = governmentRentData.Price;
  2301. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2302. if (governmentRentCurrData != null)
  2303. {
  2304. governmentRentCode = governmentRentCurrData.Name;
  2305. governmentRentName = $"({governmentRentCurrData.Remark})";
  2306. }
  2307. }
  2308. //城市税
  2309. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2310. if (cityTaxData != null)
  2311. {
  2312. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2313. cityTaxFee = cityTaxData.Price;
  2314. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2315. if (cityTaxCurrData != null)
  2316. {
  2317. cityTaxCode = cityTaxCurrData.Name;
  2318. cityTaxName = $"({cityTaxCurrData.Remark})";
  2319. }
  2320. }
  2321. //酒店早餐
  2322. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2323. if (breakfastData != null)
  2324. {
  2325. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2326. breakfastFee = breakfastData.Price;
  2327. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2328. if (breakfastCurrData != null)
  2329. {
  2330. breakfastCode = breakfastCurrData.Name;
  2331. breakfastName = $"({breakfastCurrData.Remark})";
  2332. }
  2333. }
  2334. //房间费用
  2335. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2336. if (roomData != null)
  2337. {
  2338. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2339. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2340. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2341. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2342. roomFee = roomData.Price;
  2343. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2344. if (roomCurrData != null)
  2345. {
  2346. roomCode = roomCurrData.Name;
  2347. roomName = $"({roomCurrData.Remark})";
  2348. }
  2349. }
  2350. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2351. string hotelCostStr = "";
  2352. decimal hotelCsotTotal = 0.00M;
  2353. if (groupCost != null)
  2354. {
  2355. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2356. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2357. }
  2358. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2359. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2360. string hotelCost_day = "";
  2361. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2362. foreach (var item in hotelCostDetails1)
  2363. {
  2364. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2365. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2366. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2367. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2368. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2369. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2370. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2371. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2372. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2373. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2374. hotelCost_day += @$"<br/>";
  2375. }
  2376. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2377. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2378. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2379. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2380. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2381. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2382. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2383. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2384. $"房间说明: {hotelReservations.Remark} <br/>" +
  2385. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2386. $"{hotelBreakfastStr}" +
  2387. $"{hotelGovernmentRentStr}" +
  2388. $"{hotelCityTaxStr}";
  2389. _detail.PriceNameContent = hotelReservations.HotelName;
  2390. }
  2391. break;
  2392. case 79://车/导游地接
  2393. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2394. if (touristGuideGroundReservations != null)
  2395. {
  2396. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2397. {
  2398. _detail.BusName = touristGuideGroundReservations.BusName;
  2399. }
  2400. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2401. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2402. //if (isInt)
  2403. //{
  2404. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2405. // if (cityInfo != null)
  2406. // {
  2407. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2408. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2409. // if (carFeeItem != null)
  2410. // {
  2411. // nameContent += $@"({carFeeItem.Name})";
  2412. // }
  2413. // _detail.PriceNameContent = nameContent;
  2414. // }
  2415. //}
  2416. //else
  2417. //{
  2418. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2419. //}
  2420. var touristGuideGroundReservationsContents =
  2421. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2422. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2423. foreach (var item in touristGuideGroundReservationsContents)
  2424. {
  2425. string typeName = "Unknown";
  2426. string carCurrencyCode = "Unknown";
  2427. string carCurrencyName = "Unknown";
  2428. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2429. if (carTypeData != null) typeName = carTypeData.Name;
  2430. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2431. if (currencyData != null)
  2432. {
  2433. carCurrencyCode = currencyData.Name;
  2434. carCurrencyName = currencyData.Remark;
  2435. }
  2436. //op、成本 币种是否一致
  2437. bool IsCurrencyAgreement = false;
  2438. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2439. string opCostStr = string.Empty;
  2440. decimal opCostTypePrice = 0.00M;
  2441. #region 处理成本各项费用
  2442. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2443. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2444. if (opCost.Count > 0)
  2445. {
  2446. switch (item.SId)
  2447. {
  2448. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2449. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2450. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2451. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2452. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2453. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2454. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2455. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2456. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2457. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2458. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2459. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2460. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2461. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2462. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2463. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2464. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2465. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2466. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2467. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2468. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2469. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2470. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2471. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2472. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2473. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2474. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2475. }
  2476. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2477. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2478. }
  2479. #endregion
  2480. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2481. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2482. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2483. $"{opTypeStr} {opCostStr}<br/>" +
  2484. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2485. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2486. }
  2487. _detail.PriceMsgContent = priceMsg;
  2488. }
  2489. break;
  2490. case 80: //签证
  2491. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2492. if (visaInfo != null)
  2493. {
  2494. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2495. _detail.PriceNameContent = visaInfo.VisaDescription;
  2496. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2497. }
  2498. break;
  2499. case 81: //邀请/公务活动
  2500. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2501. if (_ioa != null)
  2502. {
  2503. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2504. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2505. sendCurrName = "Unknown", //快递费用币种 Name
  2506. sendCurrCode = "Unknown", //快递费用币种 Code
  2507. eventsCurrName = "Unknown", //公务活动费币种 Name
  2508. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2509. translateCurrName = "Unknown", //公务翻译费 Name
  2510. translateCurrCode = "Unknown"; //公务翻译费 Code
  2511. #region 处理费用币种
  2512. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2513. if (inviteCurrData != null)
  2514. {
  2515. inviteCurrName = inviteCurrData.Remark;
  2516. inviteCurrCode = inviteCurrData.Name;
  2517. }
  2518. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2519. if (sendCurrData != null)
  2520. {
  2521. sendCurrName = sendCurrData.Remark;
  2522. sendCurrCode = sendCurrData.Name;
  2523. }
  2524. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2525. if (eventsCurrData != null)
  2526. {
  2527. eventsCurrName = eventsCurrData.Remark;
  2528. eventsCurrCode = eventsCurrData.Name;
  2529. }
  2530. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2531. if (translateCurrData != null)
  2532. {
  2533. translateCurrName = translateCurrData.Remark;
  2534. translateCurrCode = translateCurrData.Name;
  2535. }
  2536. #endregion
  2537. _detail.PriceNameContent = _ioa.InviterArea;
  2538. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2539. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2540. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2541. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2542. $@"备注:" + _ioa.Remark + "<br/>";
  2543. }
  2544. break;
  2545. case 82: //团组客户保险
  2546. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2547. if (customers != null)
  2548. {
  2549. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2550. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2551. }
  2552. break;
  2553. case 85: //机票预订
  2554. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2555. if (jpRes != null)
  2556. {
  2557. string FlightsDescription = jpRes.FlightsDescription;
  2558. string PriceDescription = jpRes.PriceDescription;
  2559. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2560. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2561. }
  2562. break;
  2563. case 98://其他款项
  2564. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2565. if (gdpRes != null)
  2566. {
  2567. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2568. _detail.PriceNameContent = gdpRes.PriceName;
  2569. }
  2570. break;
  2571. case 285://收款退还
  2572. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2573. if (refundAndOtherMoney != null)
  2574. {
  2575. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2576. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2577. }
  2578. break;
  2579. case 751://酒店早餐
  2580. break;
  2581. case 1015://超支费用
  2582. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2583. if (groupExtraCost != null)
  2584. {
  2585. _detail.PriceNameContent = groupExtraCost.PriceName;
  2586. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2587. }
  2588. break;
  2589. default:
  2590. break;
  2591. }
  2592. /*
  2593. * 申请人
  2594. */
  2595. string operatorName = " - ";
  2596. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2597. if (_opUser != null)
  2598. {
  2599. operatorName = _opUser.CnName;
  2600. }
  2601. _detail.OperatorName = operatorName;
  2602. /*
  2603. * 审核人
  2604. */
  2605. string auditOperatorName = "Unknown";
  2606. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2607. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2608. else
  2609. {
  2610. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2611. if (_adUser != null)
  2612. {
  2613. auditOperatorName = _adUser.CnName;
  2614. }
  2615. }
  2616. _detail.AuditOperatorName = auditOperatorName;
  2617. /*
  2618. * 超预算比例
  2619. */
  2620. string overBudgetStr = "";
  2621. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2622. else if (entity.ExceedBudget == 0)
  2623. {
  2624. if (entity.CTable == 76 || entity.CTable == 79)
  2625. {
  2626. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2627. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2628. }
  2629. else
  2630. {
  2631. overBudgetStr = "未超预算";
  2632. }
  2633. }
  2634. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2635. _detail.OverBudget = overBudgetStr;
  2636. decimal auditFee = 0.00M; //已审核金额 人名币
  2637. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2638. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2639. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2640. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2641. {
  2642. auditedFeeOriginal = entity.PayMoney;
  2643. auditFee = CurrPayStr;
  2644. }
  2645. else if (entity.IsAuditGM == 0)
  2646. {
  2647. unAuditFeeCNY = CurrPayStr;
  2648. unAuditFeeOriginal = OriginalCurrPay;
  2649. OriginalCurrPay = 0.00M;
  2650. }
  2651. /*
  2652. * 费用总计
  2653. */
  2654. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2655. {
  2656. CurrencyId = entity.PaymentCurrency,
  2657. CurrencyName = PaymentCurrency_WaitPay,
  2658. AmountPayable = entity.PayMoney,
  2659. ThisPayment = OriginalCurrPay,
  2660. BalancePayment = BalanceStr,
  2661. AuditedFunds = auditFee,
  2662. AuditedFundsOriginal = auditedFeeOriginal,
  2663. UnAuditFundsCNY = unAuditFeeCNY,
  2664. UnAuditFundsOriginal = unAuditFeeOriginal
  2665. });
  2666. _detail.IsAuditGM = entity.IsAuditGM;
  2667. detailList.Add(_detail);
  2668. }
  2669. #endregion
  2670. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2671. /*
  2672. * 下方描述处理
  2673. */
  2674. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2675. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2676. if (ccpCurrencyPrice != null)
  2677. {
  2678. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2679. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2680. }
  2681. else
  2682. {
  2683. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2684. }
  2685. string amountPayableStr = string.Format(@"应付款总金额: ");
  2686. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2687. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2688. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2689. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2690. foreach (var item in nonDuplicat)
  2691. {
  2692. var currencyName = item.CurrencyName;
  2693. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2694. if (strs.Count > 0)
  2695. {
  2696. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2697. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2698. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2699. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2700. //单独处理此次付款金额
  2701. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2702. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2703. //单独处理已审核费用
  2704. //if (item.CurrencyId == 836) //人民币
  2705. //{
  2706. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2707. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2708. //}
  2709. //else
  2710. //{
  2711. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2712. //}
  2713. if (currencyName.Equals("CNY"))
  2714. {
  2715. //已审核费用
  2716. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2717. //未审核费用
  2718. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2719. }
  2720. else
  2721. {
  2722. //已审核费用
  2723. 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"));
  2724. //未审核费用
  2725. 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"));
  2726. }
  2727. }
  2728. }
  2729. _view.TotalStr1 = amountPayableStr[..^1];
  2730. _view.TotalStr2 = thisPaymentStr[..^1];
  2731. _view.TotalStr3 = balancePaymentStr[..^1];
  2732. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  2733. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2734. var _view1 = new
  2735. {
  2736. PageFuncAuth = pageFunAuthView,
  2737. Data = _view
  2738. };
  2739. return Ok(JsonView(_view1));
  2740. }
  2741. catch (Exception ex)
  2742. {
  2743. return Ok(JsonView(false, ex.Message));
  2744. }
  2745. }
  2746. /// <summary>
  2747. /// 费用审核
  2748. /// 修改团组费用审核状态
  2749. /// </summary>
  2750. /// <param name="_dto">参数Json字符串</param>
  2751. /// <returns></returns>
  2752. [HttpPost]
  2753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2754. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2755. {
  2756. #region 参数验证
  2757. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2758. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2759. #endregion
  2760. #region 页面操作权限验证
  2761. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2762. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2763. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2764. #endregion
  2765. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2766. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2767. DateTime dtNow = DateTime.Now;
  2768. _groupRepository.BeginTran();
  2769. int rst = 0;
  2770. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2771. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2772. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2773. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2774. List<dynamic> msgDatas = new List<dynamic>();
  2775. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2776. foreach (var item in idList)
  2777. {
  2778. int CreditId = int.Parse(item);
  2779. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2780. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2781. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2782. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2783. .Where(s => s.Id == CreditId)
  2784. .ExecuteCommandAsync();
  2785. if (result < 1)
  2786. {
  2787. rst = -1;
  2788. _groupRepository.RollbackTran();
  2789. return Ok(JsonView(false, "操作失败并回滚!"));
  2790. }
  2791. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2792. if (creditData != null)
  2793. {
  2794. #region 应用通知配置
  2795. try
  2796. {
  2797. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2798. }
  2799. catch (Exception ex)
  2800. {
  2801. }
  2802. #endregion
  2803. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2804. string groupNameStr = string.Empty;
  2805. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2806. if (groupData != null) groupNameStr = groupData.TeamName;
  2807. string creditTypeStr = string.Empty;
  2808. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2809. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2810. string creditCurrency = string.Empty;
  2811. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2812. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2813. if (creditCurrency.Equals("CNY"))
  2814. {
  2815. creditData.DayRate = 1.0000M;
  2816. }
  2817. if (creditData.PayPercentage == 0.00M)
  2818. {
  2819. creditData.PayPercentage = 100M;
  2820. }
  2821. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2822. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2823. string msgContent = "";
  2824. if (creditCurrency.Equals("CNY"))
  2825. {
  2826. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2827. }
  2828. else
  2829. {
  2830. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2831. }
  2832. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2833. }
  2834. }
  2835. if (rst == 0)
  2836. {
  2837. _groupRepository.CommitTran();
  2838. foreach (var item in msgDatas)
  2839. {
  2840. //发送消息
  2841. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2842. }
  2843. #region 应用推送
  2844. try
  2845. {
  2846. foreach (var ccpId in dic_ccp_user.Keys)
  2847. {
  2848. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2849. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2850. }
  2851. }
  2852. catch (Exception)
  2853. {
  2854. }
  2855. #endregion
  2856. return Ok(JsonView(true, "操作成功!"));
  2857. }
  2858. return Ok(JsonView(false, "操作失败!"));
  2859. }
  2860. #endregion
  2861. #region 机票费用录入
  2862. /// <summary>
  2863. /// 机票录入当前登录人可操作团组
  2864. /// </summary>
  2865. /// <param name="dto"></param>
  2866. /// <returns></returns>
  2867. [HttpPost]
  2868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2869. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2870. {
  2871. try
  2872. {
  2873. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2874. if (groupData.Code != 0)
  2875. {
  2876. return Ok(JsonView(false, groupData.Msg));
  2877. }
  2878. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2879. }
  2880. catch (Exception ex)
  2881. {
  2882. return Ok(JsonView(false, "程序错误!"));
  2883. throw;
  2884. }
  2885. }
  2886. /// <summary>
  2887. /// 机票费用录入列表
  2888. /// </summary>
  2889. /// <param name="dto"></param>
  2890. /// <returns></returns>
  2891. [HttpPost]
  2892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2893. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2894. {
  2895. try
  2896. {
  2897. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2898. if (groupData.Code != 0)
  2899. {
  2900. return Ok(JsonView(false, groupData.Msg));
  2901. }
  2902. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2903. }
  2904. catch (Exception ex)
  2905. {
  2906. return Ok(JsonView(false, ex.Message));
  2907. throw;
  2908. }
  2909. }
  2910. /// <summary>
  2911. /// 根据id查询费用录入信息
  2912. /// </summary>
  2913. /// <param name="dto"></param>
  2914. /// <returns></returns>
  2915. [HttpPost]
  2916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2917. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2918. {
  2919. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2920. if (groupData.Code != 0)
  2921. {
  2922. return Ok(JsonView(false, groupData.Msg));
  2923. }
  2924. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2925. }
  2926. /// <summary>
  2927. /// 机票费用录入操作(Status:1.新增,2.修改)
  2928. /// </summary>
  2929. /// <param name="dto"></param>
  2930. /// <returns></returns>
  2931. [HttpPost]
  2932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2933. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2934. {
  2935. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2936. if (groupData.Code != 0)
  2937. {
  2938. return Ok(JsonView(false, groupData.Msg));
  2939. }
  2940. #region 应用推送
  2941. try
  2942. {
  2943. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2944. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2945. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2946. //2024-10-21 新增LZ UID
  2947. var userIds = new List<int>() { 21 };
  2948. string title = $"系统通知";
  2949. string content = "";
  2950. var diId = dto.AirTicketResOpData.DiId;
  2951. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2952. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2953. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2954. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2955. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2956. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2957. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2958. }
  2959. catch (Exception ex)
  2960. {
  2961. }
  2962. #endregion
  2963. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2964. }
  2965. /// <summary>
  2966. /// 根据舱位类型查询接团客户名单信息
  2967. /// </summary>
  2968. /// <param name="dto"></param>
  2969. /// <returns></returns>
  2970. [HttpPost]
  2971. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2972. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2973. {
  2974. try
  2975. {
  2976. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2977. if (crm_Groups.Count != 0)
  2978. {
  2979. List<dynamic> Customer = new List<dynamic>();
  2980. foreach (var item in crm_Groups)
  2981. {
  2982. var data = new
  2983. {
  2984. Id = item.Id,
  2985. Pinyin = item.Pinyin,
  2986. Name = item.LastName + item.FirstName
  2987. };
  2988. Customer.Add(data);
  2989. }
  2990. return Ok(JsonView(true, "查询成功!", Customer));
  2991. }
  2992. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2993. }
  2994. catch (Exception ex)
  2995. {
  2996. return Ok(JsonView(false, "程序错误!"));
  2997. throw;
  2998. }
  2999. }
  3000. /// <summary>
  3001. /// 根据团号获取客户信息
  3002. /// </summary>
  3003. /// <param name="dto"></param>
  3004. /// <returns></returns>
  3005. [HttpPost]
  3006. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3007. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  3008. {
  3009. var jw = JsonView(false);
  3010. if (dto.DIID < 1)
  3011. {
  3012. jw.Msg += "请输入正确的diid";
  3013. return Ok(jw);
  3014. }
  3015. var arr = getSimplClientList(dto.DIID);
  3016. jw = JsonView(true, "获取成功!", arr);
  3017. return Ok(jw);
  3018. }
  3019. private List<SimplClientInfo> getSimplClientList(int diId)
  3020. {
  3021. 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);
  3022. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  3023. foreach (var item in arr)
  3024. {
  3025. EncryptionProcessor.DecryptProperties(item);
  3026. }
  3027. return arr;
  3028. }
  3029. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  3030. {
  3031. string result = origin;
  3032. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3033. {
  3034. string[] temparr = origin.Split(',');
  3035. string fistrStr = temparr[0];
  3036. int count = temparr.Count();
  3037. int tempId;
  3038. bool success = int.TryParse(fistrStr, out tempId);
  3039. if (success)
  3040. {
  3041. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3042. if (tempInfo != null)
  3043. {
  3044. if (count > 1)
  3045. {
  3046. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  3047. }
  3048. else
  3049. {
  3050. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  3051. }
  3052. }
  3053. }
  3054. }
  3055. return result;
  3056. }
  3057. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  3058. {
  3059. string result = origin;
  3060. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3061. {
  3062. string[] temparr = origin.Split(',');
  3063. result = "";
  3064. foreach (var item in temparr)
  3065. {
  3066. int tempId;
  3067. bool success = int.TryParse(item, out tempId);
  3068. if (success)
  3069. {
  3070. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3071. if (tempInfo != null)
  3072. {
  3073. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  3074. }
  3075. }
  3076. }
  3077. }
  3078. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  3079. return result;
  3080. }
  3081. /// <summary>
  3082. /// 机票费用录入,删除
  3083. /// </summary>
  3084. /// <param name="dto"></param>
  3085. /// <returns></returns>
  3086. [HttpPost]
  3087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3088. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  3089. {
  3090. try
  3091. {
  3092. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3093. if (res)
  3094. {
  3095. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  3096. {
  3097. IsDel = 1,
  3098. DeleteUserId = dto.DeleteUserId,
  3099. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3100. }).ExecuteCommandAsync();
  3101. return Ok(JsonView(true, "删除成功!"));
  3102. }
  3103. return Ok(JsonView(false, "删除失败!"));
  3104. }
  3105. catch (Exception ex)
  3106. {
  3107. return Ok(JsonView(false, "程序错误!"));
  3108. throw;
  3109. }
  3110. }
  3111. /// <summary>
  3112. /// 导出机票录入报表
  3113. /// </summary>
  3114. /// <param name="dto"></param>
  3115. /// <returns></returns>
  3116. [HttpPost]
  3117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3118. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  3119. {
  3120. try
  3121. {
  3122. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  3123. if (groupData.Code != 0)
  3124. {
  3125. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3126. }
  3127. else
  3128. {
  3129. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  3130. if (AirTicketReservations.Count != 0)
  3131. {
  3132. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  3133. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  3134. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  3135. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  3136. WorkbookDesigner designer = new WorkbookDesigner();
  3137. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  3138. decimal countCost = 0;
  3139. foreach (var item in AirTicketReservations)
  3140. {
  3141. #region 处理客人姓名
  3142. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  3143. item.ClientName = clientNames;
  3144. #endregion
  3145. if (item.BankType == "其他")
  3146. {
  3147. item.BankNo = "--";
  3148. }
  3149. else
  3150. {
  3151. if (!string.IsNullOrEmpty(item.BankType))
  3152. {
  3153. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  3154. }
  3155. }
  3156. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  3157. item.Price = System.Decimal.Round(item.Price, 2);
  3158. countCost += Convert.ToDecimal(item.Price);
  3159. }
  3160. designer.SetDataSource("Export", AirTicketReservations);
  3161. designer.SetDataSource("ExportDiCode", diCode);
  3162. designer.SetDataSource("ExportDiName", diName);
  3163. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  3164. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  3165. designer.Process();
  3166. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  3167. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3168. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3169. return Ok(JsonView(true, "成功", url = rst));
  3170. }
  3171. else
  3172. {
  3173. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  3174. }
  3175. }
  3176. }
  3177. catch (Exception ex)
  3178. {
  3179. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  3180. throw;
  3181. }
  3182. }
  3183. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3184. /// <summary>
  3185. /// 行程单导出
  3186. /// </summary>
  3187. /// <param name="dto"></param>
  3188. /// <returns></returns>
  3189. [HttpPost]
  3190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3191. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  3192. {
  3193. try
  3194. {
  3195. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  3196. if (groupData.Code != 0)
  3197. {
  3198. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3199. }
  3200. else
  3201. {
  3202. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3203. if (dto.Language == "CN")
  3204. {
  3205. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3206. DocumentBuilder builder = new DocumentBuilder(doc);
  3207. int tableIndex = 0;//表格索引
  3208. //得到文档中的第一个表格
  3209. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3210. foreach (var item in _AirTicketReservations)
  3211. {
  3212. #region 处理固定数据
  3213. string[] FlightsCode = item.FlightsCode.Split('/');
  3214. if (FlightsCode.Length != 0)
  3215. {
  3216. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3217. if (_AirCompany != null)
  3218. {
  3219. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3220. }
  3221. else
  3222. {
  3223. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3224. }
  3225. }
  3226. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3227. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3228. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3229. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3230. string name = "";
  3231. foreach (string clientName in nameArray)
  3232. {
  3233. if (!name.Contains(clientName))
  3234. {
  3235. name += clientName + ",";
  3236. }
  3237. }
  3238. if (!string.IsNullOrWhiteSpace(name))
  3239. {
  3240. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3241. }
  3242. else
  3243. {
  3244. table.Range.Bookmarks["ClientName"].Text = "--";
  3245. }
  3246. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3247. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3248. table.Range.Bookmarks["JointTicket"].Text = "--";
  3249. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3250. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3251. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3252. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3253. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3254. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3255. #endregion
  3256. #region 循环数据处理
  3257. List<AirInfo> airs = new List<AirInfo>();
  3258. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3259. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3260. for (int i = 0; i < FlightsCode.Length; i++)
  3261. {
  3262. AirInfo air = new AirInfo();
  3263. string[] tempstr = DayArray[i]
  3264. .Replace("\r\n", string.Empty)
  3265. .Replace("\\r\\n", string.Empty)
  3266. .TrimStart().TrimEnd()
  3267. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3268. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3269. string starCity = "";
  3270. if (star_Three != null)
  3271. {
  3272. starCity = star_Three.AirPort;
  3273. }
  3274. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3275. string EndCity = "";
  3276. if (End_Three != null)
  3277. {
  3278. EndCity = End_Three.AirPort;
  3279. }
  3280. air.Destination = starCity + "/" + EndCity;
  3281. air.Flight = FlightsCode[i];
  3282. air.SeatingClass = item.CTypeName;
  3283. string dateTime = tempstr[2];
  3284. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3285. air.FlightDate = DateTemp;
  3286. air.DepartureTime = tempstr[5];
  3287. air.LandingTime = tempstr[6];
  3288. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3289. air.TicketStatus = "--";
  3290. air.Luggage = "--";
  3291. air.DepartureTerminal = "--";
  3292. air.LandingTerminal = "--";
  3293. airs.Add(air);
  3294. }
  3295. int row = 13;
  3296. for (int i = 0; i < airs.Count; i++)
  3297. {
  3298. if (airs.Count > 2)
  3299. {
  3300. for (int j = 0; j < airs.Count - 2; j++)
  3301. {
  3302. var CopyRow = table.Rows[12].Clone(true);
  3303. table.Rows.Add(CopyRow);
  3304. }
  3305. }
  3306. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3307. int index = 0;
  3308. foreach (PropertyInfo property in properties)
  3309. {
  3310. string value = property.GetValue(airs[i]).ToString();
  3311. Cell ishcel0 = table.Rows[row].Cells[index];
  3312. Paragraph p = new Paragraph(doc);
  3313. string s = value;
  3314. p.AppendChild(new Run(doc, s));
  3315. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3316. ishcel0.AppendChild(p);
  3317. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3318. index++;
  3319. }
  3320. row++;
  3321. }
  3322. #endregion
  3323. Paragraph lastParagraph = new Paragraph(doc);
  3324. //第一个表格末尾加段落
  3325. table.ParentNode.InsertAfter(lastParagraph, table);
  3326. //复制第一个表格
  3327. Table cloneTable = (Table)table.Clone(true);
  3328. //在文档末尾段落后面加入复制的表格
  3329. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3330. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3331. {
  3332. int rownewsIndex = 13;
  3333. for (int i = 0; i < 2; i++)
  3334. {
  3335. var CopyRow = table.Rows[12].Clone(true);
  3336. table.Rows.RemoveAt(13);
  3337. table.Rows.Add(CopyRow);
  3338. rownewsIndex++;
  3339. }
  3340. }
  3341. else
  3342. {
  3343. table.Rows.RemoveAt(12);
  3344. }
  3345. cloneTable.Rows.RemoveAt(12);
  3346. }
  3347. if (_AirTicketReservations.Count != 0)
  3348. {
  3349. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3350. if (FlightsCode.Length != 0)
  3351. {
  3352. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3353. if (_AirCompany != null)
  3354. {
  3355. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3356. }
  3357. else
  3358. {
  3359. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3360. }
  3361. }
  3362. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3363. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3364. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3365. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3366. string name = "";
  3367. foreach (string clientName in nameArray)
  3368. {
  3369. if (!name.Contains(clientName))
  3370. {
  3371. name += clientName + ",";
  3372. }
  3373. }
  3374. if (!string.IsNullOrWhiteSpace(name))
  3375. {
  3376. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3377. }
  3378. else
  3379. {
  3380. table.Range.Bookmarks["ClientName"].Text = "--";
  3381. }
  3382. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3383. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3384. table.Range.Bookmarks["JointTicket"].Text = "--";
  3385. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3386. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3387. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3388. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3389. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3390. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3391. }
  3392. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3393. //保存合并后的文档
  3394. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3395. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3396. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3397. return Ok(JsonView(true, "成功!", rst));
  3398. }
  3399. else
  3400. {
  3401. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3402. DocumentBuilder builder = new DocumentBuilder(doc);
  3403. int tableIndex = 0;//表格索引
  3404. //得到文档中的第一个表格
  3405. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3406. List<string> texts = new List<string>();
  3407. foreach (var item in _AirTicketReservations)
  3408. {
  3409. string[] FlightsCode = item.FlightsCode.Split('/');
  3410. if (FlightsCode.Length != 0)
  3411. {
  3412. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3413. if (_AirCompany != null)
  3414. {
  3415. if (!transDic.ContainsKey(_AirCompany.CnName))
  3416. {
  3417. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3418. }
  3419. }
  3420. else
  3421. {
  3422. if (!transDic.ContainsKey("--"))
  3423. {
  3424. transDic.Add("--", "--");
  3425. }
  3426. }
  3427. }
  3428. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3429. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3430. string name = "";
  3431. foreach (string clientName in nameArray)
  3432. {
  3433. name += clientName + ",";
  3434. }
  3435. if (!texts.Contains(name))
  3436. {
  3437. texts.Add(name);
  3438. }
  3439. List<AirInfo> airs = new List<AirInfo>();
  3440. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3441. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3442. for (int i = 0; i < FlightsCode.Length; i++)
  3443. {
  3444. AirInfo air = new AirInfo();
  3445. string[] tempstr = DayArray[i]
  3446. .Replace("\r\n", string.Empty)
  3447. .Replace("\\r\\n", string.Empty)
  3448. .TrimStart().TrimEnd()
  3449. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3450. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3451. if (star_Three != null)
  3452. {
  3453. if (!transDic.ContainsKey(star_Three.AirPort))
  3454. {
  3455. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3456. }
  3457. }
  3458. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3459. if (End_Three != null)
  3460. {
  3461. if (!transDic.ContainsKey(End_Three.AirPort))
  3462. {
  3463. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3464. }
  3465. }
  3466. if (!texts.Contains(item.CTypeName))
  3467. {
  3468. texts.Add(item.CTypeName);
  3469. }
  3470. }
  3471. }
  3472. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  3473. if (transData.Count > 0)
  3474. {
  3475. foreach (TranslateResult item in transData)
  3476. {
  3477. if (!transDic.ContainsKey(item.Query))
  3478. {
  3479. transDic.Add(item.Query, item.Translation);
  3480. }
  3481. }
  3482. }
  3483. foreach (var item in _AirTicketReservations)
  3484. {
  3485. #region 处理固定数据
  3486. string[] FlightsCode = item.FlightsCode.Split('/');
  3487. if (FlightsCode.Length != 0)
  3488. {
  3489. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3490. if (_AirCompany != null)
  3491. {
  3492. string str = "--";
  3493. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3494. if (!string.IsNullOrEmpty(translateResult))
  3495. {
  3496. str = translateResult;
  3497. str = _airTicketResRep.Processing(str);
  3498. }
  3499. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3500. }
  3501. else
  3502. {
  3503. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3504. }
  3505. }
  3506. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3507. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3508. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3509. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3510. string names = "";
  3511. foreach (string clientName in nameArray)
  3512. {
  3513. names += clientName + ",";
  3514. }
  3515. if (!string.IsNullOrWhiteSpace(names))
  3516. {
  3517. string str = "--";
  3518. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3519. if (!string.IsNullOrEmpty(translateResult))
  3520. {
  3521. str = translateResult;
  3522. str = _airTicketResRep.Processing(str);
  3523. }
  3524. table.Range.Bookmarks["ClientName"].Text = str;
  3525. }
  3526. else
  3527. {
  3528. table.Range.Bookmarks["ClientName"].Text = "--";
  3529. }
  3530. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3531. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3532. table.Range.Bookmarks["JointTicket"].Text = "--";
  3533. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3534. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3535. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3536. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3537. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3538. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3539. #endregion
  3540. #region 循环数据处理
  3541. List<AirInfo> airs = new List<AirInfo>();
  3542. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3543. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3544. for (int i = 0; i < FlightsCode.Length; i++)
  3545. {
  3546. AirInfo air = new AirInfo();
  3547. string[] tempstr = DayArray[i]
  3548. .Replace("\r\n", string.Empty)
  3549. .Replace("\\r\\n", string.Empty)
  3550. .TrimStart().TrimEnd()
  3551. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3552. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3553. string starCity = "";
  3554. if (star_Three != null)
  3555. {
  3556. string str2 = "--";
  3557. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3558. if (!string.IsNullOrEmpty(translateResult2))
  3559. {
  3560. str2 = translateResult2;
  3561. str2 = _airTicketResRep.Processing(str2);
  3562. }
  3563. starCity = str2;
  3564. }
  3565. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3566. string EndCity = "";
  3567. if (End_Three != null)
  3568. {
  3569. string str1 = "--";
  3570. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3571. if (!string.IsNullOrEmpty(translateResult1))
  3572. {
  3573. str1 = translateResult1;
  3574. str1 = _airTicketResRep.Processing(str1);
  3575. }
  3576. EndCity = str1;
  3577. }
  3578. air.Destination = starCity + "/" + EndCity;
  3579. air.Flight = FlightsCode[i];
  3580. string str = "--";
  3581. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3582. if (!string.IsNullOrEmpty(translateResult))
  3583. {
  3584. str = translateResult;
  3585. str = _airTicketResRep.Processing(str);
  3586. }
  3587. air.SeatingClass = str;
  3588. string dateTime = tempstr[2];
  3589. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3590. air.FlightDate = DateTemp;
  3591. air.DepartureTime = tempstr[5];
  3592. air.LandingTime = tempstr[6];
  3593. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3594. air.TicketStatus = "--";
  3595. air.Luggage = "--";
  3596. air.DepartureTerminal = "--";
  3597. air.LandingTerminal = "--";
  3598. airs.Add(air);
  3599. }
  3600. int row = 13;
  3601. for (int i = 0; i < airs.Count; i++)
  3602. {
  3603. if (airs.Count > 2)
  3604. {
  3605. for (int j = 0; j < airs.Count - 2; j++)
  3606. {
  3607. var CopyRow = table.Rows[12].Clone(true);
  3608. table.Rows.Add(CopyRow);
  3609. }
  3610. }
  3611. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3612. int index = 0;
  3613. foreach (PropertyInfo property in properties)
  3614. {
  3615. string value = property.GetValue(airs[i]).ToString();
  3616. Cell ishcel0 = table.Rows[row].Cells[index];
  3617. Paragraph p = new Paragraph(doc);
  3618. string s = value;
  3619. p.AppendChild(new Run(doc, s));
  3620. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3621. ishcel0.AppendChild(p);
  3622. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3623. //ishcel0.CellFormat.VerticalAlignment=
  3624. index++;
  3625. }
  3626. row++;
  3627. }
  3628. #endregion
  3629. Paragraph lastParagraph = new Paragraph(doc);
  3630. //第一个表格末尾加段落
  3631. table.ParentNode.InsertAfter(lastParagraph, table);
  3632. //复制第一个表格
  3633. Table cloneTable = (Table)table.Clone(true);
  3634. //在文档末尾段落后面加入复制的表格
  3635. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3636. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3637. {
  3638. int rownewsIndex = 13;
  3639. for (int i = 0; i < 2; i++)
  3640. {
  3641. var CopyRow = table.Rows[12].Clone(true);
  3642. table.Rows.RemoveAt(13);
  3643. table.Rows.Add(CopyRow);
  3644. rownewsIndex++;
  3645. }
  3646. }
  3647. else
  3648. {
  3649. table.Rows.RemoveAt(12);
  3650. }
  3651. cloneTable.Rows.RemoveAt(12);
  3652. }
  3653. if (_AirTicketReservations.Count != 0)
  3654. {
  3655. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3656. if (FlightsCode.Length != 0)
  3657. {
  3658. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3659. if (_AirCompany != null)
  3660. {
  3661. string str = "--";
  3662. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3663. if (!string.IsNullOrEmpty(translateResult))
  3664. {
  3665. str = translateResult;
  3666. str = _airTicketResRep.Processing(str);
  3667. }
  3668. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3669. }
  3670. else
  3671. {
  3672. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3673. }
  3674. }
  3675. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3676. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3677. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3678. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3679. string names = "";
  3680. foreach (string clientName in nameArray)
  3681. {
  3682. names += clientName + ",";
  3683. }
  3684. if (!string.IsNullOrWhiteSpace(names))
  3685. {
  3686. string str = "--";
  3687. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3688. if (!string.IsNullOrEmpty(translateResult))
  3689. {
  3690. str = translateResult;
  3691. str = _airTicketResRep.Processing(str);
  3692. }
  3693. table.Range.Bookmarks["ClientName"].Text = str;
  3694. }
  3695. else
  3696. {
  3697. table.Range.Bookmarks["ClientName"].Text = "--";
  3698. }
  3699. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3700. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3701. table.Range.Bookmarks["JointTicket"].Text = "--";
  3702. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3703. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3704. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3705. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3706. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3707. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3708. }
  3709. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3710. //保存合并后的文档
  3711. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3712. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3713. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3714. return Ok(JsonView(true, "成功!", rst));
  3715. }
  3716. }
  3717. }
  3718. catch (Exception ex)
  3719. {
  3720. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3721. throw;
  3722. }
  3723. }
  3724. #endregion
  3725. #region 团组增减款项 --> 其他款项
  3726. /// <summary>
  3727. /// 团组增减款项下拉框绑定
  3728. /// </summary>
  3729. /// <param name="dto"></param>
  3730. /// <returns></returns>
  3731. [HttpPost]
  3732. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3733. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3734. {
  3735. #region 参数验证
  3736. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3737. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3738. #endregion
  3739. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3740. }
  3741. /// <summary>
  3742. /// 根据团组Id查询团组增减款项
  3743. /// </summary>
  3744. /// <param name="dto"></param>
  3745. /// <returns></returns>
  3746. [HttpPost]
  3747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3748. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3749. {
  3750. #region 参数验证
  3751. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3752. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3753. #endregion
  3754. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3755. }
  3756. /// <summary>
  3757. /// 团组增减款项操作(Status:1.新增,2.修改)
  3758. /// </summary>
  3759. /// <param name="dto"></param>
  3760. /// <returns></returns>
  3761. [HttpPost]
  3762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3763. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3764. {
  3765. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3766. if (groupData.Code != 200)
  3767. {
  3768. return Ok(JsonView(false, groupData.Msg));
  3769. }
  3770. #region 应用推送
  3771. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3772. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3773. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3774. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  3775. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  3776. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  3777. //自动审核
  3778. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3779. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3780. //2024-10-21 新增LZ UID
  3781. var userIds = new List<int>() { 21 };
  3782. string title = $"系统通知";
  3783. string content = "";
  3784. var diId = dto.DiId;
  3785. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3786. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3787. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3788. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3789. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3790. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3791. #endregion
  3792. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3793. }
  3794. /// <summary>
  3795. /// 团组增减款项操作 删除
  3796. /// </summary>
  3797. /// <param name="dto"></param>
  3798. /// <returns></returns>
  3799. [HttpPost]
  3800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3801. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3802. {
  3803. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3804. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3805. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3806. if (res.Code == 0)
  3807. {
  3808. return Ok(JsonView(true, "删除成功!"));
  3809. }
  3810. return Ok(JsonView(false, "删除失败!"));
  3811. }
  3812. /// <summary>
  3813. /// 根据团组增减款项Id查询
  3814. /// </summary>
  3815. /// <param name="dto"></param>
  3816. /// <returns></returns>
  3817. [HttpPost]
  3818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3819. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3820. {
  3821. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3822. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3823. }
  3824. /// <summary>
  3825. /// 查询供应商名称
  3826. /// </summary>
  3827. /// <param name="dto"></param>
  3828. /// <returns></returns>
  3829. [HttpPost]
  3830. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3831. {
  3832. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3833. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3834. ?? new List<Grp_DecreasePayments>();
  3835. dbResult = dbResult.Distinct(new
  3836. ProductComparer()).ToList();
  3837. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3838. {
  3839. x.Id,
  3840. x.SupplierAddress,
  3841. x.SupplierArea,
  3842. x.SupplierContact,
  3843. x.SupplierContactNumber,
  3844. x.SupplierEmail,
  3845. x.SupplierName,
  3846. x.SupplierSocialAccount,
  3847. x.SupplierTypeId,
  3848. }).ToList());
  3849. return Ok(jw);
  3850. }
  3851. /// <summary>
  3852. /// 团组增减款项 OTA匹配
  3853. /// </summary>
  3854. /// <param name="file"></param>
  3855. /// <returns></returns>
  3856. [HttpPost]
  3857. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3858. {
  3859. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3860. string fileName = file.FileName;
  3861. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3862. {
  3863. return Ok(JsonView(false, "请上传Excel文件!"));
  3864. }
  3865. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3866. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3867. if (!Directory.Exists(path))
  3868. {
  3869. Directory.CreateDirectory(path);
  3870. }
  3871. var filePath = @$"{path}/{fileName}";
  3872. //保存文件
  3873. using (FileStream fs = System.IO.File.Create(filePath))
  3874. {
  3875. file.CopyTo(fs);
  3876. fs.Flush();
  3877. }
  3878. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3879. //读取ExcelFile
  3880. DataTable dt = ConvertExcelToDataTable(filePath);
  3881. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3882. dt.TableName = "TB";
  3883. //修改table列名
  3884. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3885. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3886. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3887. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3888. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3889. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3890. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3891. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3892. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3893. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3894. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3895. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3896. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3897. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3898. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3899. var otaOrderNos = new List<string>();
  3900. foreach (DataRow item in dt.Rows)
  3901. {
  3902. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3903. }
  3904. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3905. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3906. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3907. .Select((dp, di) => new
  3908. {
  3909. dp.PriceName,
  3910. dp.OTAOrderNo,
  3911. dp.FeeTotal,
  3912. di.TeamName,
  3913. })
  3914. .ToListAsync();
  3915. foreach (DataRow item in dt.Rows)
  3916. {
  3917. var otaOrderNo = item["OTAOrderNo"].ToString();
  3918. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3919. if (oaData == null) continue;
  3920. item["GroupName"] = oaData.TeamName;
  3921. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3922. }
  3923. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3924. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3925. List<DataTable> datas = new List<DataTable>();
  3926. datas.Add(dt);
  3927. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3928. return Ok(JsonView(true, "操作成功", new { url = url }));
  3929. }
  3930. #region
  3931. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3932. {
  3933. // 创建Workbook对象
  3934. Workbook workbook = new Workbook(excelFilePath);
  3935. // 获取第一个工作表
  3936. Worksheet worksheet = workbook.Worksheets[0];
  3937. // 将工作表转换为DataTable
  3938. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3939. return dataTable;
  3940. }
  3941. #endregion
  3942. #endregion
  3943. #region 文件上传、删除
  3944. /// <summary>
  3945. /// region 文件上传 可以带参数
  3946. /// </summary>
  3947. /// <param name="file"></param>
  3948. /// <returns></returns>
  3949. [HttpPost]
  3950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3951. public async Task<IActionResult> UploadProject(IFormFile file)
  3952. {
  3953. //var TypeName = Request.Headers["TypeName"].ToString();
  3954. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3955. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3956. ////文件名称
  3957. //string projectFileName = file.FileName;
  3958. ////上传的文件的路径
  3959. //string filePath = $"{fileDir}/{projectFileName}";
  3960. //if (TypeName == "A")//A代表团组增减款项
  3961. //{
  3962. // filePath = fileDir + $@"\团组增减款项相关文件";
  3963. // if (!Directory.Exists(filePath))
  3964. // {
  3965. // Directory.CreateDirectory(filePath);
  3966. // }
  3967. // //上传的文件的路径
  3968. // filePath += $@"\{projectFileName}";
  3969. //}
  3970. //else if (TypeName == "B")//B代表商邀相关文件
  3971. //{
  3972. // //上传的文件的路径
  3973. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3974. // if (!Directory.Exists(filePath))
  3975. // {
  3976. // Directory.CreateDirectory(filePath);
  3977. // }
  3978. // //上传的文件的路径
  3979. // filePath = $@"\{projectFileName}";
  3980. //}
  3981. //try
  3982. //{
  3983. // using (FileStream fs = System.IO.File.Create(filePath))
  3984. // {
  3985. // file.CopyTo(fs);
  3986. // fs.Flush();
  3987. // }
  3988. //}
  3989. //catch (Exception ex)
  3990. //{
  3991. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3992. //}
  3993. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3994. try
  3995. {
  3996. var TypeName = Request.Headers["TypeName"].ToString();
  3997. if (file != null)
  3998. {
  3999. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4000. //文件名称
  4001. string projectFileName = file.FileName;
  4002. //上传的文件的路径
  4003. string filePath = $"{fileDir}/{projectFileName}";
  4004. if (TypeName == "A")//A代表团组增减款项
  4005. {
  4006. if (!Directory.Exists(fileDir))
  4007. {
  4008. Directory.CreateDirectory(fileDir);
  4009. }
  4010. //上传的文件的路径
  4011. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4012. }
  4013. else if (TypeName == "B")//B代表商邀相关文件
  4014. {
  4015. if (!Directory.Exists(fileDir))
  4016. {
  4017. Directory.CreateDirectory(fileDir);
  4018. }
  4019. //上传的文件的路径
  4020. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4021. }
  4022. using (FileStream fs = System.IO.File.Create(filePath))
  4023. {
  4024. file.CopyTo(fs);
  4025. fs.Flush();
  4026. }
  4027. return Ok(JsonView(true, "上传成功!", projectFileName));
  4028. }
  4029. else
  4030. {
  4031. return Ok(JsonView(false, "上传失败!"));
  4032. }
  4033. }
  4034. catch (Exception ex)
  4035. {
  4036. return Ok(JsonView(false, "程序错误!"));
  4037. }
  4038. }
  4039. /// <summary>
  4040. /// 删除指定文件
  4041. /// </summary>
  4042. /// <param name="dto"></param>
  4043. /// <returns></returns>
  4044. [HttpPost]
  4045. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4046. public async Task<IActionResult> DelFile(DelFileDto dto)
  4047. {
  4048. try
  4049. {
  4050. var TypeName = Request.Headers["TypeName"].ToString();
  4051. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4052. string filePath = "";
  4053. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4054. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4055. int id = 0;
  4056. if (TypeName == "A")
  4057. {
  4058. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  4059. // 删除该文件
  4060. System.IO.File.Delete(filePath);
  4061. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  4062. .Where(a => a.Id == dto.Id)
  4063. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  4064. .ExecuteCommandAsync();
  4065. }
  4066. else if (TypeName == "B")
  4067. {
  4068. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  4069. // 删除该文件
  4070. System.IO.File.Delete(filePath);
  4071. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  4072. if (info != null)
  4073. {
  4074. string[] files = new string[] { };
  4075. if (!string.IsNullOrEmpty(info.Attachment))
  4076. {
  4077. try
  4078. {
  4079. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  4080. }
  4081. catch (Exception)
  4082. {
  4083. files = new List<string>() { info.Attachment }.ToArray();
  4084. }
  4085. }
  4086. if (files.Length > 0)
  4087. {
  4088. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  4089. string filePath2 = string.Empty;
  4090. if (files1.Length > 0)
  4091. {
  4092. filePath2 = JsonConvert.SerializeObject(files1);
  4093. }
  4094. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4095. .Where(a => a.Id == dto.Id)
  4096. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  4097. .ExecuteCommandAsync();
  4098. }
  4099. }
  4100. }
  4101. if (id != 0)
  4102. {
  4103. return Ok(JsonView(true, "成功!"));
  4104. }
  4105. else
  4106. {
  4107. return Ok(JsonView(false, "失败!"));
  4108. }
  4109. }
  4110. catch (Exception ex)
  4111. {
  4112. return Ok(JsonView(false, "程序错误!"));
  4113. throw;
  4114. }
  4115. }
  4116. /// <summary>
  4117. /// 文件上传多个文件 可以带参数
  4118. /// </summary>
  4119. /// <param name="files"></param>
  4120. /// <returns></returns>
  4121. [HttpPost]
  4122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4123. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  4124. {
  4125. try
  4126. {
  4127. var TypeName = Request.Headers["TypeName"].ToString();
  4128. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4129. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  4130. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4131. var filePahts = new List<string>();
  4132. foreach (var file in files)
  4133. {
  4134. //文件名称
  4135. string projectFileName = file.FileName;
  4136. //上传的文件的路径
  4137. string filePath = $"{fileDir}/{projectFileName}";
  4138. if (TypeName == "A")//A代表团组增减款项
  4139. {
  4140. if (!Directory.Exists(fileDir))
  4141. {
  4142. Directory.CreateDirectory(fileDir);
  4143. }
  4144. //上传的文件的路径
  4145. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4146. }
  4147. else if (TypeName == "B")//B代表商邀相关文件
  4148. {
  4149. if (!Directory.Exists(fileDir))
  4150. {
  4151. Directory.CreateDirectory(fileDir);
  4152. }
  4153. //上传的文件的路径
  4154. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4155. }
  4156. using (FileStream fs = System.IO.File.Create(filePath))
  4157. {
  4158. file.CopyTo(fs);
  4159. fs.Flush();
  4160. }
  4161. filePahts.Add(projectFileName);
  4162. }
  4163. return Ok(JsonView(true, "上传成功!", filePahts));
  4164. }
  4165. catch (Exception ex)
  4166. {
  4167. return Ok(JsonView(false, "程序错误!"));
  4168. }
  4169. }
  4170. #endregion
  4171. #region 商邀费用录入
  4172. /// <summary>
  4173. /// 根据团组Id查询商邀费用列表
  4174. /// </summary>
  4175. /// <param name="dto"></param>
  4176. /// <returns></returns>
  4177. [HttpPost]
  4178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4179. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  4180. {
  4181. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  4182. if (groupData.Code != 0)
  4183. {
  4184. return Ok(JsonView(false, groupData.Msg));
  4185. }
  4186. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4187. }
  4188. /// <summary>
  4189. /// 商邀费用列表
  4190. /// 下载文件
  4191. /// </summary>
  4192. /// <param name="id"></param>
  4193. /// <returns></returns>
  4194. [HttpGet("{id}")]
  4195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4196. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  4197. {
  4198. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4199. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4200. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4201. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4202. var filePaths = new List<string>();
  4203. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4204. try
  4205. {
  4206. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4207. }
  4208. catch (Exception ex)
  4209. {
  4210. filePaths.Add(info.Attachment);
  4211. }
  4212. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4213. for (int i = 0; i < filePaths.Count; i++)
  4214. {
  4215. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4216. }
  4217. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4218. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4219. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4220. {
  4221. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4222. {
  4223. foreach (string filePath in filePaths)
  4224. {
  4225. if (System.IO.File.Exists(filePath))
  4226. {
  4227. // 获取文件名
  4228. string fileName = Path.GetFileName(filePath);
  4229. // 将文件添加到ZIP归档中
  4230. zipArchive.CreateEntryFromFile(filePath, fileName);
  4231. }
  4232. }
  4233. }
  4234. }
  4235. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4236. }
  4237. /// <summary>
  4238. /// 商邀费用 Info Page 基础数据源
  4239. /// </summary>
  4240. /// <returns></returns>
  4241. [HttpPost]
  4242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4243. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4244. {
  4245. try
  4246. {
  4247. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4248. if (groupData.Code != 0)
  4249. {
  4250. return Ok(JsonView(false, groupData.Msg));
  4251. }
  4252. return Ok(JsonView(true, "操作成功", groupData.Data));
  4253. }
  4254. catch (Exception ex)
  4255. {
  4256. return Ok(JsonView(false, ex.Message));
  4257. throw;
  4258. }
  4259. }
  4260. /// <summary>
  4261. /// 根据商邀费用ID查询C表和商邀费用数据
  4262. /// </summary>
  4263. /// <param name="dto"></param>
  4264. /// <returns></returns>
  4265. [HttpPost]
  4266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4267. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4268. {
  4269. try
  4270. {
  4271. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4272. if (groupData.Code != 0)
  4273. {
  4274. return Ok(JsonView(false, groupData.Msg));
  4275. }
  4276. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4277. }
  4278. catch (Exception ex)
  4279. {
  4280. return Ok(JsonView(false, ex.Message));
  4281. throw;
  4282. }
  4283. }
  4284. /// <summary>
  4285. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4286. /// </summary>
  4287. /// <param name="dto"></param>
  4288. /// <returns></returns>
  4289. [HttpPost]
  4290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4291. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4292. {
  4293. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4294. if (groupData.Code != 0)
  4295. {
  4296. return Ok(JsonView(false, groupData.Msg));
  4297. }
  4298. #region 应用推送
  4299. try
  4300. {
  4301. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4302. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4303. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4304. //2024-10-21 新增LZ UID
  4305. var userIds = new List<int>() { 21 };
  4306. string title = $"系统通知";
  4307. string content = "";
  4308. var diId = dto.DiId;
  4309. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4310. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4311. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4312. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4313. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4314. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4315. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4316. }
  4317. catch (Exception ex)
  4318. {
  4319. }
  4320. #endregion
  4321. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4322. }
  4323. /// <summary>
  4324. /// 商邀删除
  4325. /// </summary>
  4326. /// <param name="dto"></param>
  4327. /// <returns></returns>
  4328. [HttpPost]
  4329. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4330. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4331. {
  4332. try
  4333. {
  4334. _sqlSugar.BeginTran();
  4335. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4336. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4337. {
  4338. IsDel = 1,
  4339. DeleteUserId = dto.DeleteUserId,
  4340. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4341. })
  4342. .Where(it => it.Id == dto.Id)
  4343. .ExecuteCommand();
  4344. if (res1 > 0)
  4345. {
  4346. int _diId = 0;
  4347. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4348. if (_ioaInfo != null)
  4349. {
  4350. _diId = _ioaInfo.DiId;
  4351. }
  4352. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4353. .SetColumns(a => new Grp_CreditCardPayment()
  4354. {
  4355. IsDel = 1,
  4356. DeleteUserId = dto.DeleteUserId,
  4357. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4358. })
  4359. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4360. .ExecuteCommand();
  4361. if (res2 > 0)
  4362. {
  4363. _sqlSugar.CommitTran();
  4364. return Ok(JsonView(true, "删除成功!"));
  4365. }
  4366. }
  4367. _sqlSugar.RollbackTran();
  4368. return Ok(JsonView(false, "删除失败"));
  4369. }
  4370. catch (Exception ex)
  4371. {
  4372. _sqlSugar.RollbackTran();
  4373. return Ok(JsonView(false, ex.Message));
  4374. }
  4375. }
  4376. #endregion
  4377. #region 票据上传
  4378. /// <summary>
  4379. /// 团组模块文件上传
  4380. /// </summary>
  4381. /// <param name="dto"></param>
  4382. /// <returns></returns>
  4383. [HttpPost]
  4384. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4385. {
  4386. var jw = JsonView(false);
  4387. long M = 1024 * 1024;
  4388. if (dto.Files == null || dto.Files.Count == 0)
  4389. {
  4390. jw.Msg = "无文件信息!";
  4391. return Ok(jw);
  4392. }
  4393. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4394. {
  4395. jw.Msg = "文件大小超过20M!";
  4396. return Ok(jw);
  4397. }
  4398. //var nameSp = dto.File.FileName.Split(".");
  4399. //if (nameSp.Length < 2)
  4400. //{
  4401. // jw.Msg = "拓展名称有误!";
  4402. // return Ok(jw);
  4403. //}
  4404. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4405. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4406. //{
  4407. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4408. // return Ok(jw);
  4409. //}
  4410. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4411. if (Ctable == null)
  4412. {
  4413. jw.Msg = "Ctable指向有误!";
  4414. return Ok(jw);
  4415. }
  4416. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4417. if (groupInfo == null)
  4418. {
  4419. jw.Msg = "团组信息不存在!";
  4420. return Ok(jw);
  4421. }
  4422. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4423. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4424. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4425. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4426. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4427. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4428. try
  4429. {
  4430. if (!Directory.Exists(fileBase))
  4431. {
  4432. Directory.CreateDirectory(fileBase);
  4433. }
  4434. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4435. foreach (var fileStream in dto.Files)
  4436. {
  4437. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4438. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4439. {
  4440. Cid = dto.Cid,
  4441. CreateTime = DateTime.Now,
  4442. CreateUserId = dto.Userid,
  4443. Ctable = dto.Ctable,
  4444. Diid = dto.Diid,
  4445. IsDel = 0,
  4446. FilePath = saveFilePath,
  4447. FileName = fileStream.FileName
  4448. };
  4449. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4450. {
  4451. fileStream.CopyTo(fs);
  4452. fs.Flush();
  4453. }
  4454. saveArr.Add(file);
  4455. }
  4456. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4457. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4458. jw = JsonView(true, "保存成功!", new
  4459. {
  4460. count = addResult,
  4461. filesName = saveArr.Select(x => x.FileName)
  4462. });
  4463. }
  4464. catch (Exception ex)
  4465. {
  4466. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4467. {
  4468. count = 0,
  4469. filesName = new string[0],
  4470. });
  4471. }
  4472. return Ok(jw);
  4473. }
  4474. /// <summary>
  4475. /// 查询各模块已保存文件
  4476. /// </summary>
  4477. /// <param name="dto"></param>
  4478. /// <returns></returns>
  4479. [HttpPost]
  4480. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4481. {
  4482. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4483. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4484. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4485. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4486. {
  4487. expression = Expressionable.Create<Grp_GroupModelFile>()
  4488. .And(x => visaIds.Contains(x.CreateUserId));
  4489. }
  4490. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4491. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4492. .Where(expression.ToExpression())
  4493. .ToList();
  4494. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4495. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4496. {
  4497. x.FileName,
  4498. x.Id,
  4499. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4500. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4501. })));
  4502. }
  4503. /// <summary>
  4504. /// 下载该团组下的所有文件
  4505. /// </summary>
  4506. /// <param name="dto"></param>
  4507. /// <returns></returns>
  4508. [HttpPost]
  4509. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4510. {
  4511. var jw = JsonView(false);
  4512. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4513. if (groupInfo == null)
  4514. {
  4515. jw.Msg = "团组信息不存在!";
  4516. return Ok(jw);
  4517. }
  4518. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4519. var isModule = Convert.ToBoolean(dto.isModule);
  4520. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4521. IOOperatorHelper io = new IOOperatorHelper();
  4522. if (isModule)
  4523. {
  4524. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4525. foreach (var moduleArr in moduleGroup)
  4526. {
  4527. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4528. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4529. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4530. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4531. foreach (var item in moduleArr)
  4532. {
  4533. if (System.IO.File.Exists(item.FilePath))
  4534. {
  4535. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4536. {
  4537. byte[] bytes = new byte[fileStream.Length];
  4538. fileStream.Read(bytes, 0, bytes.Length);
  4539. fileStream.Close();
  4540. Stream stream = new MemoryStream(bytes);
  4541. chiZips.Add(item.FileName, stream);
  4542. }
  4543. }
  4544. }
  4545. if (chiZips.Count > 0)
  4546. {
  4547. var byts = io.ConvertZipStream(chiZips);
  4548. Stream stream = new MemoryStream(byts);
  4549. Zips.Add(key.Name + "_.zip", stream);
  4550. }
  4551. }
  4552. }
  4553. else
  4554. {
  4555. foreach (var item in dbQuery)
  4556. {
  4557. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4558. {
  4559. byte[] bytes = new byte[fileStream.Length];
  4560. fileStream.Read(bytes, 0, bytes.Length);
  4561. fileStream.Close();
  4562. Stream stream = new MemoryStream(bytes);
  4563. while (Zips.Keys.Contains(item.FileName))
  4564. {
  4565. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4566. }
  4567. Zips.Add(item.FileName, stream);
  4568. }
  4569. }
  4570. }
  4571. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4572. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4573. if (Zips.Count > 0)
  4574. {
  4575. var byts = io.ConvertZipStream(Zips);
  4576. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4577. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4578. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4579. }
  4580. else
  4581. {
  4582. jw.Msg = "暂无生成文件!";
  4583. }
  4584. return Ok(jw);
  4585. }
  4586. /// <summary>
  4587. /// 下载该团组下此模块的所有文件
  4588. /// </summary>
  4589. /// <param name="dto"></param>
  4590. /// <returns></returns>
  4591. [HttpPost]
  4592. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4593. {
  4594. var jw = JsonView(false);
  4595. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4596. if (groupInfo == null)
  4597. {
  4598. jw.Msg = "团组信息不存在!";
  4599. return Ok(jw);
  4600. }
  4601. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4602. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4603. && x.IsDel == 0);
  4604. if (key == null)
  4605. {
  4606. jw.Msg = "Ctable指向错误!";
  4607. return Ok(jw);
  4608. }
  4609. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4610. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4611. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4612. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4613. IOOperatorHelper io = new IOOperatorHelper();
  4614. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4615. foreach (var item in dbQuery)
  4616. {
  4617. if (System.IO.File.Exists(item.FilePath))
  4618. {
  4619. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4620. {
  4621. byte[] bytes = new byte[fileStream.Length];
  4622. fileStream.Read(bytes, 0, bytes.Length);
  4623. fileStream.Close();
  4624. Stream stream = new MemoryStream(bytes);
  4625. while (Zips.Keys.Contains(item.FileName))
  4626. {
  4627. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4628. }
  4629. Zips.Add(item.FileName, stream);
  4630. }
  4631. }
  4632. }
  4633. if (Zips.Count > 0)
  4634. {
  4635. var byts = io.ConvertZipStream(Zips);
  4636. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4637. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4638. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4639. }
  4640. else
  4641. {
  4642. jw.Msg = "暂无生成文件!";
  4643. }
  4644. return Ok(jw);
  4645. }
  4646. /// <summary>
  4647. /// 删除该团组下的指定文件
  4648. /// </summary>
  4649. /// <param name="dto"></param>
  4650. /// <returns></returns>
  4651. [HttpPost]
  4652. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4653. {
  4654. var jw = JsonView(false);
  4655. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4656. if (sing == null)
  4657. {
  4658. jw.Msg = "暂无";
  4659. return Ok(jw);
  4660. }
  4661. if (System.IO.File.Exists(sing.FilePath))
  4662. {
  4663. try
  4664. {
  4665. System.IO.File.Delete(sing.FilePath);
  4666. }
  4667. catch (Exception ex)
  4668. {
  4669. jw.Msg = "删除失败!" + ex.Message;
  4670. return Ok(jw);
  4671. }
  4672. }
  4673. sing.IsDel = 1;
  4674. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4675. sing.DeleteUserId = dto.UserId;
  4676. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4677. jw = JsonView(true, "删除成功!");
  4678. return Ok(jw);
  4679. }
  4680. #endregion
  4681. #region 共享文件上传
  4682. /// <summary>
  4683. /// 共享文件数据初始化
  4684. /// </summary>
  4685. /// <returns></returns>
  4686. [HttpGet]
  4687. public async Task<IActionResult> SharedFileInit(int userid ,int portType)
  4688. {
  4689. var marketingDepartmentIds = new List<int> { 6, 26 , 27 , 28 };
  4690. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  4691. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  4692. .Select(x => x.Id)
  4693. .ToList()
  4694. .Contains(userid);
  4695. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  4696. .Where(x => x.STid == 111 && x.IsDel == 0)
  4697. .Select(x => new
  4698. {
  4699. x.Name,
  4700. x.Id,
  4701. }).ToList();
  4702. if (isMarketingDepartment)
  4703. {
  4704. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  4705. }
  4706. if (portType == 1)
  4707. {
  4708. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  4709. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  4710. .Where(x => x.IsDel == 0)
  4711. .OrderByDescending(x=> x.VisitDate )
  4712. .Select(x => new
  4713. {
  4714. x.TeamName,
  4715. x.Id,
  4716. x.CityId,
  4717. })
  4718. .ToList()
  4719. .Select(x=>
  4720. {
  4721. var provinceId = x.CityId;
  4722. var isDefualtVal = true;
  4723. if (provinceId > 0)
  4724. {
  4725. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  4726. if (parentId != null)
  4727. {
  4728. isDefualtVal = false;
  4729. provinceId = (int)parentId;
  4730. }
  4731. }
  4732. if (isDefualtVal)
  4733. {
  4734. provinceId = 122; //默认四川
  4735. }
  4736. return new
  4737. {
  4738. x.TeamName,
  4739. x.Id,
  4740. provinceId,
  4741. };
  4742. })
  4743. .ToList();
  4744. return Ok(JsonView(true, "SUCCESS!", new
  4745. {
  4746. dropDownType,
  4747. dropDownGroupList,
  4748. isMarketingDepartment
  4749. }));
  4750. }
  4751. else if (portType == 2 || portType == 3)
  4752. {
  4753. return Ok(JsonView(true, "SUCCESS!", new
  4754. {
  4755. dropDownType,
  4756. isMarketingDepartment
  4757. }));
  4758. }
  4759. else
  4760. {
  4761. return Ok(JsonView(false, "portType有误!"));
  4762. }
  4763. }
  4764. /// <summary>
  4765. /// 共享文件上传
  4766. /// </summary>
  4767. /// <param name="dto"></param>
  4768. /// <returns></returns>
  4769. [HttpPost]
  4770. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  4771. {
  4772. var isGroup = new List<int> { 1412 };
  4773. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  4774. {
  4775. return Ok(JsonView(false, "该文件需要关联团组!"));
  4776. }
  4777. if (dto.Files == null || dto.Files.Count == 0)
  4778. {
  4779. return Ok(JsonView(false, "无文件信息!"));
  4780. }
  4781. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  4782. {
  4783. return Ok(JsonView(false, "文件大小超过20M!"));
  4784. }
  4785. if (dto.Userid < 1)
  4786. {
  4787. return Ok(JsonView(false, "请传入有效的Userid!"));
  4788. }
  4789. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  4790. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  4791. .Select((u, j) => new
  4792. {
  4793. u.CnName,
  4794. UserId = u.Id,
  4795. j.JobName,
  4796. })
  4797. .First();
  4798. if (jobInfo == null)
  4799. {
  4800. return Ok(JsonView(false, "请传入有效的Userid!"));
  4801. }
  4802. List<string> commonFileExtensions = new List<string>
  4803. {
  4804. // 文本文件
  4805. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  4806. // 图片文件
  4807. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  4808. // 视频文件
  4809. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  4810. // 音频文件
  4811. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  4812. // 压缩文件
  4813. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  4814. // 数据文件
  4815. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  4816. };
  4817. try
  4818. {
  4819. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  4820. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  4821. commonFileExtensions.AddRange(settingExtend);
  4822. }
  4823. catch (Exception)
  4824. { }
  4825. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  4826. if (setdata == null)
  4827. {
  4828. return Ok(JsonView(false, "请传入有效的FileType!"));
  4829. }
  4830. List<Grp_GroupShareFile> insertList = new List<Grp_GroupShareFile>();
  4831. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  4832. if (!Directory.Exists(winPath))
  4833. {
  4834. Directory.CreateDirectory(winPath);
  4835. }
  4836. foreach (var item in dto.Files)
  4837. {
  4838. var houzui = Path.GetExtension(item.FileName);
  4839. if (!commonFileExtensions.Contains(houzui))
  4840. {
  4841. return Ok(JsonView(false, "未知后缀名称!"));
  4842. }
  4843. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  4844. var saveFilePath = winPath + fileName;
  4845. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4846. {
  4847. item.CopyTo(fs);
  4848. fs.Flush();
  4849. }
  4850. var fileDetail = new Grp_GroupShareFile()
  4851. {
  4852. CreateUserId = dto.Userid,
  4853. CreateTime = DateTime.Now,
  4854. UploadJob = jobInfo.JobName,
  4855. FileName = fileName,
  4856. FileType = dto.FileType,
  4857. Diid = dto.Diid,
  4858. FilePath = winPath + fileName,
  4859. };
  4860. insertList.Add(fileDetail);
  4861. }
  4862. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  4863. return Ok(JsonView(true, "保存成功!"));
  4864. }
  4865. /// <summary>
  4866. /// 查询共享文件列表
  4867. /// </summary>
  4868. /// <param name="dto"></param>
  4869. /// <returns></returns>
  4870. [HttpPost]
  4871. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  4872. {
  4873. var isGroup = new List<int> { 1412 };
  4874. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  4875. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  4876. .And(x => x.Diid == dto.Diid)
  4877. .And(x => x.FileType == dto.FileType)
  4878. .And(x => x.IsDel == 0)
  4879. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  4880. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  4881. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  4882. int totalCount = 0;
  4883. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  4884. .Where(queryExpression.ToExpression())
  4885. .OrderBy(x => x.UploadJob)
  4886. .Select(x => new
  4887. {
  4888. x.Id,
  4889. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  4890. x.FileName,
  4891. x.FileType,
  4892. x.CreateTime,
  4893. })
  4894. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  4895. return Ok(JsonView(true, "SUCCESS!", new
  4896. {
  4897. FileList = dbQuery,
  4898. dto.PageSize,
  4899. dto.PageIndex,
  4900. totalCount
  4901. }));
  4902. }
  4903. /// <summary>
  4904. /// 删除共享文件模块下的指定文件
  4905. /// </summary>
  4906. /// <param name="dto"></param>
  4907. /// <returns></returns>
  4908. [HttpPost]
  4909. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  4910. {
  4911. var jw = JsonView(false);
  4912. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4913. if (sing == null)
  4914. {
  4915. jw.Msg = "暂无文件信息!";
  4916. return Ok(jw);
  4917. }
  4918. if (sing.CreateUserId != dto.UserId)
  4919. {
  4920. jw.Msg = "只能删除自己上传的文件!";
  4921. return Ok(jw);
  4922. }
  4923. if (System.IO.File.Exists(sing.FilePath))
  4924. {
  4925. try
  4926. {
  4927. System.IO.File.Delete(sing.FilePath);
  4928. }
  4929. catch (Exception ex)
  4930. {
  4931. jw.Msg = "删除失败!" + ex.Message;
  4932. return Ok(jw);
  4933. }
  4934. }
  4935. sing.IsDel = 1;
  4936. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4937. sing.DeleteUserId = dto.UserId;
  4938. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  4939. jw = JsonView(true, "删除成功!");
  4940. return Ok(jw);
  4941. }
  4942. #endregion
  4943. #region 团组英文资料
  4944. /// <summary>
  4945. /// 查询团组英文所有资料
  4946. /// </summary>
  4947. /// <param name="dto"></param>
  4948. /// <returns></returns>
  4949. [HttpPost]
  4950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4951. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4952. {
  4953. try
  4954. {
  4955. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4956. if (groupData.Code != 0)
  4957. {
  4958. return Ok(JsonView(false, groupData.Msg));
  4959. }
  4960. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4961. }
  4962. catch (Exception ex)
  4963. {
  4964. return Ok(JsonView(false, "程序错误!"));
  4965. throw;
  4966. }
  4967. }
  4968. /// <summary>
  4969. /// 团组英文资料操作(Status:1.新增,2.修改)
  4970. /// </summary>
  4971. /// <param name="dto"></param>
  4972. /// <returns></returns>
  4973. [HttpPost]
  4974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4975. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4976. {
  4977. try
  4978. {
  4979. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4980. if (groupData.Code != 0)
  4981. {
  4982. return Ok(JsonView(false, groupData.Msg));
  4983. }
  4984. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4985. }
  4986. catch (Exception ex)
  4987. {
  4988. return Ok(JsonView(false, "程序错误!"));
  4989. throw;
  4990. }
  4991. }
  4992. /// <summary>
  4993. /// 团组英文资料Id查询数据
  4994. /// </summary>
  4995. /// <param name="dto"></param>
  4996. /// <returns></returns>
  4997. [HttpPost]
  4998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4999. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  5000. {
  5001. try
  5002. {
  5003. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  5004. if (_DelegationEnData != null)
  5005. {
  5006. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  5007. }
  5008. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  5009. }
  5010. catch (Exception ex)
  5011. {
  5012. return Ok(JsonView(false, "程序错误!"));
  5013. throw;
  5014. }
  5015. }
  5016. /// <summary>
  5017. /// 团组英文资料删除
  5018. /// </summary>
  5019. /// <param name="dto"></param>
  5020. /// <returns></returns>
  5021. [HttpPost]
  5022. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5023. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  5024. {
  5025. try
  5026. {
  5027. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  5028. if (!res)
  5029. {
  5030. return Ok(JsonView(false, "删除失败"));
  5031. }
  5032. return Ok(JsonView(true, "删除成功!"));
  5033. }
  5034. catch (Exception ex)
  5035. {
  5036. return Ok(JsonView(false, "程序错误!"));
  5037. throw;
  5038. }
  5039. }
  5040. #endregion
  5041. #region 导出邀请函
  5042. /// <summary>
  5043. /// 导出邀请函页面初始化
  5044. /// </summary>
  5045. /// <param name="dto"></param>
  5046. /// <returns></returns>
  5047. [HttpPost]
  5048. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5049. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  5050. {
  5051. try
  5052. {
  5053. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  5054. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  5055. if (dto.DiId == 0)
  5056. {
  5057. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  5058. }
  5059. else
  5060. {
  5061. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  5062. }
  5063. return Ok(JsonView(true, "查询成功!", new
  5064. {
  5065. deleClient = crm_Deles,
  5066. delegations = grp_Delegations
  5067. }));
  5068. }
  5069. catch (Exception ex)
  5070. {
  5071. return Ok(JsonView(false, "程序错误!"));
  5072. throw;
  5073. }
  5074. }
  5075. /// <summary>
  5076. /// 导出邀请函
  5077. /// </summary>
  5078. /// <param name="dto"></param>
  5079. /// <returns></returns>
  5080. [HttpPost]
  5081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5082. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  5083. {
  5084. #region 参数验证
  5085. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5086. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5087. #endregion
  5088. try
  5089. {
  5090. Dictionary<string, string> transDic = new Dictionary<string, string>();
  5091. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  5092. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  5093. From Grp_TourClientList tcl
  5094. Left Join
  5095. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  5096. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  5097. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  5098. From Crm_DeleClient dc
  5099. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  5100. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  5101. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  5102. Where dc.IsDel = 0) temp
  5103. On temp.DcId =tcl.ClientId
  5104. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  5105. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  5106. List<string> texts = new List<string>();
  5107. if (datas.Count != 0)
  5108. {
  5109. foreach (TourClientListDetailsView item in datas)
  5110. {
  5111. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  5112. {
  5113. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  5114. }
  5115. else
  5116. {
  5117. string name = item.LastName + item.FirstName;
  5118. texts.Add(name);
  5119. }
  5120. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  5121. {
  5122. if (!transDic.ContainsKey(item.Job))
  5123. {
  5124. texts.Add(item.Job);
  5125. }
  5126. }
  5127. if (!string.IsNullOrEmpty(item.CompanyFullName))
  5128. {
  5129. texts.Add(item.CompanyFullName);
  5130. }
  5131. }
  5132. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  5133. if (transData.Count > 0)
  5134. {
  5135. foreach (TranslateResult item in transData)
  5136. {
  5137. if (!transDic.ContainsKey(item.Query))
  5138. {
  5139. transDic.Add(item.Query, item.Translation);
  5140. }
  5141. }
  5142. }
  5143. List<GuestList> list = new List<GuestList>();
  5144. foreach (TourClientListDetailsView dele in datas)
  5145. {
  5146. GuestList guestList = new GuestList();
  5147. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  5148. {
  5149. guestList.Name = dele.Pinyin;
  5150. }
  5151. else
  5152. {
  5153. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  5154. guestList.Name = Name;
  5155. }
  5156. if (dele.Sex == 0)
  5157. {
  5158. guestList.Sex = "Male";
  5159. }
  5160. else if (dele.Sex == 1)
  5161. {
  5162. guestList.Sex = "Female";
  5163. }
  5164. guestList.DOB = dele.BirthDay.Replace('-', '.');
  5165. if (!string.IsNullOrEmpty(dele.Job))
  5166. {
  5167. guestList.Job = dele.Job;
  5168. }
  5169. list.Add(guestList);
  5170. }
  5171. //载入模板
  5172. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  5173. DocumentBuilder builder = new DocumentBuilder(doc);
  5174. //获取word里所有表格
  5175. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5176. //获取所填表格的序数
  5177. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5178. var rowStart = tableOne.Rows[0]; //获取第1行
  5179. //循环赋值
  5180. for (int i = 0; i < list.Count; i++)
  5181. {
  5182. builder.MoveToCell(0, i + 1, 0, 0);
  5183. builder.Write(list[i].Name.ToString());
  5184. builder.MoveToCell(0, i + 1, 1, 0);
  5185. builder.Write(list[i].Sex.ToString());
  5186. builder.MoveToCell(0, i + 1, 2, 0);
  5187. builder.Write(list[i].DOB.ToString());
  5188. builder.MoveToCell(0, i + 1, 3, 0);
  5189. builder.Write(list[i].Job.ToString());
  5190. }
  5191. //删除多余行
  5192. while (tableOne.Rows.Count > list.Count + 1)
  5193. {
  5194. tableOne.Rows.RemoveAt(list.Count + 1);
  5195. }
  5196. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5197. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  5198. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  5199. doc.Save(filePath);
  5200. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  5201. return Ok(JsonView(true, "操作成功!", Url));
  5202. }
  5203. else
  5204. {
  5205. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  5206. }
  5207. }
  5208. catch (Exception ex)
  5209. {
  5210. return Ok(JsonView(false, ex.Message));
  5211. throw;
  5212. }
  5213. }
  5214. #endregion
  5215. #region 团组经理模块 出入境费用
  5216. /// <summary>
  5217. /// 团组模块 - 出入境费用 - 省份基础数据源
  5218. /// </summary>
  5219. /// <returns></returns>
  5220. [HttpGet]
  5221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5222. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  5223. {
  5224. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  5225. }
  5226. /// <summary>
  5227. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  5228. /// </summary>
  5229. /// <returns></returns>
  5230. [HttpPost]
  5231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5232. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  5233. {
  5234. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  5235. var groupNamFirst = groupNameData.FirstOrDefault();
  5236. //SetDataInfoView
  5237. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66) .ToListAsync();
  5238. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  5239. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  5240. //验证城市归属并给默认值
  5241. int provinceId = 122;
  5242. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  5243. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  5244. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  5245. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  5246. return Ok(JsonView(true, "查询成功!", new
  5247. {
  5248. GroupNameData = groupNameData,
  5249. CurrencyData = _CurrencyData,
  5250. WordTypeData = wordTypeData,
  5251. ExcelTypeData = excelTypeData,
  5252. CurrencyInit = _currencyInfos,
  5253. ViewPermissionData = viewPermissionData
  5254. }));
  5255. }
  5256. /// <summary>
  5257. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  5258. /// </summary>
  5259. /// <returns></returns>
  5260. [HttpGet("{provinceId}")]
  5261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5262. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  5263. {
  5264. //验证城市归属并给默认值
  5265. if (provinceId < 1) provinceId = 122;
  5266. /*
  5267. * 122 四川
  5268. * 108 贵州
  5269. * 103 重庆
  5270. * 132 云南
  5271. */
  5272. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  5273. return Ok(JsonView(true, "查询成功!", new
  5274. {
  5275. WordTypeData = wordTypeData,
  5276. ExcelTypeData = excelTypeData,
  5277. }));
  5278. }
  5279. /// <summary>
  5280. /// 团组模块 - 出入境费用
  5281. /// 实时汇率 tips
  5282. /// 签证费用 tips
  5283. /// 机票费用 tips
  5284. /// </summary>
  5285. /// <returns></returns>
  5286. [HttpPost]
  5287. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5288. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  5289. {
  5290. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  5291. //默认币种显示
  5292. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  5293. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  5294. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  5295. return Ok(JsonView(true, "查询成功!", new
  5296. {
  5297. //GroupNameData = groupNameData.Data,
  5298. visaData = visaData.Data,
  5299. airData = airData.Data,
  5300. reteInfos = reteInfos
  5301. }));
  5302. }
  5303. /// <summary>
  5304. /// 团组模块 - 出入境费用 - Info
  5305. /// </summary>
  5306. /// <returns></returns>
  5307. [HttpPost]
  5308. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  5309. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5310. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  5311. {
  5312. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  5313. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  5314. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  5315. }
  5316. /// <summary>
  5317. /// 团组模块 - 出入境费用 - 设置view权限
  5318. /// </summary>
  5319. /// <returns></returns>
  5320. [HttpPost]
  5321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5322. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  5323. {
  5324. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  5325. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  5326. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  5327. var permissions = new List<Grp_EnterExitCostPermission>();
  5328. foreach (var userId in dto.UserIds)
  5329. {
  5330. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  5331. }
  5332. if (permissions.Any())
  5333. {
  5334. _sqlSugar.BeginTran();
  5335. try
  5336. {
  5337. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  5338. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  5339. if (result < 1)
  5340. {
  5341. _sqlSugar.RollbackTran();
  5342. return Ok(JsonView(false));
  5343. }
  5344. }
  5345. catch (Exception ex)
  5346. {
  5347. _sqlSugar.RollbackTran();
  5348. return Ok(JsonView(false, ex.Message));
  5349. }
  5350. _sqlSugar.CommitTran();
  5351. return Ok(JsonView(true));
  5352. }
  5353. return Ok(JsonView(false));
  5354. }
  5355. /// <summary>
  5356. /// 团组模块 - 出入境费用 - Add And Update
  5357. /// </summary>
  5358. /// <returns></returns>
  5359. [HttpPost]
  5360. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  5361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5362. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  5363. {
  5364. try
  5365. {
  5366. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5367. if (dto.DayOtherPriceData.Any())
  5368. {
  5369. var inserList = dto.DayOtherPriceData
  5370. .Where(x => x.Id == 0)
  5371. .Select(x => new Grp_DayOtherPrice
  5372. {
  5373. Cost = x.Cost,
  5374. Id = x.Id,
  5375. CreateTime = DateTime.Now,
  5376. CreateUserId = dto.UserId,
  5377. Currency = x.Currency,
  5378. Diid = x.DiId,
  5379. Index = x.Index,
  5380. IsDel = 0,
  5381. SetDataId = x.SetDataId,
  5382. SubTotal = x.SubTotal,
  5383. Remark = x.Remark
  5384. })
  5385. .ToList();
  5386. var updateList = dto.DayOtherPriceData
  5387. .Where(x => x.Id != 0)
  5388. .Select(x => new Grp_DayOtherPrice
  5389. {
  5390. Cost = x.Cost,
  5391. Id = x.Id,
  5392. CreateTime = DateTime.Now,
  5393. CreateUserId = dto.UserId,
  5394. Currency = x.Currency,
  5395. Diid = x.DiId,
  5396. Index = x.Index,
  5397. IsDel = 0,
  5398. SetDataId = x.SetDataId,
  5399. SubTotal = x.SubTotal,
  5400. Remark = x.Remark
  5401. })
  5402. .ToList();
  5403. //添加
  5404. _sqlSugar.BeginTran();
  5405. if (inserList.Any())
  5406. {
  5407. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  5408. }
  5409. if (updateList.Any())
  5410. {
  5411. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  5412. }
  5413. _sqlSugar.CommitTran();
  5414. }
  5415. if (data.Code != 0)
  5416. {
  5417. return Ok(JsonView(false, data.Msg));
  5418. }
  5419. //生成默认文件pdf并且通知人员
  5420. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  5421. {
  5422. DiId = dto.DiId,
  5423. ExportType = 1,
  5424. SubTypeId = 1005
  5425. }, "pdf");
  5426. //发送通知
  5427. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  5428. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  5429. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  5430. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  5431. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  5432. //汇率信息记录
  5433. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  5434. return Ok(JsonView(true, data.Msg, data.Data));
  5435. }
  5436. catch (Exception ex)
  5437. {
  5438. return Ok(JsonView(false, ex.Message));
  5439. }
  5440. }
  5441. /// <summary>
  5442. /// 团组模块 - 出入境费用 - Confirm 费用
  5443. /// </summary>
  5444. /// <returns></returns>
  5445. [HttpPost]
  5446. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5447. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  5448. {
  5449. //TODO:测试完毕需把对应的用户ID更改
  5450. //1、数据表添加字段
  5451. //2、更改字段接口()
  5452. var _view = await _enterExitCostRep.ConfirmCost(dto);
  5453. //3、确认成功 给财务发送消息
  5454. if (_view.Code == 200)
  5455. {
  5456. if (dto.Type == 1)
  5457. {
  5458. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  5459. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  5460. }
  5461. }
  5462. return Ok(_view);
  5463. }
  5464. /// <summary>
  5465. /// 团组模块 - 出入境费用 - File download
  5466. /// </summary>
  5467. /// <param name="dto"></param>
  5468. /// <returns></returns>
  5469. [HttpPost]
  5470. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  5471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5472. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  5473. {
  5474. try
  5475. {
  5476. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  5477. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  5478. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  5479. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  5480. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  5481. 3 团组成员名单 1 团组成员名单", ""));
  5482. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  5483. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  5484. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  5485. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  5486. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  5487. //数据源
  5488. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  5489. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  5490. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  5491. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  5492. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  5493. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  5494. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  5495. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  5496. .Select((x, a, b) => new
  5497. {
  5498. x.Index,
  5499. itemName = a.Name,
  5500. CurrencyStr = b.Name,
  5501. x.Cost,
  5502. x.SubTotal,
  5503. x.Remark
  5504. })
  5505. .OrderBy((x) => x.Index)
  5506. .ToList(); //其他款项费用
  5507. var peiceItemCurrencys = new List<string>();
  5508. if (_DayAndCosts.Any())
  5509. {
  5510. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  5511. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  5512. }
  5513. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  5514. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  5515. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  5516. {
  5517. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  5518. }
  5519. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5520. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5521. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5522. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5523. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5524. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5525. .Select((tcl, dc, cc) => new ClientInfo
  5526. {
  5527. LastName = dc.LastName,
  5528. FirstName = dc.FirstName,
  5529. Sex = dc.Sex,
  5530. Birthday = dc.BirthDay,
  5531. Company = cc.CompanyFullName,
  5532. Job = dc.Job
  5533. })
  5534. .ToList();
  5535. foreach (var item in DeleClientList)
  5536. {
  5537. EncryptionProcessor.DecryptProperties(item);
  5538. }
  5539. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5540. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5541. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5542. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5543. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5544. if (dto.ExportType == 1) //明细表
  5545. {
  5546. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5547. {
  5548. //获取模板
  5549. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5550. //载入模板
  5551. Document doc = new Document(tempPath);
  5552. DocumentBuilder builder = new DocumentBuilder(doc);
  5553. //利用键值对存放数据
  5554. Dictionary<string, string> dic = new Dictionary<string, string>();
  5555. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5556. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5557. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5558. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5559. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5560. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5561. //境内费用(其他费用)
  5562. if (_EnterExitCosts.ChoiceOne == 1)
  5563. {
  5564. string row1_1 = "";
  5565. if (_EnterExitCosts.Visa > 0)
  5566. {
  5567. //insidePayTotal += _EnterExitCosts.Visa;
  5568. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5569. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5570. //{
  5571. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  5572. //}
  5573. }
  5574. string row1_2 = "";
  5575. if (_EnterExitCosts.YiMiao > 0)
  5576. {
  5577. //insidePayTotal += _EnterExitCosts.YiMiao;
  5578. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5579. }
  5580. if (_EnterExitCosts.HeSuan > 0)
  5581. {
  5582. //insidePayTotal += _EnterExitCosts.HeSuan;
  5583. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5584. }
  5585. if (_EnterExitCosts.Service > 0)
  5586. {
  5587. //insidePayTotal += _EnterExitCosts.Service;
  5588. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5589. }
  5590. string row1_3 = "";
  5591. if (_EnterExitCosts.Safe > 0)
  5592. {
  5593. //insidePayTotal += _EnterExitCosts.Safe;
  5594. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5595. }
  5596. if (_EnterExitCosts.Ticket > 0)
  5597. {
  5598. //insidePayTotal += _EnterExitCosts.Ticket;
  5599. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5600. }
  5601. string row1 = "";
  5602. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5603. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5604. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5605. row1 += $"备注:{_EnterExitCosts.Remark}";
  5606. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5607. dic.Add("Row1Str", row1);
  5608. }
  5609. string airTotalStr = string.Empty,
  5610. airPriceStr = string.Empty;
  5611. //经济舱
  5612. if (_EnterExitCosts.SumJJC == 1)
  5613. {
  5614. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5615. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5616. }
  5617. //公务舱
  5618. if (_EnterExitCosts.SumGWC == 1)
  5619. {
  5620. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5621. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5622. }
  5623. //头等舱
  5624. if (_EnterExitCosts.SumTDC == 1)
  5625. {
  5626. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5627. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5628. }
  5629. //汇率描述
  5630. string rateStr = "";
  5631. if (peiceItemCurrencyInfos.Any())
  5632. {
  5633. rateStr = "\r\n汇率描述:";
  5634. foreach (var item in peiceItemCurrencyInfos)
  5635. {
  5636. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  5637. }
  5638. }
  5639. string twoItemRemark = "备注:";
  5640. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  5641. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  5642. dic.Add("AirTotalStr", airTotalStr);
  5643. dic.Add("AirPriceStr", airPriceStr);
  5644. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5645. dic.Add("TwoItemRemark", twoItemRemark);
  5646. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5647. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5648. int table1Row = 0,
  5649. table2Row = 0,
  5650. table3Row = 0,
  5651. table4Row = 0,
  5652. table5Row = 0;
  5653. //住宿费
  5654. if (_EnterExitCosts.ChoiceThree == 1)
  5655. {
  5656. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5657. table1Row = dac1.Count;
  5658. #region 填充word表格内容
  5659. for (int i = 0; i < dac1.Count; i++)
  5660. {
  5661. Grp_DayAndCost dac = dac1[i];
  5662. if (dac == null) continue;
  5663. builder.MoveToCell(0, i, 0, 0);
  5664. builder.Write("第" + dac.Days.ToString() + "晚:");
  5665. builder.MoveToCell(0, i, 1, 0);
  5666. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5667. //builder.Write(dac.Place == null ? "" : dac.Place);
  5668. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5669. builder.MoveToCell(0, i, 2, 0);
  5670. builder.Write("费用标准:");
  5671. string curr = "";
  5672. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5673. if (currData != null)
  5674. {
  5675. curr = currData.Name;
  5676. }
  5677. builder.MoveToCell(0, i, 3, 0);
  5678. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5679. builder.MoveToCell(0, i, 4, 0);
  5680. builder.Write("费用小计:");
  5681. builder.MoveToCell(0, i, 5, 0);
  5682. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5683. }
  5684. #endregion
  5685. }
  5686. else dic.Add("SubZS", "0.00");
  5687. //删除多余行
  5688. while (table1.Rows.Count > table1Row)
  5689. {
  5690. table1.Rows.RemoveAt(table1Row);
  5691. }
  5692. //伙食费
  5693. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5694. if (_EnterExitCosts.ChoiceFour == 1)
  5695. {
  5696. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5697. table2Row = dac2.Count;
  5698. #region 填充word表格内容
  5699. for (int i = 0; i < dac2.Count; i++)
  5700. {
  5701. Grp_DayAndCost dac = dac2[i];
  5702. if (dac == null) continue;
  5703. builder.MoveToCell(1, i, 0, 0);
  5704. builder.Write("第" + dac.Days.ToString() + "天:");
  5705. builder.MoveToCell(1, i, 1, 0);
  5706. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5707. builder.MoveToCell(1, i, 2, 0);
  5708. builder.Write("费用标准:");
  5709. string curr = "";
  5710. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5711. if (currData != null)
  5712. {
  5713. curr = currData.Name;
  5714. }
  5715. builder.MoveToCell(1, i, 3, 0);
  5716. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5717. builder.MoveToCell(1, i, 4, 0);
  5718. builder.Write("费用小计:");
  5719. builder.MoveToCell(1, i, 5, 0);
  5720. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5721. }
  5722. #endregion
  5723. }
  5724. else dic.Add("SubHS", "0.00");
  5725. //删除多余行
  5726. while (table2.Rows.Count > table2Row)
  5727. {
  5728. table2.Rows.RemoveAt(table2Row);
  5729. }
  5730. //公杂费
  5731. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5732. if (_EnterExitCosts.ChoiceFive == 1)
  5733. {
  5734. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5735. table3Row = dac3.Count;
  5736. #region 填充word表格内容
  5737. for (int i = 0; i < dac3.Count; i++)
  5738. {
  5739. Grp_DayAndCost dac = dac3[i];
  5740. if (dac == null) continue;
  5741. builder.MoveToCell(2, i, 0, 0);
  5742. builder.Write("第" + dac.Days.ToString() + "天:");
  5743. builder.MoveToCell(2, i, 1, 0);
  5744. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5745. builder.MoveToCell(2, i, 2, 0);
  5746. builder.Write("费用标准:");
  5747. string curr = "";
  5748. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5749. if (currData != null)
  5750. {
  5751. curr = currData.Name;
  5752. }
  5753. builder.MoveToCell(2, i, 3, 0);
  5754. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5755. builder.MoveToCell(2, i, 4, 0);
  5756. builder.Write("费用小计:");
  5757. builder.MoveToCell(2, i, 5, 0);
  5758. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5759. }
  5760. //删除多余行
  5761. while (table3.Rows.Count > table3Row)
  5762. {
  5763. table3.Rows.RemoveAt(table3Row);
  5764. }
  5765. #endregion
  5766. }
  5767. else dic.Add("SubGZF", "0.00");
  5768. //删除多余行
  5769. while (table3.Rows.Count > table3Row)
  5770. {
  5771. table3.Rows.RemoveAt(table3Row);
  5772. }
  5773. //培训费
  5774. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5775. if (_EnterExitCosts.ChoiceSix == 1)
  5776. {
  5777. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5778. dic.Add("SubPX", pxStr);
  5779. table4Row = dac4.Count;
  5780. #region 填充word表格内容
  5781. for (int i = 0; i < dac4.Count; i++)
  5782. {
  5783. Grp_DayAndCost dac = dac4[i];
  5784. if (dac == null) continue;
  5785. builder.MoveToCell(3, i, 0, 0);
  5786. builder.Write("第" + dac.Days.ToString() + "天:");
  5787. builder.MoveToCell(3, i, 1, 0);
  5788. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5789. builder.MoveToCell(3, i, 2, 0);
  5790. builder.Write("费用标准:");
  5791. string curr = "";
  5792. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5793. if (currData != null)
  5794. {
  5795. curr = currData.Name;
  5796. }
  5797. builder.MoveToCell(3, i, 3, 0);
  5798. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5799. builder.MoveToCell(3, i, 4, 0);
  5800. builder.Write("费用小计:");
  5801. builder.MoveToCell(3, i, 5, 0);
  5802. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5803. }
  5804. #endregion
  5805. }
  5806. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  5807. //删除多余行
  5808. while (table4.Rows.Count > table4Row)
  5809. {
  5810. table4.Rows.RemoveAt(table4Row);
  5811. }
  5812. //其他费用
  5813. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5814. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5815. {
  5816. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5817. dic.Add("titleQi", qtStr);
  5818. table5Row = dac5.Count;
  5819. #region 填充word表格内容
  5820. for (int i = 0; i < dac5.Count; i++)
  5821. {
  5822. var dac = dac5[i];
  5823. if (dac == null) continue;
  5824. builder.MoveToCell(4, i, 0, 0);
  5825. builder.Write("第" + dac.Index.ToString() + "项:");
  5826. builder.MoveToCell(4, i, 1, 0);
  5827. builder.Write(dac.itemName);
  5828. builder.MoveToCell(4, i, 2, 0);
  5829. builder.Write("费用标准:");
  5830. builder.MoveToCell(4, i, 3, 0);
  5831. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5832. builder.MoveToCell(4, i, 4, 0);
  5833. builder.Write("费用小计:");
  5834. builder.MoveToCell(4, i, 5, 0);
  5835. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5836. builder.MoveToCell(4, i, 6, 0);
  5837. builder.Write("备注:");
  5838. builder.MoveToCell(4, i, 7, 0);
  5839. builder.Write(dac.Remark);
  5840. }
  5841. #endregion
  5842. }
  5843. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5844. //删除多余行
  5845. while (table5.Rows.Count > table5Row)
  5846. {
  5847. table5.Rows.RemoveAt(table5Row);
  5848. }
  5849. //加上其他费用
  5850. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5851. decimal subJJC = 0.00M,
  5852. subGWC = 0.00M,
  5853. subTDC = 0.00M;
  5854. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  5855. string totalLabel = string.Format("全部费用总计:");
  5856. //经济舱
  5857. if (_EnterExitCosts.SumJJC == 1)
  5858. {
  5859. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5860. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  5861. }
  5862. //公务舱
  5863. if (_EnterExitCosts.SumGWC == 1)
  5864. {
  5865. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5866. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  5867. }
  5868. //头等舱
  5869. if (_EnterExitCosts.SumTDC == 1)
  5870. {
  5871. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5872. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  5873. }
  5874. //TotalLabel
  5875. dic.Add("TotalLabel", totalLabel);
  5876. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5877. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5878. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5879. #region 填充word模板书签内容
  5880. foreach (var key in dic.Keys)
  5881. {
  5882. Bookmark bookmark = doc.Range.Bookmarks[key];
  5883. if (bookmark != null)
  5884. {
  5885. builder.MoveToBookmark(key);
  5886. builder.Write(dic[key]);
  5887. }
  5888. }
  5889. #endregion
  5890. #region 设置页眉
  5891. string userLabel = string.Empty;
  5892. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5893. if (currUserInfo != null)
  5894. {
  5895. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5896. if (userInfo != null)
  5897. {
  5898. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5899. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5900. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5901. }
  5902. }
  5903. //设置页脚
  5904. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5905. #endregion
  5906. //文件名
  5907. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5908. AsposeHelper.removewatermark_v2180();
  5909. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5910. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5911. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5912. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5913. }
  5914. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5915. {
  5916. //获取模板
  5917. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5918. //载入模板
  5919. Document doc = new Document(tempPath);
  5920. DocumentBuilder builder = new DocumentBuilder(doc);
  5921. Dictionary<string, string> dic = new Dictionary<string, string>();
  5922. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5923. {
  5924. List<string> list = new List<string>();
  5925. try
  5926. {
  5927. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5928. foreach (var item in spilitArr)
  5929. {
  5930. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5931. var depCode = spDotandEmpty[2].Substring(0, 3);
  5932. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5933. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5934. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5935. list.Add(depName);
  5936. list.Add(arrName);
  5937. }
  5938. list = list.Distinct().ToList();
  5939. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5940. }
  5941. catch (Exception)
  5942. {
  5943. dic.Add("ReturnCode", "行程录入不正确!");
  5944. }
  5945. }
  5946. else
  5947. {
  5948. dic.Add("ReturnCode", "未录入行程!");
  5949. }
  5950. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5951. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5952. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5953. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5954. {
  5955. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5956. dic.Add("Day", sp.Days.ToString());
  5957. }
  5958. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5959. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5960. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5961. //dic.Add("Names", Names);
  5962. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5963. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5964. decimal dac1totalPrice = 0.00M;
  5965. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5966. foreach (var dac in dac1)
  5967. {
  5968. if (dac.SubTotal == 0.00M)
  5969. {
  5970. continue;
  5971. }
  5972. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5973. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5974. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5975. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5976. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5977. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5978. builder.Write(currency);//币种
  5979. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5980. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5981. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5982. builder.Write("");//人数
  5983. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5984. builder.Write("");//天数
  5985. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5986. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5987. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5988. decimal rate = 0.00M;
  5989. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5990. builder.Write(rate.ToString("#0.0000"));//汇率
  5991. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5992. decimal rbmPrice = dac.SubTotal;
  5993. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5994. accommodationStartIndex++;
  5995. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5996. }
  5997. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5998. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5999. {
  6000. table1.Rows.RemoveAt(i - 1);
  6001. foodandotherStartIndex--;
  6002. }
  6003. if (dac2.Count == dac3.Count)//国家 币种 金额
  6004. {
  6005. for (int i = 0; i < dac2.Count; i++)
  6006. {
  6007. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6008. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6009. }
  6010. }
  6011. decimal dac2totalPrice = 0.00M;
  6012. foreach (var dac in dac2)
  6013. {
  6014. if (dac.SubTotal == 0)
  6015. {
  6016. continue;
  6017. }
  6018. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6019. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6020. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6021. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6022. builder.Write(currency);//币种
  6023. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6024. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6025. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6026. builder.Write("");//人数
  6027. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6028. builder.Write("");//天数
  6029. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6030. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6031. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6032. decimal rate = 0.00M;
  6033. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6034. builder.Write(rate.ToString("#0.0000"));//汇率
  6035. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6036. decimal rbmPrice = dac.SubTotal;
  6037. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6038. foodandotherStartIndex++;
  6039. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6040. }
  6041. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6042. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  6043. {
  6044. table1.Rows.RemoveAt(i - 1);
  6045. }
  6046. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6047. string otherFeeStr = "";
  6048. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  6049. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  6050. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  6051. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6052. foreach (var otherInfo in dac5)
  6053. {
  6054. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6055. }
  6056. #endregion
  6057. if (otherFeeStr.Length > 0)
  6058. {
  6059. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6060. otherFeeStr = $"({otherFeeStr})";
  6061. dic.Add("OtherFeeStr", otherFeeStr);
  6062. }
  6063. //总计
  6064. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  6065. //国际旅费
  6066. string outsideAir = string.Empty;
  6067. string allPriceAir = string.Empty;
  6068. if (_EnterExitCosts.SumJJC == 1)
  6069. {
  6070. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6071. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  6072. }
  6073. if (_EnterExitCosts.SumGWC == 1)
  6074. {
  6075. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  6076. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6077. }
  6078. if (_EnterExitCosts.SumTDC == 1)
  6079. {
  6080. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  6081. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  6082. }
  6083. dic.Add("InTravelPrice", $"({outsideAir})");
  6084. dic.Add("FinalSumPrice", $"({allPriceAir})");
  6085. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  6086. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  6087. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  6088. foreach (var key in dic.Keys)
  6089. {
  6090. builder.MoveToBookmark(key);
  6091. builder.Write(dic[key]);
  6092. }
  6093. //模板文件名
  6094. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6095. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6096. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6097. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6098. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6099. }
  6100. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  6101. {
  6102. //获取模板
  6103. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  6104. //载入模板
  6105. WorkbookDesigner designer = new WorkbookDesigner();
  6106. designer.Workbook = new Workbook(tempPath);
  6107. Dictionary<string, string> dic = new Dictionary<string, string>();
  6108. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6109. {
  6110. List<string> list = new List<string>();
  6111. try
  6112. {
  6113. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6114. foreach (var item in spilitArr)
  6115. {
  6116. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6117. var depCode = spDotandEmpty[2].Substring(0, 3);
  6118. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6119. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  6120. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  6121. list.Add(depName);
  6122. list.Add(arrName);
  6123. }
  6124. list = list.Distinct().ToList();
  6125. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6126. }
  6127. catch (Exception)
  6128. {
  6129. dic.Add("ReturnCode", "行程录入不正确!");
  6130. }
  6131. }
  6132. else
  6133. {
  6134. dic.Add("ReturnCode", "未录入行程!");
  6135. }
  6136. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6137. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6138. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6139. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6140. {
  6141. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6142. dic.Add("Day", sp.Days.ToString());
  6143. }
  6144. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6145. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6146. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6147. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  6148. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  6149. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  6150. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  6151. designer.SetDataSource("Name", Names);
  6152. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  6153. designer.SetDataSource("Day", dic["Day"] + "天");
  6154. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  6155. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  6156. int startIndex = 10;
  6157. const int startIndexcopy = 10;
  6158. if (dac2.Count == dac3.Count)//国家 币种 金额
  6159. {
  6160. for (int i = 0; i < dac2.Count; i++)
  6161. {
  6162. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6163. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6164. }
  6165. }
  6166. DataTable dtdac1 = new DataTable();
  6167. List<string> place = new List<string>();
  6168. dtdac1.Columns.AddRange(new DataColumn[] {
  6169. new DataColumn(){ ColumnName = "city"},
  6170. new DataColumn(){ ColumnName = "curr"},
  6171. new DataColumn(){ ColumnName = "criterion"},
  6172. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6173. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6174. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6175. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6176. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  6177. });
  6178. DataTable dtdac2 = new DataTable();
  6179. dtdac2.Columns.AddRange(new DataColumn[] {
  6180. new DataColumn(){ ColumnName = "city"},
  6181. new DataColumn(){ ColumnName = "curr"},
  6182. new DataColumn(){ ColumnName = "criterion"},
  6183. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6184. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6185. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6186. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6187. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  6188. });
  6189. dtdac1.TableName = "tb1";
  6190. dtdac2.TableName = "tb2";
  6191. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  6192. foreach (var item in dac1)
  6193. {
  6194. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6195. if (place.Contains(item.Place))
  6196. {
  6197. continue;
  6198. }
  6199. DataRow row = dtdac1.NewRow();
  6200. row["city"] = item.Place;
  6201. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6202. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6203. row["curr"] = currency;
  6204. row["rate"] = rate.ToString("#0.0000");
  6205. row["criterion"] = item.Cost.ToString("#0.00");
  6206. row["number"] = 1;
  6207. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6208. //row["costRMB"] = rbmPrice;
  6209. dtdac1.Rows.Add(row);
  6210. place.Add(item.Place);
  6211. }
  6212. place = new List<string>();
  6213. foreach (var item in dac2)
  6214. {
  6215. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6216. if (place.Contains(item.Place))
  6217. {
  6218. continue;
  6219. }
  6220. DataRow row = dtdac2.NewRow();
  6221. row["city"] = item.Place;
  6222. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6223. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6224. row["curr"] = currency;
  6225. row["rate"] = rate.ToString("#0.0000");
  6226. row["criterion"] = item.Cost.ToString("#0.00");
  6227. row["number"] = 1;
  6228. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6229. //row["cost"] = item.SubTotal;
  6230. //row["costRMB"] = rbmPrice;
  6231. dtdac2.Rows.Add(row);
  6232. place.Add(item.Place);
  6233. //dac2totalPrice += rbmPrice;
  6234. }
  6235. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  6236. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  6237. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6238. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  6239. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  6240. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  6241. string cell4Str1 = string.Empty;
  6242. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  6243. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  6244. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  6245. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  6246. string cellStr = $" 5.其他费用(";
  6247. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6248. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6249. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6250. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6251. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6252. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6253. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  6254. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  6255. foreach (var otherInfo in dac5)
  6256. {
  6257. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6258. }
  6259. #endregion
  6260. if (cellStr.Length > 8)
  6261. {
  6262. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  6263. }
  6264. cellStr += ")";
  6265. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  6266. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  6267. decimal pxFee = dac4.Sum(it => it.Cost);
  6268. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  6269. string celllastStr1 = "";
  6270. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  6271. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  6272. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  6273. celllastStr1 += $",国际旅费 元";
  6274. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  6275. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  6276. designer.SetDataSource("cell4Str", cell4Str);
  6277. designer.SetDataSource("cellStr", cellStr);
  6278. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  6279. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6280. designer.SetDataSource("celllastStr", celllastStr);
  6281. Workbook wb = designer.Workbook;
  6282. var sheet = wb.Worksheets[0];
  6283. //绑定datatable数据集
  6284. designer.SetDataSource(dtdac1);
  6285. designer.SetDataSource(dtdac2);
  6286. designer.Process();
  6287. var rowStart = dtdac1.Rows.Count;
  6288. while (rowStart > 0)
  6289. {
  6290. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  6291. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6292. startIndex++;
  6293. rowStart--;
  6294. }
  6295. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  6296. startIndex += 1; //总计行
  6297. rowStart = dtdac2.Rows.Count;
  6298. while (rowStart > 0)
  6299. {
  6300. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  6301. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6302. startIndex++;
  6303. rowStart--;
  6304. }
  6305. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  6306. wb.CalculateFormula(true);
  6307. //模板文件名
  6308. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  6309. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6310. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6311. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6312. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6313. }
  6314. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  6315. {
  6316. //获取模板
  6317. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  6318. //载入模板
  6319. Document doc = new Document(tempPath);
  6320. DocumentBuilder builder = new DocumentBuilder(doc);
  6321. Dictionary<string, string> dic = new Dictionary<string, string>();
  6322. dic.Add("GroupName", _DelegationInfo.TeamName);
  6323. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6324. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  6325. string missionLeaderJob = "";//负责人job
  6326. //int groupNumber = 0; //团人数
  6327. if (DeleClientList.Count > 0)
  6328. {
  6329. missionLeader = DeleClientList[0]?.Name ?? "";
  6330. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  6331. }
  6332. dic.Add("MissionLeader", missionLeader); //团负责人
  6333. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  6334. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  6335. #region MyRegion
  6336. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6337. //{
  6338. // List<string> list = new List<string>();
  6339. // try
  6340. // {
  6341. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6342. // foreach (var item in spilitArr)
  6343. // {
  6344. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6345. // var depCode = spDotandEmpty[2].Substring(0, 3);
  6346. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  6347. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6348. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6349. // list.Add(depName);
  6350. // list.Add(arrName);
  6351. // }
  6352. // list = list.Distinct().ToList();
  6353. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6354. // }
  6355. // catch (Exception)
  6356. // {
  6357. // dic.Add("ReturnCode", "行程录入不正确!");
  6358. // }
  6359. //}
  6360. //else
  6361. //{
  6362. // dic.Add("ReturnCode", "未录入行程!");
  6363. //}
  6364. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  6365. dic.Add("ReturnCode", string.Join("、", countrys));
  6366. #endregion
  6367. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6368. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6369. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6370. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6371. //{
  6372. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6373. // dic.Add("Day", sp.Days.ToString());
  6374. //}
  6375. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  6376. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  6377. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6378. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6379. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6380. //培训人员名单
  6381. int cultivateRowIndex = 7;
  6382. foreach (var item in DeleClientList)
  6383. {
  6384. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  6385. builder.Write(item.Name);
  6386. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  6387. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  6388. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  6389. string birthDay = "";
  6390. if (item.Birthday != null)
  6391. {
  6392. DateTime dt = Convert.ToDateTime(item.Birthday);
  6393. birthDay = $"{dt.Year}.{dt.Month}";
  6394. }
  6395. builder.Write(birthDay);
  6396. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  6397. builder.Write(item.Company);
  6398. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  6399. builder.Write(item.Job);
  6400. cultivateRowIndex++;
  6401. }
  6402. //删除多余行
  6403. //cultivateRowIndex -= 2;
  6404. int delRows = 10 + 7 - cultivateRowIndex;
  6405. if (delRows > 0)
  6406. {
  6407. for (int i = 0; i < delRows; i++)
  6408. {
  6409. table1.Rows.RemoveAt(cultivateRowIndex);
  6410. //cultivateRowIndex++;
  6411. }
  6412. }
  6413. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  6414. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  6415. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  6416. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  6417. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  6418. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  6419. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  6420. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  6421. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  6422. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  6423. //其他费用
  6424. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  6425. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  6426. //其他费用合计
  6427. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  6428. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  6429. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  6430. //公务舱合计
  6431. //国际旅费
  6432. //string outsideJJ = "";
  6433. //string allPriceJJ = "";
  6434. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  6435. {
  6436. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6437. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  6438. }
  6439. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  6440. {
  6441. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  6442. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  6443. }
  6444. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  6445. {
  6446. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  6447. dic.Add("AirFeeTotal", airFeeTotalStr);
  6448. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  6449. dic.Add("FeeTotal", feeTotalStr);
  6450. }
  6451. foreach (var key in dic.Keys)
  6452. {
  6453. builder.MoveToBookmark(key);
  6454. builder.Write(dic[key]);
  6455. }
  6456. //模板文件名
  6457. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  6458. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6459. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6460. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6461. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6462. }
  6463. }
  6464. else if (dto.ExportType == 2) //表格
  6465. {
  6466. //利用键值对存放数据
  6467. Dictionary<string, string> dic = new Dictionary<string, string>();
  6468. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6469. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6470. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6471. dic.Add("Day", sp.Days.ToString());
  6472. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6473. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  6474. {
  6475. //获取模板
  6476. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  6477. //载入模板
  6478. Document doc = new Document(tempPath);
  6479. DocumentBuilder builder = new DocumentBuilder(doc);
  6480. dic.Add("TeamName", _DelegationInfo.TeamName);
  6481. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6482. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  6483. string missionLeaderName = "",
  6484. missionLeaderJob = "";
  6485. if (DeleClientList.Count > 0)
  6486. {
  6487. missionLeaderName = DeleClientList[0].Name;
  6488. missionLeaderJob = DeleClientList[0].Job;
  6489. }
  6490. dic.Add("MissionLeaderName", missionLeaderName);
  6491. dic.Add("MissionLeaderJob", missionLeaderJob);
  6492. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  6493. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  6494. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6495. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6496. int rowCount = 10;//总人数行
  6497. int startRowIndex = 7; //起始行
  6498. for (int i = 0; i < DeleClientList.Count; i++)
  6499. {
  6500. builder.MoveToCell(0, startRowIndex, 0, 0);
  6501. builder.Write(DeleClientList[i].Name); //出国人员姓名
  6502. builder.MoveToCell(0, startRowIndex, 1, 0);
  6503. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6504. builder.Write(sex);//性别
  6505. builder.MoveToCell(0, startRowIndex, 2, 0);
  6506. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  6507. builder.MoveToCell(0, startRowIndex, 3, 0);
  6508. builder.Write(DeleClientList[i].Company);//工作单位
  6509. builder.MoveToCell(0, startRowIndex, 4, 0);
  6510. builder.Write(DeleClientList[i].Job);//职务及级别
  6511. builder.MoveToCell(0, startRowIndex, 5, 0);
  6512. builder.Write("");//人员属性
  6513. builder.MoveToCell(0, startRowIndex, 6, 0);
  6514. builder.Write("");//上次出国时间
  6515. startRowIndex++;
  6516. }
  6517. int nullRow = rowCount - DeleClientList.Count;//空行
  6518. for (int i = 0; i < nullRow; i++)
  6519. {
  6520. table1.Rows.Remove(table1.Rows[startRowIndex]);
  6521. }
  6522. foreach (var key in dic.Keys)
  6523. {
  6524. builder.MoveToBookmark(key);
  6525. builder.Write(dic[key]);
  6526. }
  6527. //模板文件名
  6528. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  6529. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6530. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6531. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  6532. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  6533. }
  6534. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  6535. {
  6536. //获取模板
  6537. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  6538. //载入模板
  6539. Document doc = new Document(tempPath);
  6540. DocumentBuilder builder = new DocumentBuilder(doc);
  6541. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6542. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6543. dic.Add("Names", Names);
  6544. int accommodationRows = 12;
  6545. //int foodandotherRows = 12;
  6546. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6547. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6548. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6549. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6550. int accommodationStartIndex = 6;
  6551. decimal dac1totalPrice = 0.00M;
  6552. foreach (var dac in dac1)
  6553. {
  6554. if (dac.SubTotal == 0)
  6555. {
  6556. continue;
  6557. }
  6558. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6559. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6560. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6561. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6562. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6563. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6564. builder.Write(currency);//币种
  6565. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6566. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6567. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6568. builder.Write("");//人数
  6569. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6570. builder.Write("");//天数
  6571. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6572. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6573. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6574. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6575. builder.Write(rate.ToString("#0.0000"));//汇率
  6576. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6577. decimal rbmPrice = rate * dac.SubTotal;
  6578. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6579. accommodationStartIndex++;
  6580. dac1totalPrice += rbmPrice;
  6581. }
  6582. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6583. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6584. builder.Write("小计");
  6585. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6586. builder.Write(dac1totalPrice.ToString("#0.00"));
  6587. accommodationStartIndex++;
  6588. int nullRow = accommodationRows - dac1.Count;
  6589. //删除空行
  6590. //if (nullRow > 0)
  6591. //{
  6592. // int rowIndex = accommodationStartIndex;
  6593. // for (int i = 0; i < nullRow; i++)
  6594. // {
  6595. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6596. // row.Remove();
  6597. // rowIndex++;
  6598. // }
  6599. //}
  6600. if (dac2.Count == dac3.Count)//国家 币种 金额
  6601. {
  6602. for (int i = 0; i < dac2.Count; i++)
  6603. {
  6604. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6605. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6606. }
  6607. }
  6608. int foodandotherStartIndex = 19;//
  6609. decimal dac2totalPrice = 0.00M;
  6610. foreach (var dac in dac2)
  6611. {
  6612. if (dac.SubTotal == 0)
  6613. {
  6614. continue;
  6615. }
  6616. //foodandotherStartIndex = 12;
  6617. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6618. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6619. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6620. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6621. builder.Write(currency);//币种
  6622. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6623. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6624. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6625. builder.Write("");//人数
  6626. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6627. builder.Write("");//天数
  6628. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6629. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6630. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6631. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6632. builder.Write(rate.ToString("#0.0000"));//汇率
  6633. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6634. decimal rbmPrice = rate * dac.SubTotal;
  6635. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6636. foodandotherStartIndex++;
  6637. dac2totalPrice += rbmPrice;
  6638. }
  6639. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6640. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6641. //删除空行
  6642. //if (dac2.Count < foodandotherRows)
  6643. //{
  6644. // while (table2.Rows.Count > dac2.Count)
  6645. // {
  6646. // table2.Rows.RemoveAt(dac2.Count);
  6647. // }
  6648. //}
  6649. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6650. string otherFeeStr = "";
  6651. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6652. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6653. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6654. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6655. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6656. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6657. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6658. foreach (var otherInfo in dac5)
  6659. {
  6660. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6661. }
  6662. #endregion
  6663. if (otherFeeStr.Length > 0)
  6664. {
  6665. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6666. otherFeeStr = $"({otherFeeStr})";
  6667. dic.Add("OtherFeeStr", otherFeeStr);
  6668. }
  6669. foreach (var key in dic.Keys)
  6670. {
  6671. builder.MoveToBookmark(key);
  6672. builder.Write(dic[key]);
  6673. }
  6674. //模板文件名
  6675. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6676. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6677. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6678. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6679. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6680. }
  6681. }
  6682. else if (dto.ExportType == 3)
  6683. {
  6684. if (dto.SubTypeId == 1) //团组成员名单
  6685. {
  6686. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6687. //获取模板
  6688. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6689. //载入模板
  6690. Document doc = new Document(tempPath);
  6691. DocumentBuilder builder = new DocumentBuilder(doc);
  6692. //获取word里所有表格
  6693. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6694. //获取所填表格的序数
  6695. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6696. var rowStart = tableOne.Rows[0]; //获取第1行
  6697. //循环赋值
  6698. for (int i = 0; i < DeleClientList.Count; i++)
  6699. {
  6700. builder.MoveToCell(0, i + 1, 0, 0);
  6701. builder.Write(DeleClientList[i].Name);
  6702. builder.MoveToCell(0, i + 1, 1, 0);
  6703. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6704. builder.Write(sex);
  6705. builder.MoveToCell(0, i + 1, 2, 0);
  6706. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6707. builder.MoveToCell(0, i + 1, 3, 0);
  6708. builder.Write(DeleClientList[i].Company);
  6709. builder.MoveToCell(0, i + 1, 4, 0);
  6710. builder.Write(DeleClientList[i].Job);
  6711. }
  6712. //删除多余行
  6713. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6714. {
  6715. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6716. }
  6717. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6718. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6719. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6720. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6721. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6722. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6723. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6724. }
  6725. }
  6726. return Ok(JsonView(400, "操作失败!", ""));
  6727. }
  6728. catch (Exception ex)
  6729. {
  6730. return Ok(JsonView(400, ex.Message, ""));
  6731. }
  6732. }
  6733. /// <summary>
  6734. /// 获取三公费用标准city
  6735. /// </summary>
  6736. /// <param name="placeData"></param>
  6737. /// <param name="nationalTravelFeeId"></param>
  6738. /// <returns></returns>
  6739. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6740. {
  6741. string _city = string.Empty;
  6742. if (placeData.Count < 1) return _city;
  6743. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6744. if (data == null) return _city;
  6745. string country = data.Country;
  6746. string city = data.City;
  6747. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6748. else _city = city;
  6749. return _city;
  6750. }
  6751. ///// <summary>
  6752. ///// 团组模块 - 出入境费用 - 明细表导出
  6753. ///// </summary>
  6754. ///// <returns></returns>
  6755. //[HttpPost]
  6756. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6757. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6758. //{
  6759. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6760. // if (data.Code != 0)
  6761. // {
  6762. // return Ok(JsonView(false, data.Msg));
  6763. // }
  6764. // return Ok(JsonView(true, data.Msg, data.Data));
  6765. //}
  6766. /// <summary>
  6767. /// 团组模块 - 出入境费用 - 一键清空
  6768. /// </summary>
  6769. /// <returns></returns>
  6770. [HttpPost]
  6771. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6773. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6774. {
  6775. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6776. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6777. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6778. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6779. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6780. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6781. .SetColumns(x => new Grp_DayOtherPrice
  6782. {
  6783. IsDel = 1,
  6784. DeleteUserId = dto.UserId,
  6785. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6786. })
  6787. .ExecuteCommandAsync();
  6788. if (_view.Code == 0)
  6789. {
  6790. return Ok(JsonView(true, "操作成功"));
  6791. }
  6792. return Ok(JsonView(false, "操作失败"));
  6793. }
  6794. /// <summary>
  6795. /// 团组模块 - 出入境费用 - 子项删除
  6796. /// </summary>
  6797. /// <returns></returns>
  6798. [HttpPost]
  6799. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6801. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6802. {
  6803. try
  6804. {
  6805. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6806. if (data.Code != 0)
  6807. {
  6808. return Ok(JsonView(false, data.Msg));
  6809. }
  6810. return Ok(JsonView(true, "操作成功!", data.Data));
  6811. }
  6812. catch (Exception ex)
  6813. {
  6814. return Ok(JsonView(false, ex.Message));
  6815. }
  6816. }
  6817. /// <summary>
  6818. /// 删除三公其他费用
  6819. /// </summary>
  6820. /// <param name="dto"></param>
  6821. /// <returns></returns>
  6822. [HttpPost]
  6823. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6824. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6825. {
  6826. var jw = JsonView(false, "删除失败!");
  6827. var data = new Grp_DayOtherPrice()
  6828. {
  6829. Id = dto.Id,
  6830. IsDel = 1,
  6831. DeleteUserId = dto.DeleteUserId,
  6832. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6833. };
  6834. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6835. if (del > 0)
  6836. {
  6837. jw.Code = 200;
  6838. jw.Msg = "删除成功!";
  6839. }
  6840. return Ok(jw);
  6841. }
  6842. /// <summary>
  6843. /// 团组模块 - 出入境国家费用标准 List
  6844. /// </summary>
  6845. /// <returns></returns>
  6846. [HttpPost]
  6847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6848. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  6849. {
  6850. int provinceId = dto.ProvinceId;
  6851. if (provinceId < 1) provinceId = 122; //默认四川省数据
  6852. var nftData = await _sqlSugar
  6853. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  6854. JoinType.Left, ntf.Currency == sd1.Id,
  6855. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  6856. JoinType.Left, ntf.ProvinceId == c.Id
  6857. ))
  6858. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  6859. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  6860. {
  6861. Id = ntf.Id,
  6862. ProvinceId = ntf.ProvinceId,
  6863. ProvinceName = c.Name_CN,
  6864. Continent = ntf.Continent,
  6865. Country = ntf.Country,
  6866. City = ntf.City,
  6867. Currency = ntf.Currency,
  6868. CurrencyCode = sd1.Name,
  6869. CurrencyName = sd1.Remark,
  6870. RoomCost = ntf.RoomCost,
  6871. FoodCost = ntf.FoodCost,
  6872. PublicCost = ntf.PublicCost,
  6873. LastUpdateUserId = ntf.LastUpdateUserId,
  6874. LastUpdateUserName = u.CnName,
  6875. LastUpdateTime = ntf.LastUpdateTime
  6876. })
  6877. .ToListAsync();
  6878. return Ok(JsonView(true, "查询成功!", nftData));
  6879. }
  6880. /// <summary>
  6881. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6882. /// </summary>
  6883. /// <returns></returns>
  6884. [HttpPost]
  6885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6886. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6887. {
  6888. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6889. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6890. List<string> countryData = new List<string>();
  6891. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  6892. countryData = countryData.Distinct().ToList();
  6893. List<dynamic> dataSource = new List<dynamic>();
  6894. foreach (var item in countryData)
  6895. {
  6896. var cityData1 = new List<string>();
  6897. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  6898. var countryData2 = new
  6899. {
  6900. CountryName = item,
  6901. CityData = cityData1
  6902. };
  6903. if (!dataSource.Contains(countryData2))
  6904. {
  6905. dataSource.Add(countryData2);
  6906. }
  6907. }
  6908. return Ok(JsonView(true, "查询成功!", dataSource));
  6909. }
  6910. /// <summary>
  6911. /// 团组模块 - 出入境国家费用标准 Page List
  6912. /// </summary>
  6913. /// <returns></returns>
  6914. [HttpPost]
  6915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6916. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6917. {
  6918. int portId = dto.PortType,
  6919. pageIndex = dto.PageIndex,
  6920. pageSize = dto.PageSize;
  6921. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6922. if (pageIndex == 0) pageIndex = 1;
  6923. if (pageSize == 0) pageSize = 10;
  6924. RefAsync<int> total = 0;
  6925. var nationalTravelFeeData = await _sqlSugar
  6926. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  6927. JoinType.Left, ntf.Currency == sd1.Id,
  6928. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  6929. JoinType.Left, ntf.ProvinceId == sd2.Id
  6930. ))
  6931. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  6932. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  6933. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  6934. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  6935. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  6936. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  6937. {
  6938. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  6939. Id = ntf.Id,
  6940. ProvinceId = ntf.ProvinceId,
  6941. ProvinceName = sd2.Name_CN,
  6942. Continent = ntf.Continent,
  6943. Country = ntf.Country,
  6944. City = ntf.City,
  6945. Currency = ntf.Currency,
  6946. CurrencyCode = sd1.Name,
  6947. CurrencyName = sd1.Remark,
  6948. RoomCost = ntf.RoomCost,
  6949. FoodCost = ntf.FoodCost,
  6950. PublicCost = ntf.PublicCost,
  6951. LastUpdateUserId = ntf.LastUpdateUserId,
  6952. LastUpdateUserName = u.CnName,
  6953. LastUpdateTime = ntf.LastUpdateTime,
  6954. Remark = ntf.Remark
  6955. })
  6956. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6957. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6958. }
  6959. /// <summary>
  6960. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6961. /// </summary>
  6962. /// <returns></returns>
  6963. [HttpPost]
  6964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6965. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6966. {
  6967. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6968. int portId = dto.PortType;
  6969. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6970. string whereSql = string.Empty;
  6971. if (!string.IsNullOrEmpty(dto.Country))
  6972. {
  6973. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6974. }
  6975. if (!string.IsNullOrEmpty(dto.City))
  6976. {
  6977. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6978. }
  6979. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6980. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  6981. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6982. From Grp_NationalTravelFee gntf
  6983. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6984. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6985. Where gntf.Isdel = 0 {0} ", whereSql);
  6986. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6987. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6988. }
  6989. /// <summary>
  6990. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6991. /// </summary>
  6992. /// <returns></returns>
  6993. [HttpPost]
  6994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6995. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6996. {
  6997. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  6998. }
  6999. /// <summary>
  7000. /// 团组模块 - 出入境国家费用标准 - Del
  7001. /// </summary>
  7002. /// <returns></returns>
  7003. [HttpPost]
  7004. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7005. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  7006. {
  7007. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  7008. {
  7009. Id = dto.Id,
  7010. DeleteUserId = dto.DeleteUserId,
  7011. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7012. IsDel = 1
  7013. };
  7014. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  7015. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  7016. .WhereColumns(it => new { it.Id })
  7017. .ExecuteCommandAsync();
  7018. if (delStatus <= 0)
  7019. {
  7020. return Ok(JsonView(false, "删除失败!"));
  7021. }
  7022. return Ok(JsonView(true, "操作成功!"));
  7023. }
  7024. /// <summary>
  7025. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  7026. /// 注:Get 请求Headers 加 Token
  7027. /// </summary>
  7028. /// <param name="groupId"></param>
  7029. /// <returns></returns>
  7030. [HttpGet("{groupId}")]
  7031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7032. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  7033. {
  7034. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7035. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  7036. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  7037. data.ForEach(x =>
  7038. {
  7039. x.CreateUserId = _currUserInfo.UserId;
  7040. });
  7041. if (data.Any())
  7042. {
  7043. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  7044. if (add > 0)
  7045. {
  7046. return Ok(JsonView(true, "操作成功!"));
  7047. }
  7048. }
  7049. return Ok(JsonView(false, "未操作!"));
  7050. }
  7051. #endregion
  7052. #region 团组经理模块 出入境费用-草稿
  7053. /// <summary>
  7054. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  7055. /// </summary>
  7056. /// <returns></returns>
  7057. [HttpGet]
  7058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7059. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  7060. {
  7061. var provData = await _groupRepository.ProvinceBasicSource();
  7062. return Ok(JsonView(true, "查询成功!", provData));
  7063. }
  7064. /// <summary>
  7065. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  7066. /// </summary>
  7067. /// <returns></returns>
  7068. [HttpGet("{provinceId}")]
  7069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7070. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  7071. {
  7072. //验证城市归属并给默认值
  7073. if (provinceId < 1) provinceId = 122;
  7074. /*
  7075. * 122 四川
  7076. * 108 贵州
  7077. * 103 重庆
  7078. * 132 云南
  7079. */
  7080. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  7081. return Ok(JsonView(true, "查询成功!", new
  7082. {
  7083. WordTypeData = wordTypeData,
  7084. ExcelTypeData = excelTypeData,
  7085. }));
  7086. }
  7087. /// <summary>
  7088. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  7089. /// </summary>
  7090. /// <returns></returns>
  7091. [HttpPost]
  7092. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7093. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  7094. {
  7095. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  7096. .Where(x => x.IsDel == 0)
  7097. .OrderByDescending(x => x.CreateTime)
  7098. .Select(x => new { x.Id, x.DraftName })
  7099. .ToListAsync();
  7100. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7101. //SetDataInfoView
  7102. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  7103. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  7104. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  7105. int provinceId = dto.ProvinceId;
  7106. if (provinceId < 1) provinceId = 122;
  7107. /*
  7108. * 122 四川
  7109. * 108 贵州
  7110. * 103 重庆
  7111. * 132 云南
  7112. */
  7113. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  7114. //默认币种显示
  7115. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  7116. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  7117. return Ok(JsonView(true, "查询成功!", new
  7118. {
  7119. DraftNameDatas = draftNameDatas,
  7120. CurrencyData = _CurrencyData,
  7121. WordTypeData = wordTypeData,
  7122. ExcelTypeData = excelTypeData,
  7123. CurrencyInit = _currencyInfos,
  7124. ViewPermissionData = viewPermissionData
  7125. }));
  7126. }
  7127. /// <summary>
  7128. /// 团组模块 - 出入境费用-草稿
  7129. /// 实时汇率 tips
  7130. /// 机票费用 tips
  7131. /// </summary>
  7132. /// <returns></returns>
  7133. [HttpPost]
  7134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7135. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  7136. {
  7137. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  7138. return Ok(JsonView(true, "查询成功!", new
  7139. {
  7140. //GroupNameData = groupNameData.Data,
  7141. //visaData = visaData.Data,
  7142. //airData = airData.Data,
  7143. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  7144. }));
  7145. }
  7146. /// <summary>
  7147. /// 团组模块 - 出入境费用-草稿
  7148. /// 签证费用 tips
  7149. /// </summary>
  7150. /// <returns></returns>
  7151. [HttpPost]
  7152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7153. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  7154. {
  7155. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  7156. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  7157. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  7158. .Select(x => x.NationalTravelFeeId)
  7159. .Distinct()
  7160. .ToListAsync();
  7161. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7162. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7163. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  7164. .Select(x => x.Country)
  7165. .Distinct()
  7166. .ToArrayAsync();
  7167. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7168. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  7169. return Ok(JsonView(true, "查询成功!", new
  7170. {
  7171. totalAmt = totalAmt,
  7172. remark = remark
  7173. }));
  7174. }
  7175. /// <summary>
  7176. /// 团组模块 - 出入境费用-草稿 - Info
  7177. /// </summary>
  7178. /// <returns></returns>
  7179. [HttpPost]
  7180. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  7181. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7182. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  7183. {
  7184. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  7185. }
  7186. /// <summary>
  7187. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  7188. /// </summary>
  7189. /// <returns></returns>
  7190. [HttpPost]
  7191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7192. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  7193. {
  7194. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7195. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  7196. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  7197. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  7198. foreach (var userId in dto.UserIds)
  7199. {
  7200. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  7201. }
  7202. if (permissions.Any())
  7203. {
  7204. _sqlSugar.BeginTran();
  7205. try
  7206. {
  7207. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  7208. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  7209. if (result < 1)
  7210. {
  7211. _sqlSugar.RollbackTran();
  7212. return Ok(JsonView(false));
  7213. }
  7214. }
  7215. catch (Exception ex)
  7216. {
  7217. _sqlSugar.RollbackTran();
  7218. return Ok(JsonView(false, ex.Message));
  7219. }
  7220. _sqlSugar.CommitTran();
  7221. return Ok(JsonView(true));
  7222. }
  7223. return Ok(JsonView(false));
  7224. }
  7225. /// <summary>
  7226. /// 团组模块 - 出入境费用-草稿 - Add And Update
  7227. /// </summary>
  7228. /// <returns></returns>
  7229. [HttpPost]
  7230. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  7231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7232. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  7233. {
  7234. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  7235. if (data.Code != 0)
  7236. {
  7237. return Ok(JsonView(false, data.Msg));
  7238. }
  7239. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  7240. //汇率信息记录
  7241. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  7242. return Ok(JsonView(true, data.Msg, data.Data));
  7243. }
  7244. /// <summary>
  7245. /// 团组模块 - 出入境费用-草稿 - File downlaod
  7246. /// </summary>
  7247. /// <param name="dto"></param>
  7248. /// <returns></returns>
  7249. [HttpPost]
  7250. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  7251. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7252. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  7253. {
  7254. try
  7255. {
  7256. var id = dto.Id;
  7257. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  7258. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  7259. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  7260. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  7261. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  7262. 3 团组成员名单 1 团组成员名单", ""));
  7263. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  7264. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  7265. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  7266. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  7267. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  7268. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  7269. //数据源
  7270. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  7271. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  7272. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  7273. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  7274. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  7275. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  7276. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  7277. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  7278. .Select((x, a, b) => new
  7279. {
  7280. x.Index,
  7281. itemName = a.Name,
  7282. CurrencyStr = b.Name,
  7283. x.Cost,
  7284. x.SubTotal,
  7285. x.Remark
  7286. })
  7287. .OrderBy((x) => x.Index)
  7288. .ToList(); //其他款项费用
  7289. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7290. var peiceItemCurrencys = new List<string>();
  7291. if (_DayAndCosts.Any())
  7292. {
  7293. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  7294. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  7295. }
  7296. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  7297. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  7298. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  7299. {
  7300. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  7301. }
  7302. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  7303. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  7304. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  7305. if (dto.ExportType == 1) //明细表
  7306. {
  7307. if (dto.SubTypeId == 1005) //1005(默认明细表)
  7308. {
  7309. //获取模板
  7310. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  7311. //载入模板
  7312. Document doc = new Document(tempPath);
  7313. DocumentBuilder builder = new DocumentBuilder(doc);
  7314. //利用键值对存放数据
  7315. Dictionary<string, string> dic = new Dictionary<string, string>();
  7316. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  7317. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  7318. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  7319. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  7320. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  7321. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  7322. //境内费用(其他费用)
  7323. if (_EnterExitCosts.ChoiceOne == 1)
  7324. {
  7325. string row1_1 = "";
  7326. if (_EnterExitCosts.Visa > 0)
  7327. {
  7328. //insidePayTotal += _EnterExitCosts.Visa;
  7329. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  7330. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  7331. //{
  7332. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  7333. //}
  7334. }
  7335. string row1_2 = "";
  7336. if (_EnterExitCosts.YiMiao > 0)
  7337. {
  7338. //insidePayTotal += _EnterExitCosts.YiMiao;
  7339. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  7340. }
  7341. if (_EnterExitCosts.HeSuan > 0)
  7342. {
  7343. //insidePayTotal += _EnterExitCosts.HeSuan;
  7344. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  7345. }
  7346. if (_EnterExitCosts.Service > 0)
  7347. {
  7348. //insidePayTotal += _EnterExitCosts.Service;
  7349. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  7350. }
  7351. string row1_3 = "";
  7352. if (_EnterExitCosts.Safe > 0)
  7353. {
  7354. //insidePayTotal += _EnterExitCosts.Safe;
  7355. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  7356. }
  7357. if (_EnterExitCosts.Ticket > 0)
  7358. {
  7359. //insidePayTotal += _EnterExitCosts.Ticket;
  7360. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  7361. }
  7362. string row1 = "";
  7363. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  7364. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  7365. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  7366. row1 += $"备注:{_EnterExitCosts.Remark}";
  7367. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  7368. dic.Add("Row1Str", row1);
  7369. }
  7370. string airTotalStr = string.Empty,
  7371. airPriceStr = string.Empty;
  7372. //经济舱
  7373. if (_EnterExitCosts.SumJJC == 1)
  7374. {
  7375. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  7376. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  7377. }
  7378. //公务舱
  7379. if (_EnterExitCosts.SumGWC == 1)
  7380. {
  7381. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  7382. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  7383. }
  7384. //头等舱
  7385. if (_EnterExitCosts.SumTDC == 1)
  7386. {
  7387. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  7388. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  7389. }
  7390. //汇率描述
  7391. string rateStr = "";
  7392. if (peiceItemCurrencyInfos.Any())
  7393. {
  7394. rateStr = "\r\n汇率描述:";
  7395. foreach (var item in peiceItemCurrencyInfos)
  7396. {
  7397. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  7398. }
  7399. }
  7400. string twoItemRemark = "备注:";
  7401. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7402. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7403. dic.Add("AirTotalStr", airTotalStr);
  7404. dic.Add("AirPriceStr", airPriceStr);
  7405. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7406. dic.Add("TwoItemRemark", twoItemRemark);
  7407. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7408. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7409. int table1Row = 0,
  7410. table2Row = 0,
  7411. table3Row = 0,
  7412. table4Row = 0,
  7413. table5Row = 0;
  7414. //住宿费
  7415. if (_EnterExitCosts.ChoiceThree == 1)
  7416. {
  7417. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  7418. table1Row = dac1.Count;
  7419. #region 填充word表格内容
  7420. for (int i = 0; i < dac1.Count; i++)
  7421. {
  7422. var dac = dac1[i];
  7423. if (dac == null) continue;
  7424. builder.MoveToCell(0, i, 0, 0);
  7425. builder.Write("第" + dac.Days.ToString() + "晚:");
  7426. builder.MoveToCell(0, i, 1, 0);
  7427. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  7428. //builder.Write(dac.Place == null ? "" : dac.Place);
  7429. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7430. builder.MoveToCell(0, i, 2, 0);
  7431. builder.Write("费用标准:");
  7432. string curr = "";
  7433. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7434. if (currData != null)
  7435. {
  7436. curr = currData.Name;
  7437. }
  7438. builder.MoveToCell(0, i, 3, 0);
  7439. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7440. builder.MoveToCell(0, i, 4, 0);
  7441. builder.Write("费用小计:");
  7442. builder.MoveToCell(0, i, 5, 0);
  7443. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7444. }
  7445. #endregion
  7446. }
  7447. else dic.Add("SubZS", "0.00");
  7448. //删除多余行
  7449. while (table1.Rows.Count > table1Row)
  7450. {
  7451. table1.Rows.RemoveAt(table1Row);
  7452. }
  7453. //伙食费
  7454. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7455. if (_EnterExitCosts.ChoiceFour == 1)
  7456. {
  7457. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7458. table2Row = dac2.Count;
  7459. #region 填充word表格内容
  7460. for (int i = 0; i < dac2.Count; i++)
  7461. {
  7462. var dac = dac2[i];
  7463. if (dac == null) continue;
  7464. builder.MoveToCell(1, i, 0, 0);
  7465. builder.Write("第" + dac.Days.ToString() + "天:");
  7466. builder.MoveToCell(1, i, 1, 0);
  7467. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7468. builder.MoveToCell(1, i, 2, 0);
  7469. builder.Write("费用标准:");
  7470. string curr = "";
  7471. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7472. if (currData != null)
  7473. {
  7474. curr = currData.Name;
  7475. }
  7476. builder.MoveToCell(1, i, 3, 0);
  7477. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7478. builder.MoveToCell(1, i, 4, 0);
  7479. builder.Write("费用小计:");
  7480. builder.MoveToCell(1, i, 5, 0);
  7481. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7482. }
  7483. #endregion
  7484. }
  7485. else dic.Add("SubHS", "0.00");
  7486. //删除多余行
  7487. while (table2.Rows.Count > table2Row)
  7488. {
  7489. table2.Rows.RemoveAt(table2Row);
  7490. }
  7491. //公杂费
  7492. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7493. if (_EnterExitCosts.ChoiceFive == 1)
  7494. {
  7495. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7496. table3Row = dac3.Count;
  7497. #region 填充word表格内容
  7498. for (int i = 0; i < dac3.Count; i++)
  7499. {
  7500. var dac = dac3[i];
  7501. if (dac == null) continue;
  7502. builder.MoveToCell(2, i, 0, 0);
  7503. builder.Write("第" + dac.Days.ToString() + "天:");
  7504. builder.MoveToCell(2, i, 1, 0);
  7505. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7506. builder.MoveToCell(2, i, 2, 0);
  7507. builder.Write("费用标准:");
  7508. string curr = "";
  7509. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7510. if (currData != null)
  7511. {
  7512. curr = currData.Name;
  7513. }
  7514. builder.MoveToCell(2, i, 3, 0);
  7515. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7516. builder.MoveToCell(2, i, 4, 0);
  7517. builder.Write("费用小计:");
  7518. builder.MoveToCell(2, i, 5, 0);
  7519. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7520. }
  7521. //删除多余行
  7522. while (table3.Rows.Count > table3Row)
  7523. {
  7524. table3.Rows.RemoveAt(table3Row);
  7525. }
  7526. #endregion
  7527. }
  7528. else dic.Add("SubGZF", "0.00");
  7529. //删除多余行
  7530. while (table3.Rows.Count > table3Row)
  7531. {
  7532. table3.Rows.RemoveAt(table3Row);
  7533. }
  7534. //培训费
  7535. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7536. if (_EnterExitCosts.ChoiceSix == 1)
  7537. {
  7538. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  7539. dic.Add("SubPX", pxStr);
  7540. table4Row = dac4.Count;
  7541. #region 填充word表格内容
  7542. for (int i = 0; i < dac4.Count; i++)
  7543. {
  7544. var dac = dac4[i];
  7545. if (dac == null) continue;
  7546. builder.MoveToCell(3, i, 0, 0);
  7547. builder.Write("第" + dac.Days.ToString() + "天:");
  7548. builder.MoveToCell(3, i, 1, 0);
  7549. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7550. builder.MoveToCell(3, i, 2, 0);
  7551. builder.Write("费用标准:");
  7552. string curr = "";
  7553. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7554. if (currData != null)
  7555. {
  7556. curr = currData.Name;
  7557. }
  7558. builder.MoveToCell(3, i, 3, 0);
  7559. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7560. builder.MoveToCell(3, i, 4, 0);
  7561. builder.Write("费用小计:");
  7562. builder.MoveToCell(3, i, 5, 0);
  7563. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7564. }
  7565. #endregion
  7566. }
  7567. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  7568. //删除多余行
  7569. while (table4.Rows.Count > table4Row)
  7570. {
  7571. table4.Rows.RemoveAt(table4Row);
  7572. }
  7573. //其他费用
  7574. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7575. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7576. {
  7577. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  7578. dic.Add("titleQi", qtStr);
  7579. table5Row = dac5.Count;
  7580. #region 填充word表格内容
  7581. for (int i = 0; i < dac5.Count; i++)
  7582. {
  7583. var dac = dac5[i];
  7584. if (dac == null) continue;
  7585. builder.MoveToCell(4, i, 0, 0);
  7586. builder.Write("第" + dac.Index.ToString() + "项:");
  7587. builder.MoveToCell(4, i, 1, 0);
  7588. builder.Write(dac.itemName);
  7589. builder.MoveToCell(4, i, 2, 0);
  7590. builder.Write("费用标准:");
  7591. builder.MoveToCell(4, i, 3, 0);
  7592. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7593. builder.MoveToCell(4, i, 4, 0);
  7594. builder.Write("费用小计:");
  7595. builder.MoveToCell(4, i, 5, 0);
  7596. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7597. builder.MoveToCell(4, i, 6, 0);
  7598. builder.Write("备注:");
  7599. builder.MoveToCell(4, i, 7, 0);
  7600. builder.Write(dac.Remark);
  7601. }
  7602. #endregion
  7603. }
  7604. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7605. //删除多余行
  7606. while (table5.Rows.Count > table5Row)
  7607. {
  7608. table5.Rows.RemoveAt(table5Row);
  7609. }
  7610. //加上其他费用
  7611. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7612. decimal subJJC = 0.00M,
  7613. subGWC = 0.00M,
  7614. subTDC = 0.00M;
  7615. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7616. string totalLabel = string.Format("全部费用总计:");
  7617. //经济舱
  7618. if (_EnterExitCosts.SumJJC == 1)
  7619. {
  7620. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7621. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  7622. }
  7623. //公务舱
  7624. if (_EnterExitCosts.SumGWC == 1)
  7625. {
  7626. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7627. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  7628. }
  7629. //头等舱
  7630. if (_EnterExitCosts.SumTDC == 1)
  7631. {
  7632. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7633. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  7634. }
  7635. //TotalLabel
  7636. dic.Add("TotalLabel", totalLabel);
  7637. #region 填充word模板书签内容
  7638. foreach (var key in dic.Keys)
  7639. {
  7640. Bookmark bookmark = doc.Range.Bookmarks[key];
  7641. if (bookmark != null)
  7642. {
  7643. builder.MoveToBookmark(key);
  7644. builder.Write(dic[key]);
  7645. }
  7646. }
  7647. #endregion
  7648. //文件名
  7649. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7650. strFileName = CommonFun.ValidFileName(strFileName);
  7651. AsposeHelper.removewatermark_v2180();
  7652. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7653. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7654. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7655. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7656. }
  7657. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7658. {
  7659. //获取模板
  7660. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7661. //载入模板
  7662. Document doc = new Document(tempPath);
  7663. DocumentBuilder builder = new DocumentBuilder(doc);
  7664. Dictionary<string, string> dic = new Dictionary<string, string>();
  7665. string returnCodeLabel = string.Empty;
  7666. if (nationalTravelFeeData.Any())
  7667. {
  7668. List<string> list = new List<string>();
  7669. foreach (var item in nationalTravelFeeData)
  7670. {
  7671. list.Add($"{item.Country}({item.City})");
  7672. }
  7673. list = list.Distinct().ToList();
  7674. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7675. }
  7676. var countryLabel = string.Empty;
  7677. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7678. if (countryData.Any())
  7679. {
  7680. countryLabel = string.Join("、", countryData);
  7681. }
  7682. dic.Add("ReturnCodeAir", returnCodeLabel);
  7683. dic.Add("VisitStartDate", "-");
  7684. dic.Add("VisitEndDate", "-");
  7685. dic.Add("Day", "-");
  7686. dic.Add("VisitCountry", countryLabel);
  7687. dic.Add("ClientUnit", "-");
  7688. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7689. //dic.Add("Names", Names);
  7690. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7691. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7692. decimal dac1totalPrice = 0.00M;
  7693. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7694. foreach (var dac in dac1)
  7695. {
  7696. if (dac.SubTotal == 0.00M)
  7697. {
  7698. continue;
  7699. }
  7700. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7701. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7702. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7703. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7704. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7705. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7706. builder.Write(currency);//币种
  7707. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7708. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7709. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7710. builder.Write("");//人数
  7711. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7712. builder.Write("");//天数
  7713. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7714. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7715. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7716. decimal rate = 0.00M;
  7717. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7718. builder.Write(rate.ToString("#0.0000"));//汇率
  7719. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7720. decimal rbmPrice = dac.SubTotal;
  7721. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7722. accommodationStartIndex++;
  7723. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7724. }
  7725. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7726. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7727. {
  7728. table1.Rows.RemoveAt(i - 1);
  7729. foodandotherStartIndex--;
  7730. }
  7731. if (dac2.Count == dac3.Count)//国家 币种 金额
  7732. {
  7733. for (int i = 0; i < dac2.Count; i++)
  7734. {
  7735. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7736. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7737. }
  7738. }
  7739. decimal dac2totalPrice = 0.00M;
  7740. foreach (var dac in dac2)
  7741. {
  7742. if (dac.SubTotal == 0)
  7743. {
  7744. continue;
  7745. }
  7746. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7747. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7748. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7749. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7750. builder.Write(currency);//币种
  7751. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7752. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7753. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7754. builder.Write("");//人数
  7755. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7756. builder.Write("");//天数
  7757. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7758. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7759. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7760. decimal rate = 0.00M;
  7761. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7762. builder.Write(rate.ToString("#0.0000"));//汇率
  7763. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7764. decimal rbmPrice = dac.SubTotal;
  7765. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7766. foodandotherStartIndex++;
  7767. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7768. }
  7769. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7770. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7771. {
  7772. table1.Rows.RemoveAt(i - 1);
  7773. }
  7774. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7775. string otherFeeStr = "";
  7776. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7777. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7778. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7779. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7780. foreach (var otherInfo in dac5)
  7781. {
  7782. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7783. }
  7784. #endregion
  7785. if (otherFeeStr.Length > 0)
  7786. {
  7787. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7788. otherFeeStr = $"({otherFeeStr})";
  7789. dic.Add("OtherFeeStr", otherFeeStr);
  7790. }
  7791. //总计
  7792. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7793. //国际旅费
  7794. string outsideAir = string.Empty;
  7795. string allPriceAir = string.Empty;
  7796. if (_EnterExitCosts.SumJJC == 1)
  7797. {
  7798. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7799. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7800. }
  7801. if (_EnterExitCosts.SumGWC == 1)
  7802. {
  7803. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7804. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7805. }
  7806. if (_EnterExitCosts.SumTDC == 1)
  7807. {
  7808. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7809. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7810. }
  7811. dic.Add("InTravelPrice", $"({outsideAir})");
  7812. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7813. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7814. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7815. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7816. foreach (var key in dic.Keys)
  7817. {
  7818. builder.MoveToBookmark(key);
  7819. builder.Write(dic[key]);
  7820. }
  7821. //模板文件名
  7822. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7823. strFileName = CommonFun.ValidFileName(strFileName);
  7824. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7825. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7826. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7827. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7828. }
  7829. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7830. {
  7831. //获取模板
  7832. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7833. //载入模板
  7834. WorkbookDesigner designer = new WorkbookDesigner();
  7835. designer.Workbook = new Workbook(tempPath);
  7836. Dictionary<string, string> dic = new Dictionary<string, string>();
  7837. string returnCodeLabel = string.Empty;
  7838. if (nationalTravelFeeData.Any())
  7839. {
  7840. List<string> list = new List<string>();
  7841. foreach (var item in nationalTravelFeeData)
  7842. {
  7843. list.Add($"{item.Country}({item.City})");
  7844. }
  7845. list = list.Distinct().ToList();
  7846. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7847. }
  7848. var countryLabel = string.Empty;
  7849. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7850. if (countryData.Any())
  7851. {
  7852. countryLabel = string.Join("、", countryData);
  7853. }
  7854. dic.Add("ReturnCodeAir", returnCodeLabel);
  7855. dic.Add("VisitStartDate", "-");
  7856. dic.Add("VisitEndDate", "-");
  7857. dic.Add("Day", "0");
  7858. dic.Add("VisitCountry", countryLabel);
  7859. dic.Add("ClientUnit", "-");
  7860. designer.SetDataSource("ClientUnit", "-");
  7861. designer.SetDataSource("VisitCountry", countryLabel);
  7862. designer.SetDataSource("Group", "-");
  7863. designer.SetDataSource("ClientUnitTitle", "-");
  7864. designer.SetDataSource("Name", "-");
  7865. designer.SetDataSource("VisitStartDate", "-");
  7866. designer.SetDataSource("Day", "0");
  7867. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7868. designer.SetDataSource("ReturnCodeAir", "-");
  7869. int startIndex = 10;
  7870. const int startIndexcopy = 10;
  7871. if (dac2.Count == dac3.Count)//国家 币种 金额
  7872. {
  7873. for (int i = 0; i < dac2.Count; i++)
  7874. {
  7875. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7876. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7877. }
  7878. }
  7879. DataTable dtdac1 = new DataTable();
  7880. List<string> place = new List<string>();
  7881. dtdac1.Columns.AddRange(new DataColumn[] {
  7882. new DataColumn(){ ColumnName = "city"},
  7883. new DataColumn(){ ColumnName = "curr"},
  7884. new DataColumn(){ ColumnName = "criterion"},
  7885. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7886. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7887. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7888. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7889. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7890. });
  7891. DataTable dtdac2 = new DataTable();
  7892. dtdac2.Columns.AddRange(new DataColumn[] {
  7893. new DataColumn(){ ColumnName = "city"},
  7894. new DataColumn(){ ColumnName = "curr"},
  7895. new DataColumn(){ ColumnName = "criterion"},
  7896. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7897. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7898. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7899. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7900. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7901. });
  7902. dtdac1.TableName = "tb1";
  7903. dtdac2.TableName = "tb2";
  7904. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7905. foreach (var item in dac1)
  7906. {
  7907. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7908. if (place.Contains(item.Place))
  7909. {
  7910. continue;
  7911. }
  7912. DataRow row = dtdac1.NewRow();
  7913. row["city"] = item.Place;
  7914. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7915. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7916. row["curr"] = currency;
  7917. row["rate"] = rate.ToString("#0.0000");
  7918. row["criterion"] = item.Cost.ToString("#0.00");
  7919. row["number"] = 1;
  7920. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7921. //row["costRMB"] = rbmPrice;
  7922. dtdac1.Rows.Add(row);
  7923. place.Add(item.Place);
  7924. }
  7925. place = new List<string>();
  7926. foreach (var item in dac2)
  7927. {
  7928. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7929. if (place.Contains(item.Place))
  7930. {
  7931. continue;
  7932. }
  7933. DataRow row = dtdac2.NewRow();
  7934. row["city"] = item.Place;
  7935. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7936. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7937. row["curr"] = currency;
  7938. row["rate"] = rate.ToString("#0.0000");
  7939. row["criterion"] = item.Cost.ToString("#0.00");
  7940. row["number"] = 1;
  7941. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7942. //row["cost"] = item.SubTotal;
  7943. //row["costRMB"] = rbmPrice;
  7944. dtdac2.Rows.Add(row);
  7945. place.Add(item.Place);
  7946. //dac2totalPrice += rbmPrice;
  7947. }
  7948. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7949. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7950. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7951. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7952. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7953. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7954. string cell4Str1 = string.Empty;
  7955. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7956. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7957. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7958. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7959. string cellStr = $" 5.其他费用(";
  7960. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7961. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7962. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7963. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7964. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7965. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7966. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7967. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7968. foreach (var otherInfo in dac5)
  7969. {
  7970. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7971. }
  7972. #endregion
  7973. if (cellStr.Length > 8)
  7974. {
  7975. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7976. }
  7977. cellStr += ")";
  7978. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7979. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7980. decimal pxFee = dac4.Sum(it => it.Cost);
  7981. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7982. string celllastStr1 = "";
  7983. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7984. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7985. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7986. celllastStr1 += $",国际旅费 元";
  7987. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7988. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7989. designer.SetDataSource("cell4Str", cell4Str);
  7990. designer.SetDataSource("cellStr", cellStr);
  7991. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7992. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7993. designer.SetDataSource("celllastStr", celllastStr);
  7994. Workbook wb = designer.Workbook;
  7995. var sheet = wb.Worksheets[0];
  7996. //绑定datatable数据集
  7997. designer.SetDataSource(dtdac1);
  7998. designer.SetDataSource(dtdac2);
  7999. designer.Process();
  8000. var rowStart = dtdac1.Rows.Count;
  8001. while (rowStart > 0)
  8002. {
  8003. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8004. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8005. startIndex++;
  8006. rowStart--;
  8007. }
  8008. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8009. startIndex += 1; //总计行
  8010. rowStart = dtdac2.Rows.Count;
  8011. while (rowStart > 0)
  8012. {
  8013. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8014. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8015. startIndex++;
  8016. rowStart--;
  8017. }
  8018. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8019. wb.CalculateFormula(true);
  8020. //模板文件名
  8021. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8022. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8023. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8024. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8025. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8026. }
  8027. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8028. {
  8029. //获取模板
  8030. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8031. //载入模板
  8032. Document doc = new Document(tempPath);
  8033. DocumentBuilder builder = new DocumentBuilder(doc);
  8034. Dictionary<string, string> dic = new Dictionary<string, string>();
  8035. dic.Add("GroupName", "-");
  8036. dic.Add("ClientUnit", "-");
  8037. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8038. //string missionLeaderJob = "";//负责人job
  8039. //int groupNumber = 0; //团人数
  8040. dic.Add("MissionLeader", "-"); //团负责人
  8041. dic.Add("MissionLeaderJob", "-"); //团负责人job
  8042. dic.Add("GroupNumber", "0"); //团人数
  8043. dic.Add("Day", "0");
  8044. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8045. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8046. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8047. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8048. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8049. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8050. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8051. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8052. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8053. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8054. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8055. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8056. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8057. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  8058. //其他费用
  8059. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8060. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8061. //其他费用合计
  8062. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8063. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  8064. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  8065. //公务舱合计
  8066. //国际旅费
  8067. //string outsideJJ = "";
  8068. //string allPriceJJ = "";
  8069. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8070. {
  8071. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8072. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8073. }
  8074. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8075. {
  8076. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  8077. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8078. }
  8079. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  8080. {
  8081. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  8082. dic.Add("AirFeeTotal", airFeeTotalStr);
  8083. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  8084. dic.Add("FeeTotal", feeTotalStr);
  8085. }
  8086. foreach (var key in dic.Keys)
  8087. {
  8088. builder.MoveToBookmark(key);
  8089. builder.Write(dic[key]);
  8090. }
  8091. //模板文件名
  8092. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  8093. strFileName = CommonFun.ValidFileName(strFileName);
  8094. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8095. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8096. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8097. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8098. }
  8099. }
  8100. else if (dto.ExportType == 2) //表格
  8101. {
  8102. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8103. }
  8104. else if (dto.ExportType == 3)
  8105. {
  8106. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8107. }
  8108. return Ok(JsonView(400, "只可导出明细表!", ""));
  8109. }
  8110. catch (Exception ex)
  8111. {
  8112. return Ok(JsonView(400, ex.Message, ""));
  8113. }
  8114. }
  8115. /// <summary>
  8116. /// 获取三公费用标准city
  8117. /// </summary>
  8118. /// <param name="placeData"></param>
  8119. /// <param name="nationalTravelFeeId"></param>
  8120. /// <returns></returns>
  8121. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8122. {
  8123. string _city = string.Empty;
  8124. if (!placeData.Any()) return _city;
  8125. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8126. if (data == null) return _city;
  8127. string country = data.Country;
  8128. string city = data.City;
  8129. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8130. else _city = city;
  8131. return _city;
  8132. }
  8133. /// <summary>
  8134. /// 团组模块 - 出入境费用-草稿 - 一键清空
  8135. /// </summary>
  8136. /// <returns></returns>
  8137. [HttpPost]
  8138. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8140. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  8141. {
  8142. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8143. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8144. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  8145. if (_view.Code == 0)
  8146. {
  8147. return Ok(JsonView(true, "操作成功"));
  8148. }
  8149. return Ok(JsonView(false, "操作失败"));
  8150. }
  8151. /// <summary>
  8152. /// 团组模块 - 出入境费用-草稿 - 子项删除
  8153. /// </summary>
  8154. /// <returns></returns>
  8155. [HttpPost]
  8156. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8158. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  8159. {
  8160. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  8161. if (data.Code != 0)
  8162. {
  8163. return Ok(JsonView(false, data.Msg));
  8164. }
  8165. return Ok(JsonView(true, "操作成功!", data.Data));
  8166. }
  8167. /// <summary>
  8168. /// 三公其他费用草稿 删除
  8169. /// </summary>
  8170. /// <param name="dto"></param>
  8171. /// <returns></returns>
  8172. [HttpPost]
  8173. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8174. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  8175. {
  8176. var jw = JsonView(false, "删除失败!");
  8177. var data = new Grp_DayOtherPriceDraft()
  8178. {
  8179. Id = dto.Id,
  8180. IsDel = 1,
  8181. DeleteUserId = dto.DeleteUserId,
  8182. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8183. };
  8184. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8185. if (del > 0)
  8186. {
  8187. jw.Code = 200;
  8188. jw.Msg = "删除成功!";
  8189. }
  8190. return Ok(jw);
  8191. }
  8192. /// <summary>
  8193. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  8194. /// </summary>
  8195. /// <returns></returns>
  8196. [HttpPost]
  8197. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  8198. {
  8199. var jw = JsonView(false);
  8200. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  8201. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  8202. jw.Code = StatusCodes.Status200OK;
  8203. jw.Msg = "操作成功!";
  8204. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  8205. return Ok(jw);
  8206. }
  8207. /// <summary>
  8208. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  8209. /// </summary>
  8210. /// <param name="dto"></param>
  8211. /// <returns></returns>
  8212. [HttpPost]
  8213. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  8214. {
  8215. int userId = dto.UserId,
  8216. portId = dto.PortType,
  8217. groupId = dto.GroupId,
  8218. draftId = dto.DraftId;
  8219. _portTypeData.Add(1);
  8220. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8221. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  8222. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  8223. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  8224. _sqlSugar.BeginTran();
  8225. try
  8226. {
  8227. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  8228. if (draftDatas == null)
  8229. {
  8230. _sqlSugar.RollbackTran();
  8231. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  8232. }
  8233. //验证可覆盖已有数据 两边创建人需为同一人;
  8234. int draftCreateUserId = draftDatas.CreateUserId,
  8235. formalCreateUserId = 0;
  8236. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8237. if (formalData != null)
  8238. {
  8239. formalCreateUserId = formalData.CreateUserId;
  8240. if (draftCreateUserId != formalCreateUserId)
  8241. {
  8242. _sqlSugar.RollbackTran();
  8243. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  8244. }
  8245. }
  8246. //默认添加查看、编辑权限(创建人、自己)
  8247. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  8248. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8249. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8250. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  8251. newExterData.DiId = groupId;
  8252. newExterData.CreateUserId = userId;
  8253. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  8254. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  8255. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  8256. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  8257. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  8258. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8259. //数据如果存在执行删除
  8260. if (enterExitCostInfo != null)
  8261. {
  8262. _sqlSugar.Updateable<Grp_EnterExitCost>()
  8263. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  8264. .Where(x => x.Id == enterExitCostInfo.Id)
  8265. .ExecuteCommand();
  8266. _sqlSugar.Updateable<Grp_DayAndCost>()
  8267. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8268. .Where(x => x.DiId == groupId)
  8269. .ExecuteCommand();
  8270. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8271. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8272. .Where(x => x.Diid == groupId)
  8273. .ExecuteCommand();
  8274. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  8275. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8276. .Where(x => x.GroupId == groupId)
  8277. .ExecuteCommand();
  8278. }
  8279. //执行insert
  8280. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  8281. if (insertId < 1)
  8282. {
  8283. _sqlSugar.RollbackTran();
  8284. return Ok(JsonView(false, "草稿数据导入失败!"));
  8285. }
  8286. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  8287. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  8288. #region 默认添加权限
  8289. #endregion
  8290. _sqlSugar.CommitTran();
  8291. //执行操作之后
  8292. //生成默认文件pdf并且通知人员
  8293. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8294. {
  8295. DiId = groupId,
  8296. ExportType = 1,
  8297. SubTypeId = 1005
  8298. }, "pdf");
  8299. //发送通知
  8300. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8301. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  8302. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  8303. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  8304. //汇率信息记录
  8305. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  8306. return Ok(JsonView(true));
  8307. }
  8308. catch (Exception ex)
  8309. {
  8310. _sqlSugar.RollbackTran();
  8311. return Ok(JsonView(false, ex.Message));
  8312. }
  8313. }
  8314. #endregion
  8315. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  8316. /// <summary>
  8317. /// 获取币种基础数据(含逻辑处理)
  8318. /// </summary>
  8319. /// <returns></returns>
  8320. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  8321. {
  8322. return await GeneralMethod.EnterExitCostInitRate();
  8323. }
  8324. /// <summary>
  8325. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  8326. /// </summary>
  8327. /// <returns></returns>
  8328. [HttpPost]
  8329. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8330. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  8331. {
  8332. //验证城市归属并给默认值
  8333. int provinceId = dto.ProvinceId;
  8334. if (provinceId < 1) provinceId = 122;
  8335. var dataSource = await _sqlSugar
  8336. .Queryable<Sys_SetData>()
  8337. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  8338. .ToListAsync();
  8339. var fileTypes = new List<EecSetDataInfoView>();
  8340. //三公费用-Word明细类型
  8341. var wordTypeData = dataSource
  8342. .Where(it => it.STid == 72)
  8343. .Select(x => new EecSetDataInfoView
  8344. {
  8345. ParentId = 1,
  8346. Id = x.Id,
  8347. Name = x.Name
  8348. })
  8349. .ToArray();
  8350. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  8351. var excelTypeData = dataSource
  8352. .Where(it => it.STid == 73)
  8353. .Select(x => new EecSetDataInfoView
  8354. {
  8355. ParentId = 2,
  8356. Id = x.Id,
  8357. Name = x.Name
  8358. })
  8359. .ToArray();
  8360. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  8361. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  8362. fileTypes.Add(groupNameList);
  8363. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  8364. //默认币种显示
  8365. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  8366. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  8367. return Ok(JsonView(true, "查询成功!", new
  8368. {
  8369. FileTypeData = fileTypes,
  8370. CurrencyInit = _currencyInfos,
  8371. viewPermissionData = viewPermissionData
  8372. }));
  8373. }
  8374. /// <summary>
  8375. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  8376. /// </summary>
  8377. /// <returns></returns>
  8378. [HttpPost]
  8379. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8380. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  8381. {
  8382. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8383. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8384. RefAsync<int> total = 0;
  8385. int diId = 0;
  8386. var status = int.TryParse(dto.GroupName, out diId);
  8387. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  8388. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  8389. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  8390. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  8391. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  8392. .OrderByDescending(x => x.VisitStartDate)
  8393. .Select(x => new EnterExitCostMobileGroupView()
  8394. {
  8395. Id = x.Id,
  8396. GroupName = x.TeamName,
  8397. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  8398. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  8399. ProvinceId = x.CityId
  8400. })
  8401. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8402. //处理省份Id
  8403. if (data.Any())
  8404. {
  8405. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  8406. if (provCityDatas.Any())
  8407. {
  8408. foreach (var item in data)
  8409. {
  8410. var provinceId = item.ProvinceId;
  8411. var isDefualtVal = true;
  8412. if (provinceId > 0)
  8413. {
  8414. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  8415. if (parentId != null)
  8416. {
  8417. isDefualtVal = false;
  8418. item.ProvinceId = (int)parentId;
  8419. }
  8420. }
  8421. if (isDefualtVal)
  8422. {
  8423. item.ProvinceId = 122; //默认四川
  8424. }
  8425. }
  8426. }
  8427. }
  8428. //处理是否显示
  8429. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  8430. {
  8431. foreach (var item in data)
  8432. {
  8433. item.IsView = true;
  8434. }
  8435. }
  8436. return Ok(JsonView(true, "查询成功!", data, total));
  8437. }
  8438. /// <summary>
  8439. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  8440. /// </summary>
  8441. /// <returns></returns>
  8442. [HttpPost]
  8443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8444. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  8445. {
  8446. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8447. RefAsync<int> total = 0;
  8448. var data = await _sqlSugar.Queryable<Sys_SetData>()
  8449. .Where(x => x.IsDel == 0 && x.STid == 66)
  8450. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  8451. .Select(x => new
  8452. {
  8453. id = x.Id,
  8454. name = x.Name,
  8455. remark = x.Remark,
  8456. })
  8457. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8458. return Ok(JsonView(true, "查询成功!", data, total));
  8459. }
  8460. /// <summary>
  8461. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  8462. /// </summary>
  8463. /// <returns></returns>
  8464. [HttpPost]
  8465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8466. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  8467. {
  8468. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8469. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8470. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  8471. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  8472. var groupOtherRateData = groupRateData.TeamRates;
  8473. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8474. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  8475. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  8476. groupOtherRateData = groupOtherRateData
  8477. .Select(x => new TeamRateDescAddCurrencyIdView
  8478. {
  8479. CurrencyId = x.CurrencyId,
  8480. CurrencyName = x.CurrencyName,
  8481. CurrencyCode = x.CurrencyCode,
  8482. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  8483. }).ToList();
  8484. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  8485. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  8486. }
  8487. /// <summary>
  8488. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  8489. /// </summary>
  8490. /// <returns></returns>
  8491. [HttpPost]
  8492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8493. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  8494. {
  8495. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8496. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8497. var tipsData = new List<int>() { 1, 2, 3 };
  8498. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  8499. if (dto.TipsType == 1)
  8500. {
  8501. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  8502. }
  8503. else if (dto.TipsType == 2)
  8504. {
  8505. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  8506. return Ok(JsonView(true, "查询成功!", visaData.Data));
  8507. }
  8508. else if (dto.TipsType == 3)
  8509. {
  8510. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  8511. return Ok(JsonView(true, "查询成功!", airData.Data));
  8512. }
  8513. return Ok(JsonView(false));
  8514. }
  8515. /// <summary>
  8516. /// 团组模块 - 出入境国家费用标准-移动端 List
  8517. /// </summary>
  8518. /// <returns></returns>
  8519. [HttpPost]
  8520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8521. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  8522. {
  8523. Stopwatch sw = new Stopwatch();
  8524. sw.Start();
  8525. int provinceId = dto.ProvinceId;
  8526. if (provinceId < 1) provinceId = 122; // 默认四川
  8527. RefAsync<int> total = 0;
  8528. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8529. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  8530. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  8531. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  8532. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  8533. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  8534. .Select((ntf, sd, u, sd1) => new
  8535. {
  8536. Id = ntf.Id,
  8537. Area = $"{ntf.Country}-{ntf.City}",
  8538. Currency = ntf.Currency,
  8539. CurrencyCode = sd.Name,
  8540. CurrencyName = sd.Remark,
  8541. RoomCost = ntf.RoomCost,
  8542. FoodCost = ntf.FoodCost,
  8543. PublicCost = ntf.PublicCost,
  8544. TrainCost = ntf.TrainCost,
  8545. LastUpdateUserId = ntf.LastUpdateUserId,
  8546. LastUpdateUserName = u.CnName,
  8547. LastUpdateTime = ntf.LastUpdateTime
  8548. })
  8549. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8550. sw.Stop();
  8551. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  8552. }
  8553. /// <summary>
  8554. /// 团组模块 - 出入境费用-移动端 - Info
  8555. /// </summary>
  8556. /// <returns></returns>
  8557. [HttpPost]
  8558. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8559. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  8560. {
  8561. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8562. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8563. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  8564. return Ok(data);
  8565. }
  8566. /// <summary>
  8567. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  8568. /// </summary>
  8569. /// <returns></returns>
  8570. [HttpPost]
  8571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8572. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8573. {
  8574. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8575. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8576. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8577. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8578. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8579. mobileInfo.DiId = dto.DiId;
  8580. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8581. if (eecInfo == null) return Ok(mobileInfo);
  8582. //验证查看权限
  8583. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  8584. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  8585. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8586. mobileInfo.IsAssignPerm = isSet;
  8587. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8588. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8589. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8590. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8591. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8592. {
  8593. SubId = dac.Id,
  8594. DiId = dac.DiId,
  8595. Type = dac.Type,
  8596. Days = dac.Days,
  8597. NationalTravelFeeId = dac.NationalTravelFeeId,
  8598. Arae = $"{ntf.Country}-{ntf.City}",
  8599. Cost = dac.Cost,
  8600. Currency = dac.Currency,
  8601. CurrencyName = sd.Name,
  8602. SubTotal = dac.SubTotal,
  8603. })
  8604. .ToList();
  8605. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8606. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8607. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8608. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8609. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8610. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8611. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8612. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8613. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8614. //其他款项
  8615. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8616. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8617. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8618. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8619. .OrderBy((dop, sd1, sd2) => dop.Index)
  8620. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8621. {
  8622. SubId = dop.Id,
  8623. DiId = dop.Diid,
  8624. Index = dop.Index,
  8625. SetDataId = dop.SetDataId,
  8626. SetDataName = sd1.Name,
  8627. Cost = dop.Cost,
  8628. Currency = dop.Currency,
  8629. CurrencyName = sd2.Remark,
  8630. SubTotal = dop.SubTotal,
  8631. Remark = dop.Remark,
  8632. })
  8633. .ToArray();
  8634. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8635. return Ok(mobileInfo);
  8636. }
  8637. /// <summary>
  8638. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8639. /// </summary>
  8640. /// <returns></returns>
  8641. [HttpPost]
  8642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8643. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8644. {
  8645. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8646. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8647. //验证查看权限
  8648. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  8649. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  8650. var userIds = await _sqlSugar
  8651. .Queryable<Grp_EnterExitCostPermission>()
  8652. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8653. .Select(x => x.UserId)
  8654. .ToArrayAsync();
  8655. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  8656. var perUsersView = new List<dynamic>();
  8657. foreach (var item in perUsers)
  8658. {
  8659. bool isView1 = false;
  8660. if (userIds.Any(x => x == item.Id)) isView1 = true;
  8661. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  8662. }
  8663. return Ok(JsonView(perUsersView));
  8664. }
  8665. /// <summary>
  8666. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8667. /// </summary>
  8668. /// <returns></returns>
  8669. [HttpPost]
  8670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8671. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8672. {
  8673. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8674. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8675. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8676. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8677. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8678. //验证查看权限
  8679. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8680. //if (!isView) return Ok(JsonView(false, msg));
  8681. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8682. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8683. var subType = dto.SubType;
  8684. if (subType == 1) //1:境内费用
  8685. {
  8686. var oneData = new ChoiceOneMobileSubInfoView()
  8687. {
  8688. Id = eecInfo.Id,
  8689. ChoiceOne = eecInfo.ChoiceOne,
  8690. ChoiceOneTotalCost = eecInfo.InsidePay,
  8691. Visa = eecInfo.Visa,
  8692. VisaRemark = eecInfo.VisaRemark,
  8693. YiMiao = eecInfo.YiMiao,
  8694. HeSuan = eecInfo.HeSuan,
  8695. Service = eecInfo.Service,
  8696. Ticket = eecInfo.Ticket,
  8697. Safe = eecInfo.Safe,
  8698. FirstItemRemark = eecInfo.FirstItemRemark
  8699. };
  8700. return Ok(JsonView(oneData));
  8701. }
  8702. else if (subType == 2) //2:国际旅费
  8703. {
  8704. var twoData = new ChoiceTwoMobileSubInfoView()
  8705. {
  8706. Id = eecInfo.Id,
  8707. ChoiceTwoJJ = eecInfo.SumJJC,
  8708. OutsideJJPay = eecInfo.OutsideJJPay,
  8709. ChoiceTwoGW = eecInfo.SumGWC,
  8710. OutsideGWPay = eecInfo.OutsideGWPay,
  8711. ChoiceTwoTD = eecInfo.SumTDC,
  8712. OutsideTDPay = eecInfo.OutsideTDPay,
  8713. AirJJ = eecInfo.AirJJ,
  8714. AirGW = eecInfo.AirGW,
  8715. AirTD = eecInfo.AirTD,
  8716. CityTranffic = eecInfo.CityTranffic,
  8717. TwoItemRemark = eecInfo.TwoItemRemark
  8718. };
  8719. return Ok(JsonView(twoData));
  8720. }
  8721. else if (subType == 3) //3:住宿费
  8722. {
  8723. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8724. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8725. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8726. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8727. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8728. {
  8729. SubId = dac.Id,
  8730. DiId = dac.DiId,
  8731. Type = dac.Type,
  8732. Days = dac.Days,
  8733. NationalTravelFeeId = dac.NationalTravelFeeId,
  8734. Arae = $"{ntf.Country}-{ntf.City}",
  8735. Cost = dac.Cost,
  8736. Currency = dac.Currency,
  8737. CurrencyName = sd.Name,
  8738. SubTotal = dac.SubTotal,
  8739. })
  8740. .ToArray();
  8741. var data = new ChoiceMobileSubInfo3To6View()
  8742. {
  8743. ParentId = eecInfo.Id,
  8744. Choice = eecInfo.ChoiceThree,
  8745. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8746. Details = dayAndCostDatas
  8747. };
  8748. return Ok(JsonView(data));
  8749. }
  8750. else if (subType == 4) //4:伙食费
  8751. {
  8752. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8753. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8754. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8755. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8756. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8757. {
  8758. SubId = dac.Id,
  8759. DiId = dac.DiId,
  8760. Type = dac.Type,
  8761. Days = dac.Days,
  8762. NationalTravelFeeId = dac.NationalTravelFeeId,
  8763. Arae = $"{ntf.Country}-{ntf.City}",
  8764. Cost = dac.Cost,
  8765. Currency = dac.Currency,
  8766. CurrencyName = sd.Name,
  8767. SubTotal = dac.SubTotal,
  8768. })
  8769. .ToArray();
  8770. var data = new ChoiceMobileSubInfo3To6View()
  8771. {
  8772. ParentId = eecInfo.Id,
  8773. Choice = eecInfo.ChoiceFour,
  8774. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8775. Details = dayAndCostDatas
  8776. };
  8777. return Ok(JsonView(data));
  8778. }
  8779. else if (subType == 5) //5:公杂费
  8780. {
  8781. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8782. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8783. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8784. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8785. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8786. {
  8787. SubId = dac.Id,
  8788. DiId = dac.DiId,
  8789. Type = dac.Type,
  8790. Days = dac.Days,
  8791. NationalTravelFeeId = dac.NationalTravelFeeId,
  8792. Arae = $"{ntf.Country}-{ntf.City}",
  8793. Cost = dac.Cost,
  8794. Currency = dac.Currency,
  8795. CurrencyName = sd.Name,
  8796. SubTotal = dac.SubTotal,
  8797. })
  8798. .ToArray();
  8799. var data = new ChoiceMobileSubInfo3To6View()
  8800. {
  8801. ParentId = eecInfo.Id,
  8802. Choice = eecInfo.ChoiceFive,
  8803. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8804. Details = dayAndCostDatas
  8805. };
  8806. return Ok(JsonView(data));
  8807. }
  8808. else if (subType == 6) //6:培训费
  8809. {
  8810. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8811. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8812. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8813. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8814. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8815. {
  8816. SubId = dac.Id,
  8817. DiId = dac.DiId,
  8818. Type = dac.Type,
  8819. Days = dac.Days,
  8820. NationalTravelFeeId = dac.NationalTravelFeeId,
  8821. Arae = $"{ntf.Country}-{ntf.City}",
  8822. Cost = dac.Cost,
  8823. Currency = dac.Currency,
  8824. CurrencyName = sd.Name,
  8825. SubTotal = dac.SubTotal,
  8826. })
  8827. .ToArray();
  8828. var data = new ChoiceMobileSubInfo3To6View()
  8829. {
  8830. ParentId = eecInfo.Id,
  8831. Choice = eecInfo.ChoiceSix,
  8832. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8833. Details = dayAndCostDatas
  8834. };
  8835. return Ok(JsonView(data));
  8836. }
  8837. else if (subType == 7) //7:其他
  8838. {
  8839. //其他款项
  8840. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8841. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8842. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8843. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8844. .OrderBy((dop, sd1, sd2) => dop.Index)
  8845. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8846. {
  8847. SubId = dop.Id,
  8848. DiId = dop.Diid,
  8849. Index = dop.Index,
  8850. SetDataId = dop.SetDataId,
  8851. SetDataName = sd1.Name,
  8852. Cost = dop.Cost,
  8853. Currency = dop.Currency,
  8854. CurrencyName = sd2.Name,
  8855. SubTotal = dop.SubTotal,
  8856. Remark = dop.Remark,
  8857. })
  8858. .ToArray();
  8859. var data = new ChoiceSevenMobileSubInfoView()
  8860. {
  8861. ParentId = eecInfo.Id,
  8862. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8863. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8864. Details = otherData
  8865. };
  8866. return Ok(JsonView(data));
  8867. }
  8868. return Ok(JsonView(false));
  8869. }
  8870. #region op
  8871. /// <summary>
  8872. /// 移动端更新费用消息通知
  8873. /// </summary>
  8874. /// <param name="diid"></param>
  8875. /// <param name="id"></param>
  8876. /// <param name="currUserId"></param>
  8877. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8878. {
  8879. try
  8880. {
  8881. ////生成默认文件pdf并且通知人员
  8882. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8883. //{
  8884. // DiId = diid,
  8885. // ExportType = 1,
  8886. // SubTypeId = 1005
  8887. //}, "pdf");
  8888. ////发送通知
  8889. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8890. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8891. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8892. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8893. ////汇率信息记录
  8894. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8895. }
  8896. catch (Exception ex)
  8897. {
  8898. //记录日志
  8899. throw;
  8900. }
  8901. }
  8902. /// <summary>
  8903. /// 验证出入境费用数据是否存在
  8904. /// 不存在添加
  8905. /// </summary>
  8906. /// <param name="diId"></param>
  8907. /// <param name="currUserId"></param>
  8908. /// <returns></returns>
  8909. /// <exception cref="CustomException"></exception>
  8910. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8911. {
  8912. var parentId = 0;
  8913. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8914. if (info != null)
  8915. {
  8916. parentId = info.Id;
  8917. }
  8918. else
  8919. {
  8920. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8921. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8922. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8923. parentId = addId;
  8924. }
  8925. return parentId;
  8926. }
  8927. /// <summary>
  8928. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8929. /// </summary>
  8930. /// <returns></returns>
  8931. [HttpPost]
  8932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8933. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8934. {
  8935. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8936. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8937. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8938. //验证编辑权限
  8939. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8940. //if (!isEdit) return Ok(JsonView(false, msg));
  8941. var permissions = new List<Grp_EnterExitCostPermission>();
  8942. foreach (var userId in dto.UserIds)
  8943. {
  8944. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8945. }
  8946. if (permissions.Any())
  8947. {
  8948. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  8949. {
  8950. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  8951. }
  8952. _sqlSugar.BeginTran();
  8953. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8954. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8955. if (result < 1)
  8956. {
  8957. _sqlSugar.RollbackTran();
  8958. return Ok(JsonView(false));
  8959. }
  8960. _sqlSugar.CommitTran();
  8961. return Ok(JsonView(true));
  8962. }
  8963. return Ok(JsonView(false));
  8964. }
  8965. /// <summary>
  8966. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8967. /// </summary>
  8968. /// <returns></returns>
  8969. [HttpPost]
  8970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8971. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8972. {
  8973. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8974. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8975. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8976. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8977. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8978. int id = dto.Id;
  8979. if (id <= 0) //add
  8980. {
  8981. //int provinceId = dto.ProvinceId;
  8982. int groupId = dto.DiId;
  8983. //if (provinceId < 1) provinceId = 122;
  8984. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  8985. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  8986. if (add < 1) return Ok(JsonView(false));
  8987. id = add;
  8988. }
  8989. else //update
  8990. {
  8991. ////验证编辑权限
  8992. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8993. //if (!isEdit) return Ok(JsonView(false, msg));
  8994. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8995. if (upd < 1) return Ok(JsonView(false));
  8996. }
  8997. #region 汇率变更时更改币种相关费用
  8998. var opDayCosts = new List<Grp_DayAndCost>();
  8999. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  9000. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9001. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  9002. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9003. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9004. .Select((dac, sd) => new
  9005. {
  9006. dac.Id,
  9007. dac.DiId,
  9008. CurrencyCode = sd.Name,
  9009. dac.Cost
  9010. })
  9011. .ToList();
  9012. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9013. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9014. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9015. .Select((dop, sd) => new
  9016. {
  9017. dop.Id,
  9018. dop.Diid,
  9019. CurrencyCode = sd.Name,
  9020. dop.Cost
  9021. })
  9022. .ToList();
  9023. if (dayCosts.Count > 0)
  9024. {
  9025. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9026. foreach (var dc in new_dayCosts)
  9027. {
  9028. var thisCurrency = dc.Key.ToUpper();
  9029. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9030. if (thisRate == 0.00M) continue;
  9031. foreach (var dcSub in dc)
  9032. {
  9033. opDayCosts.Add(new Grp_DayAndCost()
  9034. {
  9035. Id = dcSub.Id,
  9036. DiId = dcSub.DiId,
  9037. Cost = dcSub.Cost,
  9038. SubTotal = dcSub.Cost * thisRate,
  9039. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9040. });
  9041. }
  9042. }
  9043. if (opDayCosts.Count > 0)
  9044. {
  9045. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9046. }
  9047. }
  9048. if (dayOtherCosts.Count > 0)
  9049. {
  9050. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9051. foreach (var dc in new_dayOtherCosts)
  9052. {
  9053. var thisCurrency = dc.Key.ToUpper();
  9054. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9055. if (thisRate == 0.00M) continue;
  9056. foreach (var dcSub in dc)
  9057. {
  9058. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  9059. {
  9060. Id = dcSub.Id,
  9061. Diid = dcSub.Diid,
  9062. Cost = dcSub.Cost,
  9063. SubTotal = dcSub.Cost * thisRate,
  9064. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9065. });
  9066. }
  9067. }
  9068. if (opDayOtherCosts.Count > 0)
  9069. {
  9070. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9071. }
  9072. }
  9073. #endregion
  9074. //消息通知
  9075. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9076. //汇率信息记录
  9077. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9078. return Ok(JsonView(new { parentId = id }));
  9079. }
  9080. /// <summary>
  9081. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  9082. /// </summary>
  9083. /// <returns></returns>
  9084. [HttpPost]
  9085. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9086. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  9087. {
  9088. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9089. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9090. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9091. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9092. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  9093. int id = dto.Id;
  9094. if (id <= 0) //add
  9095. {
  9096. checkboxInfo.CreateUserId = dto.CurrUserId;
  9097. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9098. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9099. if (add < 1) return Ok(JsonView(false));
  9100. }
  9101. else //update
  9102. {
  9103. ////验证编辑权限
  9104. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9105. //if (!isEdit) return Ok(JsonView(false, msg));
  9106. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9107. .UpdateColumns(x => new
  9108. {
  9109. x.ChoiceOne,
  9110. x.ChoiceTwo,
  9111. x.SumJJC,
  9112. x.SumGWC,
  9113. x.SumTDC,
  9114. x.ChoiceThree,
  9115. x.ChoiceFour,
  9116. x.ChoiceFive,
  9117. x.ChoiceSix,
  9118. x.OtherExpenses_Checked
  9119. })
  9120. .Where(x => x.Id == id)
  9121. .ExecuteCommandAsync();
  9122. if (upd < 1) return Ok(JsonView(false));
  9123. }
  9124. return Ok(JsonView(new { parentId = id }));
  9125. }
  9126. /// <summary>
  9127. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  9128. /// </summary>
  9129. /// <returns></returns>
  9130. [HttpPost]
  9131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9132. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  9133. {
  9134. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  9135. // if (provinceId < 1) provinceId = 122;
  9136. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9137. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9138. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9139. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9140. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9141. var checkboxInfo = new Grp_EnterExitCost()
  9142. {
  9143. Id = id,
  9144. //ProvinceId = provinceId,
  9145. DiId = diId,
  9146. CreateUserId = currUserId
  9147. };
  9148. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9149. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9150. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9151. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9152. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9153. if (id <= 0) //add
  9154. {
  9155. checkboxInfo.CreateUserId = dto.CurrUserId;
  9156. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9157. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9158. if (add < 1) return Ok(JsonView(false));
  9159. }
  9160. else //update
  9161. {
  9162. ////验证编辑权限
  9163. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9164. //if (!isEdit) return Ok(JsonView(false, msg));
  9165. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  9166. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9167. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9168. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9169. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9170. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9171. .Where(x => x.Id == id)
  9172. .ExecuteCommandAsync();
  9173. if (upd < 1) return Ok(JsonView(false));
  9174. }
  9175. return Ok(JsonView(new { parentId = id }));
  9176. }
  9177. /// <summary>
  9178. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  9179. /// </summary>
  9180. /// <returns></returns>
  9181. [HttpPost]
  9182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9183. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  9184. {
  9185. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9186. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9187. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9188. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9189. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9190. info.FirstItemRemark = dto.FirstItemRemark;
  9191. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9192. int id = dto.Id;
  9193. if (id <= 0) //add
  9194. {
  9195. info.CreateUserId = dto.CurrUserId;
  9196. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9197. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9198. if (add < 1) return Ok(JsonView(false));
  9199. id = add;
  9200. }
  9201. else //update
  9202. {
  9203. ////验证编辑权限
  9204. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9205. //if (!isEdit) return Ok(JsonView(false, msg));
  9206. var upd = await _sqlSugar.Updateable(info)
  9207. .UpdateColumns(x => new
  9208. {
  9209. x.ChoiceOne,
  9210. x.InsidePay,
  9211. x.VisaRemark,
  9212. x.Visa,
  9213. x.Service,
  9214. x.Safe,
  9215. x.Ticket,
  9216. x.HeSuan,
  9217. x.YiMiao,
  9218. x.FirstItemRemark
  9219. })
  9220. .Where(x => x.Id == id)
  9221. .ExecuteCommandAsync();
  9222. if (upd < 1) return Ok(JsonView(false));
  9223. }
  9224. //消息通知
  9225. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9226. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9227. }
  9228. /// <summary>
  9229. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  9230. /// </summary>
  9231. /// <returns></returns>
  9232. [HttpPost]
  9233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9234. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  9235. {
  9236. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9237. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9238. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9239. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9240. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9241. info.DiId = dto.DiId;
  9242. //info.ProvinceId = dto.ProvinceId;
  9243. info.OutsideJJPay = dto.OutsideJJPay;
  9244. info.OutsideGWPay = dto.OutsideGWPay;
  9245. info.OutsideTDPay = dto.OutsideTDPay;
  9246. info.AirJJ = dto.AirJJ;
  9247. info.AirGW = dto.AirGW;
  9248. info.AirTD = dto.AirTD;
  9249. info.CityTranffic = dto.CityTranffic;
  9250. info.TwoItemRemark = dto.TwoItemRemark;
  9251. info.SumJJC = dto.ChoiceTwoJJ;
  9252. info.SumGWC = dto.ChoiceTwoGW;
  9253. info.SumTDC = dto.ChoiceTwoTD;
  9254. int id = dto.Id;
  9255. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9256. if (id <= 0) //add
  9257. {
  9258. info.CreateUserId = dto.CurrUserId;
  9259. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9260. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9261. if (addId <= 0) return Ok(JsonView(false));
  9262. id = addId;
  9263. }
  9264. else //update
  9265. {
  9266. ////验证编辑权限
  9267. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9268. //if (!isEdit) return Ok(JsonView(false, msg));
  9269. var upd = await _sqlSugar.Updateable(info)
  9270. .UpdateColumns(x => new
  9271. {
  9272. x.SumJJC,
  9273. x.OutsideJJPay,
  9274. x.SumGWC,
  9275. x.OutsideGWPay,
  9276. x.SumTDC,
  9277. x.OutsideTDPay,
  9278. x.AirJJ,
  9279. x.AirGW,
  9280. x.AirTD,
  9281. x.CityTranffic,
  9282. x.TwoItemRemark
  9283. })
  9284. .Where(x => x.Id == id)
  9285. .ExecuteCommandAsync();
  9286. if (upd < 1) return Ok(JsonView(false));
  9287. }
  9288. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9289. gwcItemTotal = info.AirGW + info.CityTranffic;
  9290. tdcItemTotal = info.AirTD + info.CityTranffic;
  9291. //消息通知
  9292. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9293. return Ok(JsonView(new
  9294. {
  9295. parentId = id,
  9296. choiceTwoJJ = dto.ChoiceTwoJJ,
  9297. jjcItemTotal = jjcItemTotal,
  9298. choiceTwoGW = dto.ChoiceTwoGW,
  9299. gwcItemTotal = gwcItemTotal,
  9300. choiceTwoTD = dto.ChoiceTwoTD,
  9301. tdcItemTotal = tdcItemTotal
  9302. }));
  9303. }
  9304. /// <summary>
  9305. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9306. /// </summary>
  9307. /// <returns></returns>
  9308. [HttpPost]
  9309. [ApiExplorerSettings(IgnoreApi = true)]
  9310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9311. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  9312. {
  9313. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9314. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9315. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9316. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9317. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9318. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9319. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  9320. var infos = infos1.Select(x => new Grp_DayAndCost
  9321. {
  9322. Id = x.Id,
  9323. DiId = dto.DiId,
  9324. Type = dto.FeeType,
  9325. Days = x.Days,
  9326. NationalTravelFeeId = x.NationalTravelFeeId,
  9327. Cost = x.Cost,
  9328. Currency = x.Currency,
  9329. SubTotal = x.SubTotal,
  9330. CreateUserId = dto.CurrUserId
  9331. })
  9332. .ToList();
  9333. var adds = infos.Where(x => x.Id <= 0).ToList();
  9334. var upds = infos.Where(x => x.Id > 0).ToList();
  9335. if (adds.Count > 0)
  9336. {
  9337. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9338. if (add < 1) return Ok(JsonView(false));
  9339. }
  9340. if (upds.Count > 0)
  9341. {
  9342. var upd = await _sqlSugar.Updateable(adds)
  9343. .UpdateColumns(x => new
  9344. {
  9345. x.Days,
  9346. x.NationalTravelFeeId,
  9347. x.Cost,
  9348. x.Currency,
  9349. x.SubTotal
  9350. })
  9351. .WhereColumns(x => new { x.Id })
  9352. .ExecuteCommandAsync();
  9353. if (upd < 1) return Ok(JsonView(false));
  9354. }
  9355. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9356. //消息通知
  9357. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  9358. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9359. return Ok(JsonView(new { itemTotal = itemTotal }));
  9360. }
  9361. /// <summary>
  9362. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9363. /// </summary>
  9364. /// <returns></returns>
  9365. [HttpPost]
  9366. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9367. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  9368. {
  9369. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9370. int subId = dto.SubId, feeType = dto.FeeType;
  9371. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9372. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9373. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9374. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9375. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  9376. subInfo.Id = subId;
  9377. subInfo.DiId = dto.DiId;
  9378. if (feeType == 3) subInfo.Type = 1;
  9379. else if (feeType == 4) subInfo.Type = 2;
  9380. else if (feeType == 5) subInfo.Type = 3;
  9381. else if (feeType == 6) subInfo.Type = 4;
  9382. subInfo.CreateUserId = dto.CurrUserId;
  9383. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  9384. if (parentId < 1) return Ok(JsonView(false));
  9385. //子表op
  9386. if (subId < 1)
  9387. {
  9388. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9389. if (subAdd < 1) return Ok(JsonView(false));
  9390. }
  9391. else
  9392. {
  9393. ////验证编辑权限
  9394. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9395. //if (!isEdit) return Ok(JsonView(false, msg));
  9396. var subUpd = await _sqlSugar.Updateable(subInfo)
  9397. .UpdateColumns(x => new
  9398. {
  9399. x.Days,
  9400. x.NationalTravelFeeId,
  9401. x.Cost,
  9402. x.Currency,
  9403. x.SubTotal
  9404. })
  9405. .WhereColumns(x => new { x.Id })
  9406. .ExecuteCommandAsync();
  9407. if (subUpd < 1) return Ok(JsonView(false));
  9408. }
  9409. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  9410. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  9411. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9412. }
  9413. /// <summary>
  9414. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  9415. /// </summary>
  9416. /// <returns></returns>
  9417. [HttpPost]
  9418. [ApiExplorerSettings(IgnoreApi = true)]
  9419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9420. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  9421. {
  9422. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9423. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9424. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9425. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  9426. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  9427. {
  9428. Id = x.Id,
  9429. Diid = dto.DiId,
  9430. SetDataId = x.SetDataId,
  9431. Index = x.Index,
  9432. Cost = x.Cost,
  9433. Currency = x.Currency,
  9434. SubTotal = x.SubTotal,
  9435. CreateUserId = dto.CurrUserId,
  9436. Remark = x.Remark
  9437. }).ToList();
  9438. var adds = infos.Where(x => x.Id <= 0).ToList();
  9439. var upds = infos.Where(x => x.Id > 0).ToList();
  9440. if (adds.Count > 0)
  9441. {
  9442. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9443. if (add < 1) return Ok(JsonView(false));
  9444. }
  9445. if (upds.Count > 0)
  9446. {
  9447. var upd = await _sqlSugar.Updateable(adds)
  9448. .UpdateColumns(x => new
  9449. {
  9450. x.Index,
  9451. x.SetDataId,
  9452. x.Cost,
  9453. x.Currency,
  9454. x.SubTotal,
  9455. x.Remark
  9456. })
  9457. .WhereColumns(x => new { x.Id })
  9458. .ExecuteCommandAsync();
  9459. if (upd < 1) return Ok(JsonView(false));
  9460. }
  9461. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  9462. //消息通知
  9463. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  9464. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9465. return Ok(JsonView(new { itemTotal = itemTotal }));
  9466. }
  9467. /// <summary>
  9468. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  9469. /// </summary>
  9470. /// <returns></returns>
  9471. [HttpPost]
  9472. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9473. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  9474. {
  9475. int subId = dto.SubId;
  9476. int diId = dto.Diid;
  9477. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9478. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9479. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9480. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  9481. subInfo.Id = subId;
  9482. subInfo.Diid = dto.Diid;
  9483. subInfo.CreateUserId = dto.CurrUserId;
  9484. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  9485. if (parentId < 1) return Ok(JsonView(false));
  9486. #region 子表op
  9487. if (subId < 1)//add
  9488. {
  9489. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9490. if (subAdd < 1) return Ok(JsonView(false));
  9491. }
  9492. else //upd
  9493. {
  9494. ////验证编辑权限
  9495. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  9496. //if (!isEdit) return Ok(JsonView(false, msg));
  9497. var subUpd = await _sqlSugar.Updateable(subInfo)
  9498. .UpdateColumns(x => new
  9499. {
  9500. x.Index,
  9501. x.SetDataId,
  9502. x.Cost,
  9503. x.Currency,
  9504. x.SubTotal,
  9505. x.Remark
  9506. })
  9507. .WhereColumns(x => new { x.Id })
  9508. .ExecuteCommandAsync();
  9509. if (subUpd < 1) return Ok(JsonView(false));
  9510. }
  9511. #endregion
  9512. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  9513. //消息通知
  9514. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  9515. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9516. }
  9517. /// <summary>
  9518. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  9519. /// </summary>
  9520. /// <returns></returns>
  9521. [HttpPost]
  9522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9523. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  9524. {
  9525. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  9526. if (data.Code != 0)
  9527. {
  9528. return Ok(JsonView(false, data.Msg));
  9529. }
  9530. return Ok(JsonView(true, "操作成功!", data.Data));
  9531. }
  9532. /// <summary>
  9533. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  9534. /// </summary>
  9535. /// <param name="dto"></param>
  9536. /// <returns></returns>
  9537. [HttpPost]
  9538. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  9539. {
  9540. var data = new Grp_DayOtherPrice()
  9541. {
  9542. Id = dto.Id,
  9543. IsDel = 1,
  9544. DeleteUserId = dto.DeleteUserId,
  9545. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9546. };
  9547. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9548. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  9549. return Ok(JsonView(false, "删除失败!"));
  9550. }
  9551. #endregion
  9552. #endregion
  9553. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  9554. /// <summary>
  9555. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  9556. /// </summary>
  9557. /// <returns></returns>
  9558. [HttpGet]
  9559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9560. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  9561. {
  9562. var provData = await _groupRepository.ProvinceBasicSource();
  9563. return Ok(JsonView(true, "查询成功!", provData));
  9564. }
  9565. /// <summary>
  9566. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  9567. /// </summary>
  9568. /// <returns></returns>
  9569. [HttpPost]
  9570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9571. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  9572. {
  9573. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9574. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9575. RefAsync<int> total = 0;
  9576. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  9577. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  9578. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  9579. .Select(x => new
  9580. {
  9581. Id = x.Id,
  9582. DraftName = x.DraftName,
  9583. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  9584. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  9585. .Any()
  9586. })
  9587. .OrderByDescending(x => x.Id)
  9588. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9589. return Ok(JsonView(true, "查询成功!", data, total));
  9590. }
  9591. /// <summary>
  9592. /// 出入境费用-草稿 移动端
  9593. /// 获取币种基础数据(含逻辑处理)
  9594. /// </summary>
  9595. /// <returns></returns>
  9596. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  9597. {
  9598. return await GeneralMethod.EnterExitCostInitRate();
  9599. }
  9600. /// <summary>
  9601. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9602. /// </summary>
  9603. /// <returns></returns>
  9604. [HttpPost]
  9605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9606. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  9607. {
  9608. //验证城市归属并给默认值
  9609. int provinceId = dto.ProvinceId;
  9610. if (provinceId < 1) provinceId = 122;
  9611. var dataSource = await _sqlSugar
  9612. .Queryable<Sys_SetData>()
  9613. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9614. .ToListAsync();
  9615. //三公费用-Word明细类型
  9616. var wordTypeData = dataSource.Where(it => it.STid == 72)
  9617. .Select(x => new SetDataInfoView
  9618. {
  9619. Id = x.Id,
  9620. Name = x.Name,
  9621. Remark = x.Remark
  9622. })
  9623. .ToList();
  9624. //三公费用-Excel明细类型
  9625. var excelTypeData = dataSource.Where(it => it.STid == 73)
  9626. .Select(x => new SetDataInfoView
  9627. {
  9628. Id = x.Id,
  9629. Name = x.Name,
  9630. Remark = x.Remark
  9631. })
  9632. .ToList();
  9633. //默认币种显示
  9634. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9635. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9636. return Ok(JsonView(true, "查询成功!", new
  9637. {
  9638. WordTypeData = wordTypeData,
  9639. ExcelTypeData = excelTypeData,
  9640. CurrencyInit = _currencyInfos,
  9641. viewPermissionData = viewPermissionData
  9642. }));
  9643. }
  9644. /// <summary>
  9645. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9646. /// </summary>
  9647. /// <returns></returns>
  9648. [HttpPost]
  9649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9650. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9651. {
  9652. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9653. RefAsync<int> total = 0;
  9654. int diId = 0;
  9655. var status = int.TryParse(dto.GroupName, out diId);
  9656. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9657. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9658. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9659. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9660. .OrderByDescending(x => x.VisitStartDate)
  9661. .Select(x => new
  9662. {
  9663. Id = x.Id,
  9664. GroupName = x.TeamName
  9665. })
  9666. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9667. return Ok(JsonView(true, "查询成功!", data, total));
  9668. }
  9669. /// <summary>
  9670. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9671. /// </summary>
  9672. /// <returns></returns>
  9673. [HttpPost]
  9674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9675. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9676. {
  9677. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9678. RefAsync<int> total = 0;
  9679. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9680. .Where(x => x.IsDel == 0 && x.STid == 66)
  9681. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9682. .Select(x => new
  9683. {
  9684. id = x.Id,
  9685. name = x.Name,
  9686. remark = x.Remark,
  9687. })
  9688. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9689. return Ok(JsonView(true, "查询成功!", data, total));
  9690. }
  9691. /// <summary>
  9692. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9693. /// </summary>
  9694. /// <returns></returns>
  9695. [HttpPost]
  9696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9697. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9698. {
  9699. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9700. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9701. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  9702. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9703. var groupOtherRateData = groupRateData.TeamRates;
  9704. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9705. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9706. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9707. groupOtherRateData = groupOtherRateData
  9708. .Select(x => new TeamRateDescAddCurrencyIdView
  9709. {
  9710. CurrencyId = x.CurrencyId,
  9711. CurrencyName = x.CurrencyName,
  9712. CurrencyCode = x.CurrencyCode,
  9713. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9714. }).ToList();
  9715. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9716. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9717. }
  9718. /// <summary>
  9719. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9720. /// </summary>
  9721. /// <returns></returns>
  9722. [HttpPost]
  9723. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9724. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9725. {
  9726. int portType = dto.PortType;
  9727. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9728. var tipsData = new List<int>() { 1, 2, 3 };
  9729. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9730. if (dto.TipsType == 1)
  9731. {
  9732. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9733. }
  9734. else if (dto.TipsType == 2)
  9735. {
  9736. if (portType == 2)
  9737. {
  9738. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9739. }
  9740. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9741. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9742. .Select(x => x.NationalTravelFeeId)
  9743. .Distinct()
  9744. .ToListAsync();
  9745. if (portType == 2)
  9746. {
  9747. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9748. }
  9749. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9750. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9751. .Select(x => x.Country)
  9752. .Distinct()
  9753. .ToArrayAsync();
  9754. if (portType == 2)
  9755. {
  9756. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9757. }
  9758. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9759. return Ok(JsonView(true, "查询成功!", new
  9760. {
  9761. totalAmt = totalAmt,
  9762. remark = remark
  9763. }));
  9764. }
  9765. else if (dto.TipsType == 3)
  9766. {
  9767. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  9768. }
  9769. return Ok(JsonView(false));
  9770. }
  9771. /// <summary>
  9772. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  9773. /// </summary>
  9774. /// <returns></returns>
  9775. [HttpPost]
  9776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9777. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  9778. {
  9779. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  9780. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9781. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9782. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  9783. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  9784. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  9785. var info = new Grp_EnterExitCostDraft()
  9786. {
  9787. ProvinceId = dto.ProvinceId,
  9788. DraftName = dto.DraftName,
  9789. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  9790. CreateUserId = dto.CurrUserId
  9791. };
  9792. _sqlSugar.BeginTran();
  9793. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9794. if (draftId < 1)
  9795. {
  9796. _sqlSugar.RollbackTran();
  9797. return Ok(JsonView(false, "草稿创建失败!"));
  9798. }
  9799. //添加默认权限
  9800. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  9801. _sqlSugar.CommitTran();
  9802. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  9803. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9804. mobileInfo.Id = draftId;
  9805. mobileInfo.DraftName = dto.DraftName;
  9806. mobileInfo.Currencys = rateInfos;
  9807. mobileInfo.IsAssignPerm = assignPerm;
  9808. return Ok(JsonView(mobileInfo));
  9809. }
  9810. /// <summary>
  9811. /// 出入境费用-草稿-移动端 查看编辑提示消息
  9812. /// </summary>
  9813. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  9814. /// <summary>
  9815. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9816. /// </summary>
  9817. /// <returns></returns>
  9818. [HttpPost]
  9819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9820. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9821. {
  9822. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9823. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9824. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9825. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9826. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9827. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  9828. //验证查看编辑权限
  9829. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9830. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9831. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9832. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  9833. mobileInfo.IsAssignPerm = assignPerm;
  9834. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9835. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9836. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9837. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9838. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9839. {
  9840. ParentId = dac.ParentId,
  9841. SubId = dac.Id,
  9842. Type = dac.Type,
  9843. Days = dac.Days,
  9844. NationalTravelFeeId = dac.NationalTravelFeeId,
  9845. Arae = $"{ntf.Country}-{ntf.City}",
  9846. Cost = dac.Cost,
  9847. Currency = dac.Currency,
  9848. CurrencyName = sd.Name,
  9849. SubTotal = dac.SubTotal,
  9850. })
  9851. .ToList();
  9852. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9853. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9854. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9855. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9856. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9857. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9858. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9859. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9860. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9861. //其他款项
  9862. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9863. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9864. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9865. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9866. .OrderBy((dop, sd1, sd2) => dop.Index)
  9867. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9868. {
  9869. ParentId = dop.ParentId,
  9870. SubId = dop.Id,
  9871. Index = dop.Index,
  9872. SetDataId = dop.SetDataId,
  9873. SetDataName = sd1.Name,
  9874. Cost = dop.Cost,
  9875. Currency = dop.Currency,
  9876. CurrencyName = sd2.Remark,
  9877. SubTotal = dop.SubTotal,
  9878. Remark = dop.Remark,
  9879. })
  9880. .ToArray();
  9881. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9882. return Ok(mobileInfo);
  9883. }
  9884. /// <summary>
  9885. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9886. /// </summary>
  9887. /// <returns></returns>
  9888. [HttpPost]
  9889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9890. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9891. {
  9892. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9893. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9894. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9895. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9896. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9897. //验证查看编辑权限
  9898. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9899. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9900. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9901. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9902. var subType = dto.SubType;
  9903. if (subType == 1) //1:境内费用
  9904. {
  9905. var oneData = new ChoiceOneMobileSubInfoView()
  9906. {
  9907. Id = eecInfo.Id,
  9908. ChoiceOne = eecInfo.ChoiceOne,
  9909. ChoiceOneTotalCost = eecInfo.InsidePay,
  9910. Visa = eecInfo.Visa,
  9911. VisaRemark = eecInfo.VisaRemark,
  9912. YiMiao = eecInfo.YiMiao,
  9913. HeSuan = eecInfo.HeSuan,
  9914. Service = eecInfo.Service,
  9915. Ticket = eecInfo.Ticket,
  9916. Safe = eecInfo.Safe,
  9917. FirstItemRemark = eecInfo.FirstItemRemark
  9918. };
  9919. return Ok(JsonView(oneData));
  9920. }
  9921. else if (subType == 2) //2:国际旅费
  9922. {
  9923. var twoData = new ChoiceTwoMobileSubInfoView()
  9924. {
  9925. Id = eecInfo.Id,
  9926. ChoiceTwoJJ = eecInfo.SumJJC,
  9927. OutsideJJPay = eecInfo.OutsideJJPay,
  9928. ChoiceTwoGW = eecInfo.SumGWC,
  9929. OutsideGWPay = eecInfo.OutsideGWPay,
  9930. ChoiceTwoTD = eecInfo.SumTDC,
  9931. OutsideTDPay = eecInfo.OutsideTDPay,
  9932. AirJJ = eecInfo.AirJJ,
  9933. AirGW = eecInfo.AirGW,
  9934. AirTD = eecInfo.AirTD,
  9935. CityTranffic = eecInfo.CityTranffic,
  9936. TwoItemRemark = eecInfo.TwoItemRemark
  9937. };
  9938. return Ok(JsonView(twoData));
  9939. }
  9940. else if (subType == 3) //3:住宿费
  9941. {
  9942. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9943. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9944. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9945. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9946. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9947. {
  9948. ParentId = dac.ParentId,
  9949. SubId = dac.Id,
  9950. Type = dac.Type,
  9951. Days = dac.Days,
  9952. NationalTravelFeeId = dac.NationalTravelFeeId,
  9953. Arae = $"{ntf.Country}-{ntf.City}",
  9954. Cost = dac.Cost,
  9955. Currency = dac.Currency,
  9956. CurrencyName = sd.Name,
  9957. SubTotal = dac.SubTotal,
  9958. })
  9959. .ToArray();
  9960. var data = new ChoiceDraftMobileSubInfo3To6View()
  9961. {
  9962. ParentId = eecInfo.Id,
  9963. Choice = eecInfo.ChoiceThree,
  9964. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9965. Details = dayAndCostDatas
  9966. };
  9967. return Ok(JsonView(data));
  9968. }
  9969. else if (subType == 4) //4:伙食费
  9970. {
  9971. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9972. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9973. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9974. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9975. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9976. {
  9977. ParentId = dac.ParentId,
  9978. SubId = dac.Id,
  9979. Type = dac.Type,
  9980. Days = dac.Days,
  9981. NationalTravelFeeId = dac.NationalTravelFeeId,
  9982. Arae = $"{ntf.Country}-{ntf.City}",
  9983. Cost = dac.Cost,
  9984. Currency = dac.Currency,
  9985. CurrencyName = sd.Name,
  9986. SubTotal = dac.SubTotal,
  9987. })
  9988. .ToArray();
  9989. var data = new ChoiceDraftMobileSubInfo3To6View()
  9990. {
  9991. ParentId = eecInfo.Id,
  9992. Choice = eecInfo.ChoiceFour,
  9993. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9994. Details = dayAndCostDatas
  9995. };
  9996. return Ok(JsonView(data));
  9997. }
  9998. else if (subType == 5) //5:公杂费
  9999. {
  10000. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10001. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10002. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10003. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  10004. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10005. {
  10006. ParentId = dac.ParentId,
  10007. SubId = dac.Id,
  10008. Type = dac.Type,
  10009. Days = dac.Days,
  10010. NationalTravelFeeId = dac.NationalTravelFeeId,
  10011. Arae = $"{ntf.Country}-{ntf.City}",
  10012. Cost = dac.Cost,
  10013. Currency = dac.Currency,
  10014. CurrencyName = sd.Name,
  10015. SubTotal = dac.SubTotal,
  10016. })
  10017. .ToArray();
  10018. var data = new ChoiceDraftMobileSubInfo3To6View()
  10019. {
  10020. ParentId = eecInfo.Id,
  10021. Choice = eecInfo.ChoiceFive,
  10022. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10023. Details = dayAndCostDatas
  10024. };
  10025. return Ok(JsonView(data));
  10026. }
  10027. else if (subType == 6) //6:培训费
  10028. {
  10029. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10030. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10031. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10032. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  10033. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10034. {
  10035. ParentId = dac.ParentId,
  10036. SubId = dac.Id,
  10037. Type = dac.Type,
  10038. Days = dac.Days,
  10039. NationalTravelFeeId = dac.NationalTravelFeeId,
  10040. Arae = $"{ntf.Country}-{ntf.City}",
  10041. Cost = dac.Cost,
  10042. Currency = dac.Currency,
  10043. CurrencyName = sd.Name,
  10044. SubTotal = dac.SubTotal,
  10045. })
  10046. .ToArray();
  10047. var data = new ChoiceDraftMobileSubInfo3To6View()
  10048. {
  10049. ParentId = eecInfo.Id,
  10050. Choice = eecInfo.ChoiceSix,
  10051. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10052. Details = dayAndCostDatas
  10053. };
  10054. return Ok(JsonView(data));
  10055. }
  10056. else if (subType == 7) //7:其他
  10057. {
  10058. //其他款项
  10059. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10060. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10061. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10062. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10063. .OrderBy((dop, sd1, sd2) => dop.Index)
  10064. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10065. {
  10066. ParentId = dop.ParentId,
  10067. SubId = dop.Id,
  10068. Index = dop.Index,
  10069. SetDataId = dop.SetDataId,
  10070. SetDataName = sd1.Name,
  10071. Cost = dop.Cost,
  10072. Currency = dop.Currency,
  10073. CurrencyName = sd2.Name,
  10074. SubTotal = dop.SubTotal,
  10075. Remark = dop.Remark,
  10076. })
  10077. .ToArray();
  10078. var data = new ChoiceSevenDraftMobileSubInfoView()
  10079. {
  10080. ParentId = eecInfo.Id,
  10081. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10082. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10083. Details = otherData
  10084. };
  10085. return Ok(JsonView(data));
  10086. }
  10087. return Ok(JsonView(false));
  10088. }
  10089. #region op
  10090. /// <summary>
  10091. /// 移动端更新费用消息通知
  10092. /// </summary>
  10093. /// <param name="draftId"></param>
  10094. /// <param name="id"></param>
  10095. /// <param name="currUserId"></param>
  10096. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  10097. {
  10098. try
  10099. {
  10100. ////生成默认文件pdf并且通知人员
  10101. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10102. //{
  10103. // DiId = draftId,
  10104. // ExportType = 1,
  10105. // SubTypeId = 1005
  10106. //}, "pdf");
  10107. ////发送通知
  10108. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10109. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10110. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10111. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  10112. ////汇率信息记录
  10113. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10114. }
  10115. catch (Exception ex)
  10116. {
  10117. //记录日志
  10118. throw;
  10119. }
  10120. }
  10121. /// <summary>
  10122. /// 验证出入境费用数据是否存在
  10123. /// 不存在添加
  10124. /// </summary>
  10125. /// <param name="draftId"></param>
  10126. /// <param name="currUserId"></param>
  10127. /// <returns></returns>
  10128. /// <exception cref="CustomException"></exception>
  10129. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  10130. {
  10131. var parentId = 0;
  10132. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10133. if (info != null) parentId = info.Id;
  10134. else
  10135. {
  10136. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  10137. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10138. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10139. parentId = addId;
  10140. }
  10141. return parentId;
  10142. }
  10143. /// <summary>
  10144. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  10145. /// </summary>
  10146. /// <returns></returns>
  10147. [HttpPost]
  10148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10149. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  10150. {
  10151. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10152. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10153. //验证查看权限
  10154. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10155. if (!isView) return Ok(JsonView(false, _viewPermStr));
  10156. var userIds = await _sqlSugar
  10157. .Queryable<Grp_EnterExitCostDraftPermission>()
  10158. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  10159. .Select(x => x.UserId)
  10160. .ToArrayAsync();
  10161. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  10162. var perUsersView = new List<dynamic>();
  10163. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  10164. var viewPermissionData = new List<PermissionViewUserview>();
  10165. if (feeBasePerm.Any())
  10166. {
  10167. foreach (var item in feeBasePerm)
  10168. {
  10169. if (item.Users.Any())
  10170. {
  10171. viewPermissionData.AddRange(item.Users);
  10172. }
  10173. }
  10174. }
  10175. foreach (var item in perUsers)
  10176. {
  10177. bool isView1 = false;
  10178. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10179. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  10180. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10181. }
  10182. return Ok(JsonView(perUsersView));
  10183. }
  10184. /// <summary>
  10185. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  10186. /// </summary>
  10187. /// <returns></returns>
  10188. [HttpPost]
  10189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10190. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  10191. {
  10192. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10193. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10194. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10195. //验证查看编辑权限
  10196. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10197. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10198. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  10199. foreach (var userId in dto.UserIds)
  10200. {
  10201. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  10202. }
  10203. if (permissions.Any())
  10204. {
  10205. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10206. {
  10207. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10208. }
  10209. _sqlSugar.BeginTran();
  10210. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  10211. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10212. if (result < 1)
  10213. {
  10214. _sqlSugar.RollbackTran();
  10215. return Ok(JsonView(false));
  10216. }
  10217. _sqlSugar.CommitTran();
  10218. return Ok(JsonView(true));
  10219. }
  10220. return Ok(JsonView(false));
  10221. }
  10222. /// <summary>
  10223. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  10224. /// </summary>
  10225. /// <returns></returns>
  10226. [HttpPost]
  10227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10228. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  10229. {
  10230. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10231. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10232. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10233. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  10234. int id = dto.DraftId;
  10235. if (id <= 0) //add
  10236. {
  10237. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10238. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10239. if (add < 1) return Ok(JsonView(false));
  10240. id = add;
  10241. }
  10242. else //update
  10243. {
  10244. //验证查看编辑权限
  10245. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10246. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10247. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10248. if (upd < 1) return Ok(JsonView(false));
  10249. }
  10250. return Ok(JsonView(new { parentId = id }));
  10251. }
  10252. /// <summary>
  10253. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  10254. /// </summary>
  10255. /// <returns></returns>
  10256. [HttpPost]
  10257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10258. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  10259. {
  10260. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10261. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10262. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10263. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10264. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10265. int id = dto.DraftId;
  10266. if (id <= 0) //add
  10267. {
  10268. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10269. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10270. if (add < 1) return Ok(JsonView(false));
  10271. id = add;
  10272. }
  10273. else //update
  10274. {
  10275. //验证查看编辑权限
  10276. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10277. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10278. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10279. if (upd < 1) return Ok(JsonView(false));
  10280. }
  10281. #region 汇率变更时更改币种相关费用
  10282. var opDayCosts = new List<Grp_DayAndCostDraft>();
  10283. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  10284. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10285. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10286. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10287. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10288. .Select((dac, sd) => new
  10289. {
  10290. dac.Id,
  10291. dac.ParentId,
  10292. CurrencyCode = sd.Name,
  10293. dac.Cost
  10294. })
  10295. .ToList();
  10296. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10297. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10298. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10299. .Select((dop, sd) => new
  10300. {
  10301. dop.Id,
  10302. dop.ParentId,
  10303. CurrencyCode = sd.Name,
  10304. dop.Cost
  10305. })
  10306. .ToList();
  10307. if (dayCosts.Count > 0)
  10308. {
  10309. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10310. foreach (var dc in new_dayCosts)
  10311. {
  10312. var thisCurrency = dc.Key.ToUpper();
  10313. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10314. if (thisRate == 0.00M) continue;
  10315. foreach (var dcSub in dc)
  10316. {
  10317. opDayCosts.Add(new Grp_DayAndCostDraft()
  10318. {
  10319. Id = dcSub.Id,
  10320. ParentId = dcSub.ParentId,
  10321. Cost = dcSub.Cost,
  10322. SubTotal = dcSub.Cost * thisRate,
  10323. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  10324. });
  10325. }
  10326. }
  10327. if (opDayCosts.Count > 0)
  10328. {
  10329. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10330. }
  10331. }
  10332. if (dayOtherCosts.Count > 0)
  10333. {
  10334. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10335. foreach (var dc in new_dayOtherCosts)
  10336. {
  10337. var thisCurrency = dc.Key.ToUpper();
  10338. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10339. if (thisRate == 0.00M) continue;
  10340. foreach (var dcSub in dc)
  10341. {
  10342. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  10343. {
  10344. Id = dcSub.Id,
  10345. ParentId = dcSub.ParentId,
  10346. Cost = dcSub.Cost,
  10347. SubTotal = dcSub.Cost * thisRate,
  10348. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10349. });
  10350. }
  10351. }
  10352. if (opDayOtherCosts.Count > 0)
  10353. {
  10354. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10355. }
  10356. }
  10357. #endregion
  10358. ////消息通知
  10359. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10360. ////汇率信息记录
  10361. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10362. return Ok(JsonView(new { parentId = id }));
  10363. }
  10364. /// <summary>
  10365. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  10366. /// </summary>
  10367. /// <returns></returns>
  10368. [HttpPost]
  10369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10370. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  10371. {
  10372. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10373. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10374. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10375. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  10376. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10377. int id = dto.DraftId;
  10378. if (id <= 0) //add
  10379. {
  10380. checkboxInfo.ProvinceId = dto.ProvinceId;
  10381. checkboxInfo.CreateUserId = dto.CurrUserId;
  10382. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  10383. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10384. if (add < 1) return Ok(JsonView(false));
  10385. }
  10386. else //update
  10387. {
  10388. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10389. .UpdateColumns(x => new
  10390. {
  10391. x.ChoiceOne,
  10392. x.ChoiceTwo,
  10393. x.SumJJC,
  10394. x.SumGWC,
  10395. x.SumTDC,
  10396. x.ChoiceThree,
  10397. x.ChoiceFour,
  10398. x.ChoiceFive,
  10399. x.ChoiceSix,
  10400. x.OtherExpenses_Checked
  10401. })
  10402. .Where(x => x.Id == id)
  10403. .ExecuteCommandAsync();
  10404. if (upd < 1) return Ok(JsonView(false));
  10405. }
  10406. return Ok(JsonView(new { parentId = id }));
  10407. }
  10408. /// <summary>
  10409. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  10410. /// </summary>
  10411. /// <returns></returns>
  10412. [HttpPost]
  10413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10414. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  10415. {
  10416. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  10417. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10418. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10419. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10420. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10421. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10422. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10423. var checkboxInfo = new Grp_EnterExitCostDraft()
  10424. {
  10425. Id = draftId,
  10426. ProvinceId = dto.ProvinceId,
  10427. CreateUserId = currUserId
  10428. };
  10429. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10430. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10431. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10432. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10433. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10434. if (draftId <= 0) //add
  10435. {
  10436. checkboxInfo.CreateUserId = dto.CurrUserId;
  10437. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10438. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10439. if (add < 1) return Ok(JsonView(false));
  10440. }
  10441. else //update
  10442. {
  10443. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  10444. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10445. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10446. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10447. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10448. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10449. .Where(x => x.Id == draftId)
  10450. .ExecuteCommandAsync();
  10451. if (upd < 1) return Ok(JsonView(false));
  10452. }
  10453. return Ok(JsonView(new { parentId = draftId }));
  10454. }
  10455. /// <summary>
  10456. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  10457. /// </summary>
  10458. /// <returns></returns>
  10459. [HttpPost]
  10460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10461. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  10462. {
  10463. int id = dto.DraftId, currUserId = dto.CurrUserId;
  10464. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10465. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  10466. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10467. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10468. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  10469. info.ProvinceId = dto.ProvinceId;
  10470. info.FirstItemRemark = dto.FirstItemRemark;
  10471. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10472. if (id <= 0) //add
  10473. {
  10474. info.CreateUserId = dto.CurrUserId;
  10475. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10476. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10477. if (add < 1) return Ok(JsonView(false));
  10478. id = add;
  10479. }
  10480. else //update
  10481. {
  10482. var upd = await _sqlSugar.Updateable(info)
  10483. .UpdateColumns(x => new
  10484. {
  10485. x.ChoiceOne,
  10486. x.InsidePay,
  10487. x.VisaRemark,
  10488. x.Visa,
  10489. x.Service,
  10490. x.Safe,
  10491. x.Ticket,
  10492. x.HeSuan,
  10493. x.YiMiao,
  10494. x.FirstItemRemark
  10495. })
  10496. .Where(x => x.Id == id)
  10497. .ExecuteCommandAsync();
  10498. if (upd < 1) return Ok(JsonView(false));
  10499. }
  10500. ////消息通知
  10501. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10502. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10503. }
  10504. /// <summary>
  10505. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  10506. /// </summary>
  10507. /// <returns></returns>
  10508. [HttpPost]
  10509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10510. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  10511. {
  10512. int id = dto.DraftId;
  10513. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10514. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  10515. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10516. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10517. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  10518. info.ProvinceId = dto.ProvinceId;
  10519. info.OutsideJJPay = dto.OutsideJJPay;
  10520. info.OutsideGWPay = dto.OutsideGWPay;
  10521. info.OutsideTDPay = dto.OutsideTDPay;
  10522. info.AirJJ = dto.AirJJ;
  10523. info.AirGW = dto.AirGW;
  10524. info.AirTD = dto.AirTD;
  10525. info.CityTranffic = dto.CityTranffic;
  10526. info.TwoItemRemark = dto.TwoItemRemark;
  10527. info.SumJJC = dto.ChoiceTwoJJ;
  10528. info.SumGWC = dto.ChoiceTwoGW;
  10529. info.SumTDC = dto.ChoiceTwoTD;
  10530. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10531. if (id <= 0) //add
  10532. {
  10533. info.CreateUserId = dto.CurrUserId;
  10534. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10535. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10536. if (addId <= 0) return Ok(JsonView(false));
  10537. id = addId;
  10538. }
  10539. else //update
  10540. {
  10541. var upd = await _sqlSugar.Updateable(info)
  10542. .UpdateColumns(x => new
  10543. {
  10544. x.SumJJC,
  10545. x.OutsideJJPay,
  10546. x.SumGWC,
  10547. x.OutsideGWPay,
  10548. x.SumTDC,
  10549. x.OutsideTDPay,
  10550. x.AirJJ,
  10551. x.AirGW,
  10552. x.AirTD,
  10553. x.CityTranffic,
  10554. x.TwoItemRemark
  10555. })
  10556. .Where(x => x.Id == id)
  10557. .ExecuteCommandAsync();
  10558. if (upd < 1) return Ok(JsonView(false));
  10559. }
  10560. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10561. gwcItemTotal = info.AirGW + info.CityTranffic;
  10562. tdcItemTotal = info.AirTD + info.CityTranffic;
  10563. ////消息通知
  10564. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10565. return Ok(JsonView(new
  10566. {
  10567. parentId = id,
  10568. choiceTwoJJ = dto.ChoiceTwoJJ,
  10569. jjcItemTotal = jjcItemTotal,
  10570. choiceTwoGW = dto.ChoiceTwoGW,
  10571. gwcItemTotal = gwcItemTotal,
  10572. choiceTwoTD = dto.ChoiceTwoTD,
  10573. tdcItemTotal = tdcItemTotal
  10574. }));
  10575. }
  10576. /// <summary>
  10577. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10578. /// </summary>
  10579. /// <returns></returns>
  10580. [HttpPost]
  10581. [ApiExplorerSettings(IgnoreApi = true)]
  10582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10583. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  10584. {
  10585. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10586. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10587. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10588. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10589. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10590. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10591. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  10592. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  10593. {
  10594. Id = x.Id,
  10595. ParentId = dto.DraftId,
  10596. Type = dto.FeeType,
  10597. Days = x.Days,
  10598. NationalTravelFeeId = x.NationalTravelFeeId,
  10599. Cost = x.Cost,
  10600. Currency = x.Currency,
  10601. SubTotal = x.SubTotal,
  10602. CreateUserId = dto.CurrUserId
  10603. })
  10604. .ToList();
  10605. var adds = infos.Where(x => x.Id <= 0).ToList();
  10606. var upds = infos.Where(x => x.Id > 0).ToList();
  10607. if (adds.Count > 0)
  10608. {
  10609. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10610. if (add < 1) return Ok(JsonView(false));
  10611. }
  10612. if (upds.Count > 0)
  10613. {
  10614. var upd = await _sqlSugar.Updateable(adds)
  10615. .UpdateColumns(x => new
  10616. {
  10617. x.Days,
  10618. x.NationalTravelFeeId,
  10619. x.Cost,
  10620. x.Currency,
  10621. x.SubTotal
  10622. })
  10623. .WhereColumns(x => new { x.Id })
  10624. .ExecuteCommandAsync();
  10625. if (upd < 1) return Ok(JsonView(false));
  10626. }
  10627. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10628. ////消息通知
  10629. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  10630. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10631. return Ok(JsonView(new { itemTotal = itemTotal }));
  10632. }
  10633. /// <summary>
  10634. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10635. /// </summary>
  10636. /// <returns></returns>
  10637. [HttpPost]
  10638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10639. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  10640. {
  10641. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10642. int subId = dto.SubId, feeType = dto.FeeType;
  10643. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10644. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10645. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10646. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10647. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  10648. subInfo.Id = subId;
  10649. subInfo.ParentId = dto.DraftId;
  10650. if (feeType == 3) subInfo.Type = 1;
  10651. else if (feeType == 4) subInfo.Type = 2;
  10652. else if (feeType == 5) subInfo.Type = 3;
  10653. else if (feeType == 6) subInfo.Type = 4;
  10654. subInfo.CreateUserId = dto.CurrUserId;
  10655. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  10656. if (parentId < 1) return Ok(JsonView(false));
  10657. //子表op
  10658. if (subId < 1)
  10659. {
  10660. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10661. if (subAdd < 1) return Ok(JsonView(false));
  10662. }
  10663. else
  10664. {
  10665. var subUpd = await _sqlSugar.Updateable(subInfo)
  10666. .UpdateColumns(x => new
  10667. {
  10668. x.Days,
  10669. x.NationalTravelFeeId,
  10670. x.Cost,
  10671. x.Currency,
  10672. x.SubTotal
  10673. })
  10674. .WhereColumns(x => new { x.Id })
  10675. .ExecuteCommandAsync();
  10676. if (subUpd < 1) return Ok(JsonView(false));
  10677. }
  10678. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  10679. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10680. }
  10681. /// <summary>
  10682. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  10683. /// </summary>
  10684. /// <returns></returns>
  10685. [HttpPost]
  10686. [ApiExplorerSettings(IgnoreApi = true)]
  10687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10688. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  10689. {
  10690. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10691. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10692. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10693. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  10694. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  10695. {
  10696. Id = x.Id,
  10697. ParentId = dto.DraftId,
  10698. SetDataId = x.SetDataId,
  10699. Index = x.Index,
  10700. Cost = x.Cost,
  10701. Currency = x.Currency,
  10702. SubTotal = x.SubTotal,
  10703. CreateUserId = dto.CurrUserId,
  10704. Remark = x.Remark
  10705. }).ToList();
  10706. var adds = infos.Where(x => x.Id <= 0).ToList();
  10707. var upds = infos.Where(x => x.Id > 0).ToList();
  10708. if (adds.Count > 0)
  10709. {
  10710. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10711. if (add < 1) return Ok(JsonView(false));
  10712. }
  10713. if (upds.Count > 0)
  10714. {
  10715. var upd = await _sqlSugar.Updateable(adds)
  10716. .UpdateColumns(x => new
  10717. {
  10718. x.Index,
  10719. x.SetDataId,
  10720. x.Cost,
  10721. x.Currency,
  10722. x.SubTotal,
  10723. x.Remark
  10724. })
  10725. .WhereColumns(x => new { x.Id })
  10726. .ExecuteCommandAsync();
  10727. if (upd < 1) return Ok(JsonView(false));
  10728. }
  10729. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  10730. //消息通知
  10731. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  10732. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10733. return Ok(JsonView(new { itemTotal = itemTotal }));
  10734. }
  10735. /// <summary>
  10736. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  10737. /// </summary>
  10738. /// <returns></returns>
  10739. [HttpPost]
  10740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10741. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  10742. {
  10743. int subId = dto.SubId, id = dto.DraftId;
  10744. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10745. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  10746. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10747. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  10748. subInfo.Id = subId;
  10749. subInfo.ParentId = id;
  10750. subInfo.CreateUserId = dto.CurrUserId;
  10751. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  10752. if (parentId < 1) return Ok(JsonView(false));
  10753. #region 子表op
  10754. if (subId < 1)//add
  10755. {
  10756. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10757. if (subAdd < 1) return Ok(JsonView(false));
  10758. }
  10759. else //upd
  10760. {
  10761. var subUpd = await _sqlSugar.Updateable(subInfo)
  10762. .UpdateColumns(x => new
  10763. {
  10764. x.Index,
  10765. x.SetDataId,
  10766. x.Cost,
  10767. x.Currency,
  10768. x.SubTotal,
  10769. x.Remark
  10770. })
  10771. .WhereColumns(x => new { x.Id })
  10772. .ExecuteCommandAsync();
  10773. if (subUpd < 1) return Ok(JsonView(false));
  10774. }
  10775. #endregion
  10776. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10777. ////消息通知
  10778. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10779. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10780. }
  10781. /// <summary>
  10782. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10783. /// </summary>
  10784. /// <returns></returns>
  10785. [HttpPost]
  10786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10787. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10788. {
  10789. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10790. if (data.Code != 0)
  10791. {
  10792. return Ok(JsonView(false, data.Msg));
  10793. }
  10794. return Ok(JsonView(true, "操作成功!", data.Data));
  10795. }
  10796. /// <summary>
  10797. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10798. /// </summary>
  10799. /// <param name="dto"></param>
  10800. /// <returns></returns>
  10801. [HttpPost]
  10802. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10803. {
  10804. var data = new Grp_DayOtherPriceDraft()
  10805. {
  10806. Id = dto.Id,
  10807. IsDel = 1,
  10808. DeleteUserId = dto.DeleteUserId,
  10809. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10810. };
  10811. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10812. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10813. return Ok(JsonView(false, "删除失败!"));
  10814. }
  10815. #endregion
  10816. #endregion
  10817. #region 团组经理模块 出入境费用报价表
  10818. /// <summary>
  10819. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  10820. /// </summary>
  10821. /// <returns></returns>
  10822. [HttpPost]
  10823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10824. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  10825. {
  10826. var initRates = await GeneralMethod.EnterExitCostInitRate();
  10827. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  10828. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  10829. initRates.Insert(0, cnyInfo);
  10830. liveRates.Insert(0, cnyInfo);
  10831. return Ok(JsonView(true, "查询成功!", new
  10832. {
  10833. InitRates = initRates,
  10834. LiveRates = liveRates
  10835. }));
  10836. }
  10837. /// <summary>
  10838. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  10839. /// </summary>
  10840. /// <returns></returns>
  10841. [HttpPost]
  10842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10843. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  10844. {
  10845. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  10846. }
  10847. /// <summary>
  10848. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  10849. /// </summary>
  10850. /// <returns></returns>
  10851. [HttpPost]
  10852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10853. public async Task<IActionResult> EnterExitCostQuoteGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  10854. {
  10855. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  10856. }
  10857. /// <summary>
  10858. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  10859. /// </summary>
  10860. /// <returns></returns>
  10861. [HttpPost]
  10862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10863. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  10864. {
  10865. int groupId = dto.DiId,
  10866. currUserId = dto.CurrUserId;
  10867. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  10868. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  10869. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10870. if (info.Code != StatusCodes.Status200OK) return Ok(info);
  10871. var infoView = info.Data as EnterExitCostInfoView;
  10872. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  10873. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  10874. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  10875. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  10876. var eecRates = infoView.Currencys;
  10877. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  10878. int pplNum = 1;
  10879. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  10880. var views = new List<QuoteSubItemInfo>();
  10881. #region 数据填充
  10882. var intTravelCosts = new List<QuoteSubItemInfo>();
  10883. #region 机票费用 1354
  10884. int intTravelIndex = 1;
  10885. if (infoView.SumJJC == 1)
  10886. {
  10887. intTravelCosts.Add(new QuoteSubItemInfo
  10888. {
  10889. ItemId = 1354,
  10890. Index = intTravelIndex,
  10891. FeeName = "经济舱",
  10892. UnitPrice = infoView.AirJJ,
  10893. Currency = "CNY",
  10894. Quantity = 1,
  10895. PplNum = 1,
  10896. TotalAmt = infoView.AirJJ,
  10897. Remark = "",
  10898. });
  10899. intTravelIndex++;
  10900. }
  10901. if (infoView.SumGWC == 1)
  10902. {
  10903. intTravelCosts.Add(new QuoteSubItemInfo
  10904. {
  10905. ItemId = 1354,
  10906. Index = intTravelIndex,
  10907. FeeName = "公务舱",
  10908. UnitPrice = infoView.AirGW,
  10909. Currency = "CNY",
  10910. Quantity = 1,
  10911. PplNum = 1,
  10912. TotalAmt = infoView.AirGW,
  10913. Remark = "",
  10914. });
  10915. intTravelIndex++;
  10916. }
  10917. if (infoView.SumTDC == 1)
  10918. {
  10919. intTravelCosts.Add(new QuoteSubItemInfo
  10920. {
  10921. ItemId = 1354,
  10922. Index = intTravelIndex,
  10923. FeeName = "头等舱",
  10924. UnitPrice = infoView.AirTD,
  10925. Currency = "CNY",
  10926. Quantity = 1,
  10927. PplNum = 1,
  10928. TotalAmt = infoView.AirTD,
  10929. Remark = "",
  10930. });
  10931. intTravelIndex++;
  10932. }
  10933. intTravelCosts.Add(new QuoteSubItemInfo
  10934. {
  10935. ItemId = 1354,
  10936. Index = intTravelIndex,
  10937. FeeName = "城市间交通费用",
  10938. UnitPrice = infoView.CityTranffic,
  10939. Currency = "CNY",
  10940. Quantity = 1,
  10941. PplNum = pplNum,
  10942. TotalAmt = infoView.CityTranffic * pplNum,
  10943. Remark = "",
  10944. });
  10945. views.AddRange(intTravelCosts);
  10946. #endregion
  10947. var accomCosts = new List<QuoteSubItemInfo>();
  10948. #region 住宿费 1355
  10949. if (infoView.QuarterageData.Any())
  10950. {
  10951. int accomIndex = 1;
  10952. int accomItemTypeId = 1355;
  10953. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  10954. foreach (var item in groupData)
  10955. {
  10956. string feeName = string.Empty;
  10957. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10958. if (countryInfo != null)
  10959. {
  10960. feeName = countryInfo.Country;
  10961. var city = countryInfo.City;
  10962. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10963. {
  10964. feeName += $"-{city}";
  10965. }
  10966. }
  10967. var hotelInfo = item.FirstOrDefault();
  10968. if (hotelInfo == null) continue;
  10969. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  10970. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10971. int quantity = item.ToList().Count;
  10972. accomCosts.Add(new QuoteSubItemInfo
  10973. {
  10974. ItemId = accomItemTypeId,
  10975. Index = accomIndex,
  10976. FeeName = feeName,
  10977. UnitPrice = hotelInfo.Cost,
  10978. Currency = thisCurrency,
  10979. Quantity = quantity,
  10980. PplNum = pplNum,
  10981. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  10982. Remark = "",
  10983. });
  10984. accomIndex++;
  10985. }
  10986. views.AddRange(accomCosts);
  10987. }
  10988. #endregion
  10989. var mealCosts = new List<QuoteSubItemInfo>();
  10990. #region 餐饮费 1356
  10991. if (infoView.BoardWagesData.Any())
  10992. {
  10993. var mealIndex = 1;
  10994. int mealItemTypeId = 1356;
  10995. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  10996. foreach (var item in groupData)
  10997. {
  10998. string feeName = string.Empty;
  10999. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11000. if (countryInfo != null)
  11001. {
  11002. feeName = countryInfo.Country;
  11003. var city = countryInfo.City;
  11004. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11005. {
  11006. feeName += $"-{city}";
  11007. }
  11008. }
  11009. var mealInfo = item.FirstOrDefault();
  11010. if (mealInfo == null) continue;
  11011. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  11012. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11013. int quantity = item.ToList().Count;
  11014. mealCosts.Add(new QuoteSubItemInfo
  11015. {
  11016. ItemId = mealItemTypeId,
  11017. Index = mealIndex,
  11018. FeeName = feeName,
  11019. UnitPrice = mealInfo.Cost,
  11020. Currency = thisCurrency,
  11021. Quantity = quantity,
  11022. PplNum = pplNum,
  11023. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  11024. Remark = "",
  11025. });
  11026. mealIndex++;
  11027. }
  11028. views.AddRange(mealCosts);
  11029. }
  11030. #endregion
  11031. var miscCosts = new List<QuoteSubItemInfo>();
  11032. #region 公杂费 1364
  11033. if (infoView.MiscellaneousFeeData.Any())
  11034. {
  11035. var miscIndex = 1;
  11036. int miscItemTypeId = 1364;
  11037. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  11038. foreach (var item in groupData)
  11039. {
  11040. string feeName = string.Empty;
  11041. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11042. if (countryInfo != null)
  11043. {
  11044. feeName = countryInfo.Country;
  11045. var city = countryInfo.City;
  11046. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11047. {
  11048. feeName += $"-{city}";
  11049. }
  11050. }
  11051. var miscInfo = item.FirstOrDefault();
  11052. if (miscInfo == null) continue;
  11053. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  11054. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11055. int quantity = item.ToList().Count;
  11056. mealCosts.Add(new QuoteSubItemInfo
  11057. {
  11058. ItemId = miscItemTypeId,
  11059. Index = miscIndex,
  11060. FeeName = feeName,
  11061. UnitPrice = miscInfo.Cost,
  11062. Currency = thisCurrency,
  11063. Quantity = quantity,
  11064. PplNum = pplNum,
  11065. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  11066. Remark = "",
  11067. });
  11068. miscIndex++;
  11069. }
  11070. views.AddRange(mealCosts);
  11071. }
  11072. #endregion
  11073. #region 签证+保险 1362
  11074. int visaInsIndex = 1;
  11075. int visaInsItemTypeId = 1362;
  11076. if (infoView.Visa > 0)
  11077. {
  11078. views.Add(new QuoteSubItemInfo()
  11079. {
  11080. ItemId = visaInsItemTypeId,
  11081. Index = visaInsIndex,
  11082. FeeName = $"签证",
  11083. UnitPrice = infoView.Visa,
  11084. Currency = $"CNY",
  11085. Quantity = 1,
  11086. PplNum = pplNum,
  11087. TotalAmt = infoView.Visa * pplNum,
  11088. Remark = "",
  11089. });
  11090. visaInsIndex++;
  11091. }
  11092. if (infoView.Safe > 0)
  11093. {
  11094. views.Add(new QuoteSubItemInfo()
  11095. {
  11096. ItemId = visaInsItemTypeId,
  11097. Index = visaInsIndex,
  11098. FeeName = $"保险",
  11099. UnitPrice = infoView.Safe,
  11100. Currency = $"CNY",
  11101. Quantity = 1,
  11102. PplNum = pplNum,
  11103. TotalAmt = infoView.Safe * pplNum,
  11104. Remark = "",
  11105. });
  11106. }
  11107. #endregion
  11108. #region 服务费 1363
  11109. int serviceFeeIndex = 1;
  11110. int serviceFeeItemTypeId = 1363;
  11111. if (infoView.Service > 0)
  11112. {
  11113. views.Add(new QuoteSubItemInfo()
  11114. {
  11115. ItemId = serviceFeeItemTypeId,
  11116. Index = serviceFeeIndex,
  11117. FeeName = $"服务费",
  11118. UnitPrice = infoView.Service,
  11119. Currency = $"CNY",
  11120. Quantity = 1,
  11121. PplNum = pplNum,
  11122. TotalAmt = infoView.Service * pplNum,
  11123. Remark = "",
  11124. });
  11125. }
  11126. #endregion
  11127. #endregion
  11128. var result = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { });
  11129. result.Rates = eecRates.ToArray();
  11130. if (result.FeeItems.Any())
  11131. {
  11132. result.FeeItems.Select(x =>
  11133. {
  11134. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  11135. if (feeInfos.Any()) x.Infos = feeInfos;
  11136. return x;
  11137. }
  11138. )
  11139. .OrderBy(x => x.Index)
  11140. .ToList();
  11141. }
  11142. return Ok(JsonView(result));
  11143. }
  11144. /// <summary>
  11145. /// 团组模块 - 出入境费用报价表 - Info
  11146. /// </summary>
  11147. /// <returns></returns>
  11148. [HttpPost]
  11149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11150. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  11151. {
  11152. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  11153. if (!info.Rates.Any())
  11154. {
  11155. var rates = await GeneralMethod.EnterExitCostInitRate();
  11156. info.Rates = rates.ToArray();
  11157. }
  11158. return Ok(JsonView(info));
  11159. }
  11160. /// <summary>
  11161. /// 团组模块 - 出入境费用报价表 - OP
  11162. /// </summary>
  11163. /// <returns></returns>
  11164. [HttpPost]
  11165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11166. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  11167. {
  11168. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  11169. }
  11170. /// <summary>
  11171. /// 团组模块 - 出入境费用报价表 - 删除 项
  11172. /// </summary>
  11173. /// <returns></returns>
  11174. [HttpPost]
  11175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11176. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  11177. {
  11178. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11179. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11180. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  11181. }
  11182. /// <summary>
  11183. /// 团组模块 - 出入境费用报价表 - 导出
  11184. /// </summary>
  11185. /// <returns></returns>
  11186. [HttpPost]
  11187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11188. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  11189. {
  11190. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11191. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11192. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  11193. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  11194. var rates = info.Rates;
  11195. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  11196. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  11197. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  11198. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  11199. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  11200. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  11201. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1560); //邀请函发放时间
  11202. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1561); //公务活动
  11203. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1562); //签证+保险
  11204. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1563); //服务费
  11205. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1564); //公杂费
  11206. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1565); //税费
  11207. //获取模板
  11208. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  11209. var designer = new WorkbookDesigner();
  11210. designer.Workbook = new Workbook(tempPath);
  11211. designer.SetDataSource("QuoteName", info.Name);
  11212. designer.SetDataSource("CompanyTitle", "公司名称");
  11213. designer.SetDataSource("CompanyLabel", "");
  11214. #region 国际旅费
  11215. designer.SetDataSource("IntTravelTitle", intTravelCosts.ItemName);
  11216. if (intTravelCosts.Infos.Any())
  11217. {
  11218. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  11219. StringBuilder label = new StringBuilder();
  11220. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  11221. if (infos.Any())
  11222. {
  11223. label.Append(infos.Sum(x => x.PplNum));
  11224. label.Append("人全程机票:");
  11225. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  11226. label.AppendLine("元");
  11227. }
  11228. foreach (var item in intTravelCosts.Infos)
  11229. {
  11230. label.Append(item.FeeName);
  11231. label.Append(":");
  11232. label.Append(item.UnitPrice.TruncDecimals(2));
  11233. label.Append("元/人*");
  11234. label.Append(item.PplNum);
  11235. label.AppendLine("人");
  11236. }
  11237. if (label.HasValue())
  11238. {
  11239. label.Append("\r\n以上小计:");
  11240. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  11241. label.Append("元");
  11242. }
  11243. designer.SetDataSource("IntTravelLabel", label.ToString());
  11244. }
  11245. #endregion
  11246. #region 住宿费
  11247. designer.SetDataSource("AccomTitle", accomCosts.ItemName);
  11248. if (accomCosts.Infos.Any())
  11249. {
  11250. string currencyName = string.Empty;
  11251. decimal rate = 1.0000M;
  11252. StringBuilder label = new StringBuilder();
  11253. label.AppendLine("全程五星酒店,每人1间房");
  11254. foreach (var item in accomCosts.Infos)
  11255. {
  11256. string hotelName = string.Empty;
  11257. if (item.FeeName.Contains("-"))
  11258. {
  11259. var feeName = item.FeeName.Split('-');
  11260. hotelName = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  11261. }
  11262. else hotelName = $"\r\n{item.FeeName}:";
  11263. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  11264. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  11265. rate = rateInfo?.Rate ?? 1.0000M;
  11266. label.Append(hotelName);
  11267. label.Append(item.UnitPrice.TruncDecimals(2));
  11268. label.Append(currencyName);
  11269. label.Append("/间/晚*");
  11270. label.Append(item.Quantity.ToString("#0"));
  11271. label.AppendLine("人");
  11272. }
  11273. if (label.HasValue())
  11274. {
  11275. label.Append("\r\n以上小计:");
  11276. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  11277. label.Append("元(");
  11278. label.Append(currencyName);
  11279. label.Append("汇率:");
  11280. label.Append(rate.TruncDecimals(4));
  11281. label.Append(")");
  11282. }
  11283. designer.SetDataSource("AccomLabel", label.ToString());
  11284. }
  11285. #endregion
  11286. #region 餐饮费
  11287. designer.SetDataSource("MealTitle", mealCosts.ItemName);
  11288. if (mealCosts.Infos.Any())
  11289. {
  11290. string currencyName = string.Empty;
  11291. decimal rate = 1.0000M;
  11292. StringBuilder label = new StringBuilder();
  11293. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  11294. foreach (var item in mealCosts.Infos)
  11295. {
  11296. string name = string.Empty;
  11297. if (item.FeeName.Contains("-"))
  11298. {
  11299. var feeName = item.FeeName.Split('-');
  11300. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  11301. }
  11302. else name = $"\r\n{item.FeeName}:";
  11303. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  11304. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  11305. rate = rateInfo?.Rate ?? 1.0000M;
  11306. label.Append(name);
  11307. label.Append(item.UnitPrice.TruncDecimals(2));
  11308. label.Append(currencyName);
  11309. label.Append("/天*");
  11310. label.Append(item.Quantity.ToString("#0"));
  11311. label.Append("*");
  11312. label.Append(item.PplNum);
  11313. label.Append("人\r\n");
  11314. }
  11315. if (label.HasValue())
  11316. {
  11317. label.Append("\r\n以上小计:");
  11318. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  11319. label.Append("元\r\n(");
  11320. label.Append("汇率:");
  11321. label.Append(rate.TruncDecimals(4));
  11322. label.Append(")");
  11323. }
  11324. designer.SetDataSource("MealLabel", label.ToString());
  11325. }
  11326. #endregion
  11327. #region 车辆安排
  11328. designer.SetDataSource("VehArrangeTitle", vehArranges.ItemName);
  11329. if (vehArranges.Infos.Any())
  11330. {
  11331. string currencyName = string.Empty;
  11332. //decimal rate = 1.0000M;
  11333. StringBuilder label = new StringBuilder();
  11334. foreach (var item in vehArranges.Infos)
  11335. {
  11336. label.Append(item.Remark);
  11337. label.AppendLine();
  11338. label.AppendLine();
  11339. label.Append(item.FeeName);
  11340. label.Append("\r\n\r\n费用:");
  11341. label.Append(item.FeeName);
  11342. label.Append(item.TotalAmt.TruncDecimals(2));
  11343. }
  11344. designer.SetDataSource("VehArrangeLabel", label.ToString());
  11345. }
  11346. #endregion
  11347. #region 邀请函发放对象
  11348. designer.SetDataSource("InviteToTitle", inviteTo.ItemName);
  11349. #endregion
  11350. designer.Process();
  11351. //文件名
  11352. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  11353. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  11354. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  11355. return Ok(JsonView(true, "成功", url));
  11356. }
  11357. #endregion
  11358. #region 签证费用录入
  11359. /// <summary>
  11360. /// 根据diid查询签证费用列表
  11361. /// </summary>
  11362. /// <param name="dto"></param>
  11363. /// <returns></returns>
  11364. [HttpPost]
  11365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11366. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  11367. {
  11368. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  11369. if (groupData.Code != 0)
  11370. {
  11371. return Ok(JsonView(false, groupData.Msg));
  11372. }
  11373. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11374. }
  11375. /// <summary>
  11376. /// 根据签证费用Id查询单条数据及c表数据
  11377. /// </summary>
  11378. /// <param name="dto"></param>
  11379. /// <returns></returns>
  11380. [HttpPost]
  11381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11382. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  11383. {
  11384. Result groupData = await _visaPriceRep.PostVisaById(dto);
  11385. if (groupData.Code != 0)
  11386. {
  11387. return Ok(JsonView(false, groupData.Msg));
  11388. }
  11389. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11390. }
  11391. /// <summary>
  11392. /// 签证费用删除
  11393. /// </summary>
  11394. /// <param name="dto"></param>
  11395. /// <returns></returns>
  11396. [HttpPost]
  11397. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11398. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  11399. {
  11400. _sqlSugar.BeginTran();
  11401. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  11402. if (!res)
  11403. {
  11404. _sqlSugar.RollbackTran();
  11405. return Ok(JsonView(false, "删除失败"));
  11406. }
  11407. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  11408. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  11409. .SetColumns(a => new Grp_CreditCardPayment()
  11410. {
  11411. IsDel = 1,
  11412. DeleteUserId = dto.DeleteUserId,
  11413. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11414. })
  11415. .ExecuteCommand();
  11416. if (resSub < 1)
  11417. {
  11418. _sqlSugar.RollbackTran();
  11419. return Ok(JsonView(false, "删除失败"));
  11420. }
  11421. _sqlSugar.CommitTran();
  11422. return Ok(JsonView(true, "删除成功!"));
  11423. }
  11424. /// <summary>
  11425. /// 签证费用录入下拉框初始化
  11426. /// </summary>
  11427. /// <returns></returns>
  11428. [HttpPost]
  11429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11430. public async Task<IActionResult> VisaPriceAddSelect()
  11431. {
  11432. //支付方式
  11433. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  11434. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  11435. //币种
  11436. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  11437. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  11438. //乘客类型
  11439. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  11440. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  11441. //卡类型
  11442. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  11443. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  11444. //代办费类型
  11445. var agencyFeeTypeData = new List<dynamic>() {
  11446. new { id = 0 , Text = "未选择" },
  11447. new { id = 1 , Text = "小公务" },
  11448. new { id = 2 , Text = "大公务" },
  11449. };
  11450. //签证费用标准国家Data
  11451. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  11452. var data = new
  11453. {
  11454. Payment = _Payment,
  11455. CurrencyList = _CurrencyList,
  11456. PassengerType = _PassengerType,
  11457. BankCard = _BankCard,
  11458. AgencyFeeType = agencyFeeTypeData,
  11459. CountryFeeData = visaCountryFeeData
  11460. };
  11461. return Ok(JsonView(true, "查询成功!", data));
  11462. }
  11463. /// <summary>
  11464. /// 签证费用录入操作(Status:1.新增,2.修改)
  11465. /// </summary>
  11466. /// <param name="dto"></param>
  11467. /// <returns></returns>
  11468. [HttpPost]
  11469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11470. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  11471. {
  11472. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  11473. if (groupData.Code != 0)
  11474. {
  11475. return Ok(JsonView(false, groupData.Msg));
  11476. }
  11477. #region 应用推送
  11478. try
  11479. {
  11480. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11481. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11482. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11483. //2024-10-21 新增LZ UID
  11484. var userIds = new List<int>() { 21 };
  11485. string title = $"系统通知";
  11486. string content = "";
  11487. var diId = dto.DiId;
  11488. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11489. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11490. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  11491. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  11492. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11493. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  11494. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  11495. }
  11496. catch (Exception ex)
  11497. {
  11498. }
  11499. #endregion
  11500. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11501. }
  11502. #endregion
  11503. #region 签证提成录入
  11504. /// <summary>
  11505. /// 签证提成录入
  11506. /// 基础数据
  11507. /// </summary>
  11508. /// <returns></returns>
  11509. [HttpGet]
  11510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11511. public async Task<IActionResult> VisaCommissionInit()
  11512. {
  11513. return Ok(await _visaCommissionRep.Init());
  11514. }
  11515. /// <summary>
  11516. /// 签证提成录入
  11517. /// Item
  11518. /// </summary>
  11519. /// <param name="_dto"></param>
  11520. /// <returns></returns>
  11521. [HttpPost]
  11522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11523. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  11524. {
  11525. var validator = new VisaCommissionItemDtoValidator();
  11526. var validatorRes = await validator.ValidateAsync(_dto);
  11527. if (!validatorRes.IsValid)
  11528. {
  11529. StringBuilder sb = new StringBuilder();
  11530. foreach (var item in validatorRes.Errors)
  11531. {
  11532. sb.AppendLine(item.ErrorMessage);
  11533. }
  11534. return Ok(JsonView(false, sb.ToString()));
  11535. }
  11536. return Ok(await _visaCommissionRep.Item(_dto));
  11537. }
  11538. /// <summary>
  11539. /// 签证提成录入
  11540. /// Save
  11541. /// </summary>
  11542. /// <param name="_dto"></param>
  11543. /// <returns></returns>
  11544. [HttpPost]
  11545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11546. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  11547. {
  11548. //参数验证
  11549. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  11550. foreach (var item in _dto.Items)
  11551. {
  11552. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  11553. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  11554. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  11555. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  11556. }
  11557. return Ok(await _visaCommissionRep.Save(_dto));
  11558. }
  11559. /// <summary>
  11560. /// 签证提成录入
  11561. /// Create
  11562. /// </summary>
  11563. /// <param name="_dto"></param>
  11564. /// <returns></returns>
  11565. [HttpPost]
  11566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11567. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  11568. {
  11569. var validator = new VisaCommissionCreateDtoValidator();
  11570. var validatorRes = await validator.ValidateAsync(_dto);
  11571. if (!validatorRes.IsValid)
  11572. {
  11573. StringBuilder sb = new StringBuilder();
  11574. foreach (var item in validatorRes.Errors)
  11575. {
  11576. sb.AppendLine(item.ErrorMessage);
  11577. }
  11578. return Ok(JsonView(false, sb.ToString()));
  11579. }
  11580. return Ok(await _visaCommissionRep.Create(_dto));
  11581. }
  11582. /// <summary>
  11583. /// 签证提成录入
  11584. /// Put(编辑)
  11585. /// </summary>
  11586. /// <param name="id"></param>
  11587. /// <param name="_dto"></param>
  11588. /// <returns></returns>
  11589. [HttpPut]
  11590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11591. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  11592. {
  11593. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  11594. var validator = new VisaCommissionCreateDtoValidator();
  11595. var validatorRes = await validator.ValidateAsync(_dto);
  11596. if (!validatorRes.IsValid)
  11597. {
  11598. StringBuilder sb = new StringBuilder();
  11599. foreach (var item in validatorRes.Errors)
  11600. {
  11601. sb.AppendLine(item.ErrorMessage);
  11602. }
  11603. return Ok(JsonView(false, sb.ToString()));
  11604. }
  11605. return Ok(await _visaCommissionRep.Edit(id, _dto));
  11606. }
  11607. /// <summary>
  11608. /// 签证提成录入
  11609. /// Del
  11610. /// </summary>
  11611. /// <param name="id"></param>
  11612. /// <param name="currUserId"></param>
  11613. /// <returns></returns>
  11614. [HttpPost]
  11615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11616. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  11617. {
  11618. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  11619. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  11620. return Ok(await _visaCommissionRep.Del(id, currUserId));
  11621. }
  11622. #endregion
  11623. #region op费用录入
  11624. /// <summary>
  11625. /// 根据diid查询op费用列表
  11626. /// </summary>
  11627. /// <param name="dto"></param>
  11628. /// <returns></returns>
  11629. [HttpPost]
  11630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11631. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  11632. {
  11633. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  11634. if (groupData.Code != 0)
  11635. {
  11636. return Ok(JsonView(false, groupData.Msg));
  11637. }
  11638. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11639. }
  11640. /// <summary>
  11641. /// 根据op费用Id查询单条数据及c表数据
  11642. /// </summary>
  11643. /// <param name="dto"></param>
  11644. /// <returns></returns>
  11645. [HttpPost]
  11646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11647. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  11648. {
  11649. try
  11650. {
  11651. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  11652. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  11653. var data = new
  11654. {
  11655. CarTouristGuideGround = _groupData,
  11656. CreditCardPayment = _creditCardPayment
  11657. };
  11658. return Ok(JsonView(true, "查询成功!", data));
  11659. }
  11660. catch (Exception ex)
  11661. {
  11662. return Ok(JsonView(false, "程序错误!"));
  11663. }
  11664. }
  11665. /// <summary>
  11666. /// op费用删除
  11667. /// </summary>
  11668. /// <param name="dto"></param>
  11669. /// <returns></returns>
  11670. [HttpPost]
  11671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11672. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  11673. {
  11674. try
  11675. {
  11676. _sqlSugar.BeginTran();
  11677. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  11678. if (!res)
  11679. {
  11680. return Ok(JsonView(false, "删除失败"));
  11681. }
  11682. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  11683. {
  11684. IsDel = 1,
  11685. DeleteUserId = dto.DeleteUserId,
  11686. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11687. }).ExecuteCommandAsync();
  11688. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  11689. {
  11690. IsDel = 1,
  11691. DeleteUserId = dto.DeleteUserId,
  11692. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11693. }).ExecuteCommandAsync();
  11694. #region 删除超支相关数据
  11695. //删除导入的超支数据
  11696. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  11697. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  11698. {
  11699. IsDel = 1,
  11700. DeleteUserId = dto.DeleteUserId,
  11701. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11702. }).ExecuteCommand();
  11703. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  11704. {
  11705. IsDel = 1,
  11706. DeleteUserId = dto.DeleteUserId,
  11707. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11708. }).ExecuteCommand();
  11709. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  11710. {
  11711. IsDel = 1,
  11712. DeleteUserId = dto.DeleteUserId,
  11713. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11714. }).ExecuteCommand();
  11715. #endregion
  11716. _sqlSugar.CommitTran();
  11717. return Ok(JsonView(true, "删除成功!"));
  11718. }
  11719. catch (Exception ex)
  11720. {
  11721. _sqlSugar.RollbackTran();
  11722. return Ok(JsonView(false, "程序错误!" + ex.Message));
  11723. }
  11724. }
  11725. /// <summary>
  11726. /// op费用录入操作(Status:1.新增,2.修改)
  11727. /// </summary>
  11728. /// <param name="dto"></param>
  11729. /// <returns></returns>
  11730. [HttpPost]
  11731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11732. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  11733. {
  11734. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  11735. if (groupData.Code != 0)
  11736. {
  11737. return Ok(JsonView(false, groupData.Msg));
  11738. }
  11739. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11740. }
  11741. /// <summary>
  11742. /// 填写费用详细页面初始化绑定
  11743. /// </summary>
  11744. /// <param name="dto"></param>
  11745. /// <returns></returns>
  11746. [HttpPost]
  11747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11748. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  11749. {
  11750. try
  11751. {
  11752. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  11753. if (groupData.Code != 0)
  11754. {
  11755. return Ok(JsonView(false, groupData.Msg));
  11756. }
  11757. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11758. }
  11759. catch (Exception ex)
  11760. {
  11761. return Ok(JsonView(false, ex.Message));
  11762. }
  11763. }
  11764. /// <summary>
  11765. /// 根据op费用Id查询详细数据
  11766. /// </summary>
  11767. /// <param name="dto"></param>
  11768. /// <returns></returns>
  11769. [HttpPost]
  11770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11771. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  11772. {
  11773. try
  11774. {
  11775. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  11776. if (groupData.Code != 0)
  11777. {
  11778. return Ok(JsonView(false, groupData.Msg));
  11779. }
  11780. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11781. }
  11782. catch (Exception ex)
  11783. {
  11784. return Ok(JsonView(false, ex.Message));
  11785. }
  11786. }
  11787. /// <summary>
  11788. /// OP费用录入填写详情
  11789. /// </summary>
  11790. /// <param name="dto"></param>
  11791. /// <returns></returns>
  11792. [HttpPost]
  11793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11794. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  11795. {
  11796. try
  11797. {
  11798. #region 参数校验
  11799. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  11800. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  11801. if (di == null) return Ok(JsonView(false, "团组错误!"));
  11802. #endregion
  11803. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  11804. if (groupData.Code != 0)
  11805. {
  11806. return Ok(JsonView(false, groupData.Msg));
  11807. }
  11808. //自动审核
  11809. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  11810. #region 应用推送
  11811. try
  11812. {
  11813. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11814. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11815. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11816. //2024-10-21 新增LZ UID
  11817. var userIds = new List<int>() { 21 };
  11818. string title = $"系统通知";
  11819. var diId = dto.DiId;
  11820. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11821. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11822. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  11823. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11824. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  11825. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  11826. }
  11827. catch (Exception ex)
  11828. {
  11829. }
  11830. #endregion
  11831. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11832. }
  11833. catch (Exception ex)
  11834. {
  11835. return Ok(JsonView(false, ex.Message));
  11836. }
  11837. }
  11838. /// <summary>
  11839. /// 获取三公详细所有城市
  11840. /// </summary>
  11841. /// <returns></returns>
  11842. [HttpGet]
  11843. public IActionResult OpCarCityResult()
  11844. {
  11845. var jw = JsonView(false);
  11846. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  11847. {
  11848. x.Id,
  11849. x.Country,
  11850. x.City,
  11851. }).ToList();
  11852. if (data.Count > 0)
  11853. {
  11854. jw = JsonView(true, "获取成功!", data);
  11855. }
  11856. else
  11857. {
  11858. jw.Msg = "城市数据为空!";
  11859. jw.Data = new string[0];
  11860. }
  11861. return Ok(jw);
  11862. }
  11863. /// <summary>
  11864. /// 导出地接费用明细
  11865. /// </summary>
  11866. /// <param name="dto"></param>
  11867. /// <returns></returns>
  11868. [HttpPost]
  11869. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  11870. {
  11871. var jw = JsonView(false);
  11872. if (dto.Diid < 1)
  11873. {
  11874. jw.Msg = "请输入正确的diid!";
  11875. return Ok(jw);
  11876. }
  11877. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11878. if (group == null)
  11879. {
  11880. jw.Msg = "未找到团组信息!";
  11881. return Ok(jw);
  11882. }
  11883. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11884. if (localGuideArr.Count == 0)
  11885. {
  11886. jw.Msg = "该团组暂无地接信息!";
  11887. return Ok(jw);
  11888. }
  11889. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  11890. var overspendSoure = new Dictionary<int, int>
  11891. {
  11892. { 91, 982 }, //车
  11893. { 92 , 1059} ,//导游
  11894. { 994 , 1073}, //翻译
  11895. { 988 , 1074 }, //早餐
  11896. { 93 , 1075 }, //午餐
  11897. { 989 , 1076 }, //晚餐
  11898. };
  11899. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  11900. foreach (var groupArr in localGroup)
  11901. {
  11902. var keyValue = groupArr.Key;
  11903. if (int.TryParse(keyValue, out int cityid))
  11904. {
  11905. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  11906. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  11907. }
  11908. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  11909. foreach (var item in groupArr)
  11910. {
  11911. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  11912. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  11913. new Grp_CarTouristGuideGroundReservationsContentExtend
  11914. {
  11915. Count = a.Count,
  11916. CreateTime = a.CreateTime,
  11917. CreateUserId = a.CreateUserId,
  11918. CTGGRId = a.CTGGRId,
  11919. Currency = a.Currency,
  11920. DatePrice = a.DatePrice,
  11921. DeleteTime = a.DeleteTime,
  11922. DeleteUserId = a.DeleteUserId,
  11923. DiId = a.DiId,
  11924. Id = a.Id,
  11925. IsDel = a.IsDel,
  11926. Price = a.Price,
  11927. PriceContent = a.PriceContent,
  11928. Remark = a.Remark,
  11929. SId = a.SId,
  11930. SidName = b.Name,
  11931. Units = a.Units,
  11932. }
  11933. ).ToList();
  11934. if (content.Count > 0)
  11935. {
  11936. contentArr.Add(content);
  11937. }
  11938. }
  11939. //open excel
  11940. //set excel
  11941. //save excel
  11942. try
  11943. {
  11944. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  11945. IWorkbook workbook;
  11946. if (Path.GetExtension(filePath).ToLower() == ".xls")
  11947. {
  11948. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11949. }
  11950. else
  11951. {
  11952. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11953. }
  11954. ISheet sheet = workbook.GetSheetAt(0);
  11955. var rowStartIndex = 2;
  11956. var clounmCount = 10;
  11957. var initStyleRow = sheet.GetRow(2);
  11958. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  11959. //var overspendArrDetail =
  11960. var existsId = new List<CarCompare>();
  11961. var lastElem = arr.Last();
  11962. var thisSid = -1;
  11963. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  11964. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  11965. {
  11966. Name = "未知币种!",
  11967. Remark = "未知币种!",
  11968. };
  11969. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  11970. Action cloneRowFn = () =>
  11971. {
  11972. rowStartIndex++;
  11973. var cloneRow = sheet.CreateRow(rowStartIndex);
  11974. // 复制样式
  11975. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  11976. {
  11977. ICell sourceCell = initStyleRow.GetCell(i);
  11978. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  11979. // 确保单元格存在样式
  11980. if (sourceCell.CellStyle != null)
  11981. {
  11982. targetCell.CellStyle = sourceCell.CellStyle;
  11983. }
  11984. }
  11985. };
  11986. var mergeRow = () =>
  11987. {
  11988. for (int i = 2; i < sheet.LastRowNum; i++)
  11989. {
  11990. var row = sheet.GetRow(i);
  11991. var cellFirst = row.GetCell(0);
  11992. var thisIndex = i + 1;
  11993. while (thisIndex < sheet.LastRowNum)
  11994. {
  11995. var nextRow = sheet.GetRow(thisIndex);
  11996. var nextCellFirst = nextRow.GetCell(0);
  11997. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  11998. {
  11999. thisIndex++;
  12000. }
  12001. else
  12002. {
  12003. break;
  12004. }
  12005. }
  12006. thisIndex--;
  12007. if (thisIndex != i)
  12008. {
  12009. //合并row
  12010. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12011. i, // 起始行索引(0-based)
  12012. thisIndex, // 结束行索引(0-based)
  12013. 0, // 起始列索引(0-based)
  12014. 0 // 结束列索引(0-based)
  12015. );
  12016. sheet.AddMergedRegion(cellRangeAddress);
  12017. i = thisIndex;
  12018. }
  12019. }
  12020. };
  12021. var chaoshiNumber = 0;
  12022. var totalNumber = 0.00M;
  12023. string lastStr = "";
  12024. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  12025. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  12026. {
  12027. b.IsAuditGM,
  12028. x.Id,
  12029. x.Area,
  12030. b.PayPercentage,
  12031. b.PayMoney,
  12032. }).ToList();
  12033. string yesPayment = "", noPayment = "";
  12034. foreach (var item in queryCarArrByCityAndDiid)
  12035. {
  12036. if (item.IsAuditGM == 1)
  12037. {
  12038. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12039. }
  12040. else
  12041. {
  12042. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12043. }
  12044. }
  12045. lastStr = yesPayment + noPayment;
  12046. foreach (var item in arr)
  12047. {
  12048. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  12049. {
  12050. if (thisSid != item.SId)
  12051. {
  12052. if (thisSid == -1)
  12053. {
  12054. thisSid = item.SId;
  12055. }
  12056. else
  12057. {
  12058. //合并小计行
  12059. //创建合并区域的实例
  12060. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12061. rowStartIndex, // 起始行索引(0-based)
  12062. rowStartIndex, // 结束行索引(0-based)
  12063. 0, // 起始列索引(0-based)
  12064. 3 // 结束列索引(0-based)
  12065. );
  12066. sheet.AddMergedRegion(cellRangeAddress);
  12067. var CellStyle = workbook.CreateCellStyle();
  12068. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12069. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  12070. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  12071. for (int i = 0; i <= clounmCount; i++)
  12072. {
  12073. if (i > 6)
  12074. {
  12075. var CellStyle1 = workbook.CreateCellStyle();
  12076. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12077. IFont Font = workbook.CreateFont(); // 创建字体
  12078. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  12079. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12080. CellStyle1.SetFont(Font);
  12081. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  12082. }
  12083. else
  12084. {
  12085. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  12086. }
  12087. }
  12088. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  12089. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  12090. //超时合计
  12091. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  12092. //超时数
  12093. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  12094. //超时合计费用
  12095. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  12096. thisSid = item.SId;
  12097. cloneRowFn();
  12098. chaoshiNumber = 0;
  12099. totalNumber = 0;
  12100. }
  12101. }
  12102. IRow row = sheet.GetRow(rowStartIndex);
  12103. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12104. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  12105. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  12106. if (isOpenOverspendSoure)
  12107. {
  12108. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12109. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  12110. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  12111. }
  12112. for (int i = 0; i <= clounmCount; i++)
  12113. {
  12114. var cell = row.GetCell(i);
  12115. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  12116. if (cell == null)
  12117. {
  12118. cell = row.CreateCell(i);
  12119. }
  12120. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  12121. fontRed.CloneStyleFrom(cell.CellStyle);
  12122. IFont Font = workbook.CreateFont(); // 创建字体
  12123. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  12124. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12125. fontRed.SetFont(Font);
  12126. byte[] rgb = new byte[3] { 255, 242, 204 };
  12127. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  12128. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  12129. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  12130. if (workbook is XSSFWorkbook)
  12131. {
  12132. BackgroundColor255_242_204.FillForegroundColor = 0;
  12133. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  12134. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  12135. }
  12136. else
  12137. {
  12138. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  12139. }
  12140. if (i == 1 || i > 6)
  12141. {
  12142. if (i > 6)
  12143. {
  12144. fontRed.FillForegroundColor = 0;
  12145. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  12146. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  12147. }
  12148. cell.CellStyle = fontRed;
  12149. }
  12150. if (i > 2 && i < 7)
  12151. {
  12152. cell.CellStyle = BackgroundColor255_242_204;
  12153. }
  12154. cell.SetCellValue(setCellValue); //写入单元格
  12155. }
  12156. if (overspendSoure.ContainsKey(thisSid))
  12157. {
  12158. var overspendId = overspendSoure[thisSid];
  12159. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12160. }
  12161. cloneRowFn();
  12162. existsId.Add(new CarCompare
  12163. {
  12164. DataPrice = item.DatePrice.ObjToDate(),
  12165. Sid = item.SId
  12166. });
  12167. }
  12168. if (item.Equals(lastElem))
  12169. {
  12170. //合并小计行
  12171. //创建合并区域的实例
  12172. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12173. rowStartIndex, // 起始行索引(0-based)
  12174. rowStartIndex, // 结束行索引(0-based)
  12175. 0, // 起始列索引(0-based)
  12176. 3 // 结束列索引(0-based)
  12177. );
  12178. sheet.AddMergedRegion(cellRangeAddress);
  12179. var CellStyle = workbook.CreateCellStyle();
  12180. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12181. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  12182. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  12183. for (int i = 0; i <= clounmCount; i++)
  12184. {
  12185. if (i > 6)
  12186. {
  12187. var CellStyle1 = workbook.CreateCellStyle();
  12188. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12189. IFont Font = workbook.CreateFont(); // 创建字体
  12190. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  12191. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12192. CellStyle1.SetFont(Font);
  12193. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  12194. }
  12195. else
  12196. {
  12197. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  12198. }
  12199. }
  12200. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  12201. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  12202. //超时合计
  12203. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  12204. //超时数
  12205. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  12206. //超时合计费用
  12207. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  12208. cloneRowFn();
  12209. // 创建合并区域的实例
  12210. cellRangeAddress = new CellRangeAddress(
  12211. rowStartIndex, // 起始行索引(0-based)
  12212. rowStartIndex, // 结束行索引(0-based)
  12213. 0, // 起始列索引(0-based)
  12214. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  12215. );
  12216. // 添加合并区域
  12217. sheet.AddMergedRegion(cellRangeAddress);
  12218. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  12219. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  12220. }
  12221. }
  12222. mergeRow();
  12223. // 保存修改后的Excel文件到新文件
  12224. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  12225. // new FileStream(newFilePath, FileMode.CreateNew)
  12226. using (var stream = new MemoryStream())
  12227. {
  12228. workbook.Write(stream, true);
  12229. stream.Flush();
  12230. stream.Seek(0, SeekOrigin.Begin);
  12231. MemoryStream memoryStream = new MemoryStream();
  12232. stream.CopyTo(memoryStream);
  12233. memoryStream.Seek(0, SeekOrigin.Begin);
  12234. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  12235. }
  12236. workbook.Close();
  12237. workbook.Dispose();
  12238. }
  12239. catch (Exception ex)
  12240. {
  12241. jw.Msg = "出现异常!" + ex.Message;
  12242. return Ok(jw);
  12243. }
  12244. }
  12245. if (Zips.Count > 0)
  12246. {
  12247. IOOperatorHelper io = new IOOperatorHelper();
  12248. var byts = io.ConvertZipStream(Zips);
  12249. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  12250. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  12251. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  12252. }
  12253. else
  12254. {
  12255. jw.Msg = "暂无生成文件!";
  12256. }
  12257. return Ok(jw);
  12258. }
  12259. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  12260. {
  12261. string outStr = string.Empty;
  12262. switch (i)
  12263. {
  12264. case 0:
  12265. outStr = arr[0].SidName;
  12266. break;
  12267. case 1:
  12268. outStr = arr[0].DataPriceStr;
  12269. break;
  12270. case 2:
  12271. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  12272. break;
  12273. case 4:
  12274. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  12275. break;
  12276. case 7:
  12277. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12278. {
  12279. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  12280. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  12281. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  12282. }
  12283. break;
  12284. case 8:
  12285. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12286. {
  12287. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  12288. }
  12289. break;
  12290. case 9:
  12291. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12292. {
  12293. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  12294. }
  12295. break;
  12296. case 10:
  12297. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12298. {
  12299. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  12300. }
  12301. break;
  12302. }
  12303. return outStr;
  12304. }
  12305. #region OP行程单
  12306. /// <summary>
  12307. /// OP行程单初始化
  12308. /// </summary>
  12309. /// <param name="dto"></param>
  12310. /// <returns></returns>
  12311. [HttpPost]
  12312. public IActionResult InitOpTravel(InitOpTravelDto dto)
  12313. {
  12314. var jw = JsonView(false);
  12315. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  12316. var group = groupList.First();
  12317. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  12318. if (group == null)
  12319. {
  12320. jw.Msg = "暂无团组!";
  12321. return Ok(jw);
  12322. }
  12323. group = groupList.Find(x => x.Id == diid);
  12324. if (group == null)
  12325. {
  12326. jw.Msg = "请输入正确的团组ID!";
  12327. return Ok(jw);
  12328. }
  12329. string city = string.Empty;
  12330. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  12331. if (blackCode.Count > 0)
  12332. {
  12333. var black = blackCode.First();
  12334. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  12335. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  12336. if (blackSp.Length > 0)
  12337. {
  12338. try
  12339. {
  12340. var cityArrCode = new List<string>(20);
  12341. foreach (var item in blackSp)
  12342. {
  12343. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  12344. var IndexSelect = itemSp[2];
  12345. var cityArrCodeLength = cityArrCode.Count - 1;
  12346. var startCity = IndexSelect.Substring(0, 3);
  12347. if (cityArrCodeLength > 0)
  12348. {
  12349. var arrEndCity = cityArrCode[cityArrCodeLength];
  12350. if (arrEndCity != startCity)
  12351. {
  12352. cityArrCode.Add(startCity.ToUpper());
  12353. }
  12354. }
  12355. else
  12356. {
  12357. cityArrCode.Add(startCity.ToUpper());
  12358. }
  12359. var endCity = IndexSelect.Substring(3, 3);
  12360. cityArrCode.Add(endCity.ToUpper());
  12361. }
  12362. var cityThree = string.Empty;
  12363. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  12364. cityThree = cityThree.TrimEnd(',');
  12365. if (string.IsNullOrWhiteSpace(cityThree))
  12366. {
  12367. throw new
  12368. Exception("error");
  12369. }
  12370. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  12371. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  12372. foreach (var item in cityArrCode)
  12373. {
  12374. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  12375. if (find != null)
  12376. {
  12377. city += find.City + "/";
  12378. }
  12379. else
  12380. {
  12381. city += item + "三字码未收入/";
  12382. }
  12383. }
  12384. city = city.TrimEnd('/');
  12385. }
  12386. catch (Exception e)
  12387. {
  12388. city = "黑屏代码格式不正确!";
  12389. }
  12390. }
  12391. }
  12392. else
  12393. {
  12394. city = "未录入黑屏代码";
  12395. }
  12396. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  12397. {
  12398. Date = x.Date,
  12399. Days = x.Days,
  12400. Diffgroup = x.Diffgroup,
  12401. Diid = x.Diid,
  12402. Traffic_First = x.Traffic_First,
  12403. Traffic_Second = x.Traffic_Second,
  12404. Trip = x.Trip,
  12405. WeekDay = x.WeekDay,
  12406. Id = x.Id
  12407. }).ToList();
  12408. jw.Data = new
  12409. {
  12410. groupList = groupList.Select(x => new
  12411. {
  12412. x.Id,
  12413. x.TeamName,
  12414. x.TourCode
  12415. }).ToList(),
  12416. groupInfo = new
  12417. {
  12418. group.VisitDays,
  12419. group.TourCode,
  12420. group.VisitPNumber,
  12421. group.TeamName,
  12422. city
  12423. },
  12424. OpTravelList
  12425. };
  12426. jw.Code = 200;
  12427. jw.Msg = "操作成功!";
  12428. return Ok(jw);
  12429. }
  12430. /// <summary>
  12431. /// 删除团组行程单
  12432. /// </summary>
  12433. /// <returns></returns>
  12434. [HttpPost]
  12435. public IActionResult DelTravel(DelOpTravelDto dto)
  12436. {
  12437. var jw = JsonView(false);
  12438. if (dto.UserId <= 0 || dto.Diid <= 0)
  12439. {
  12440. jw.Msg = "请输入正确的参数!";
  12441. return Ok(jw);
  12442. }
  12443. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  12444. .SetColumns(x => new Grp_TravelList
  12445. {
  12446. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  12447. DeleteUserId = dto.UserId,
  12448. IsDel = 1,
  12449. }).ExecuteCommand();
  12450. jw = JsonView(true);
  12451. return Ok(jw);
  12452. }
  12453. /// <summary>
  12454. /// 行程单保存
  12455. /// </summary>
  12456. /// <returns></returns>
  12457. [HttpPost]
  12458. public IActionResult TravelSave(TravelSaveDto dto)
  12459. {
  12460. var jw = JsonView(false);
  12461. if (dto.Arr.Count > 0)
  12462. {
  12463. try
  12464. {
  12465. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  12466. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  12467. .ToList();
  12468. _sqlSugar.BeginTran();
  12469. foreach (var item in dto.Arr)
  12470. {
  12471. if (item.Id == 0)
  12472. {
  12473. throw new Exception("请传入正确的Id");
  12474. }
  12475. //比较上一次的差异
  12476. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  12477. if (findTravel != null)
  12478. {
  12479. item.Trip = item.Trip.Replace("[++]", string.Empty);
  12480. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  12481. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  12482. }
  12483. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  12484. .SetColumns(x => new Grp_TravelList
  12485. {
  12486. Trip = item.Trip
  12487. }).ExecuteCommand();
  12488. }
  12489. _sqlSugar.CommitTran();
  12490. jw = JsonView(true);
  12491. }
  12492. catch (Exception ex)
  12493. {
  12494. _sqlSugar.RollbackTran();
  12495. jw.Msg = "程序异常!" + ex.Message;
  12496. }
  12497. }
  12498. else
  12499. {
  12500. jw.Msg = "请传入正确的参数!";
  12501. }
  12502. return Ok(jw);
  12503. }
  12504. private string CheckStr(string original, string changed)
  12505. {
  12506. // 创建diff_match_patch对象
  12507. var dmp = new diff_match_patch();
  12508. // 计算差异
  12509. List<Diff> diffs = dmp.diff_main(original, changed);
  12510. // 清理和合并差异
  12511. dmp.diff_cleanupSemantic(diffs);
  12512. // 使用StringBuilder构建最终的字符串
  12513. StringBuilder finalString = new StringBuilder();
  12514. // 输出差异结果,并构建变动后的字符串
  12515. foreach (Diff diff in diffs)
  12516. {
  12517. switch (diff.operation)
  12518. {
  12519. case Operation.EQUAL:
  12520. // 相等的部分,直接添加到最终字符串
  12521. finalString.Append(diff.text);
  12522. break;
  12523. case Operation.INSERT:
  12524. // 插入的部分,添加标记并添加到最终字符串
  12525. finalString.Append("[++]" + diff.text + "[++]");
  12526. break;
  12527. case Operation.DELETE:
  12528. // 删除的部分,不添加到最终字符串
  12529. //finalString.Append("[++]" + diff.text + "[++]");
  12530. break;
  12531. }
  12532. }
  12533. // 输出变动后的字符串
  12534. return finalString.ToString();
  12535. }
  12536. private class tagContent
  12537. {
  12538. public DateTime Date { get; set; }
  12539. public string StartTag { get; set; }
  12540. public string EndTag { get; set; }
  12541. public string Content { get; set; }
  12542. public static int tagLength { get { return 3; } }
  12543. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  12544. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  12545. public bool IsFinally { get; set; }
  12546. }
  12547. private List<string> ExtractContentBetweenTags(string input, string tag)
  12548. {
  12549. List<string> results = new List<string>();
  12550. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  12551. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  12552. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  12553. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  12554. string[] strValueArr = new string[1];
  12555. foreach (System.Text.RegularExpressions.Match match in matches)
  12556. {
  12557. var strValue = match.Groups[1].Value;
  12558. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  12559. }
  12560. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  12561. return results;
  12562. }
  12563. /// <summary>
  12564. /// 导出行程单
  12565. /// </summary>
  12566. /// <param name="dto"></param>
  12567. /// <returns></returns>
  12568. [HttpPost]
  12569. public IActionResult ExportTravel(ExportTravelDto dto)
  12570. {
  12571. var jw = JsonView(false);
  12572. jw.Data = "";
  12573. int diid = 0;
  12574. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  12575. if (Find == null)
  12576. {
  12577. jw.Msg = "请选择正确的团组!";
  12578. return Ok(jw);
  12579. }
  12580. else
  12581. {
  12582. diid = Find.Id;
  12583. }
  12584. //数据源
  12585. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  12586. DataTable dtBlack = null;
  12587. try
  12588. {
  12589. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  12590. }
  12591. catch (Exception)
  12592. {
  12593. jw.Msg = "机票黑屏代码有误!";
  12594. return Ok(jw);
  12595. }
  12596. string CityStr = string.Empty;
  12597. if (dtBlack.Rows.Count == 0)
  12598. {
  12599. jw.Msg = "机票黑屏代码有误!";
  12600. return Ok(jw);
  12601. }
  12602. else
  12603. {
  12604. foreach (DataRow row in dtBlack.Rows)
  12605. {
  12606. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12607. {
  12608. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  12609. return Ok(jw);
  12610. }
  12611. }
  12612. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  12613. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  12614. }
  12615. // 指定的文字
  12616. var targetTextDic = new Dictionary<string, List<string>>();
  12617. //创建数据源Table
  12618. DataTable dtSource = new DataTable();
  12619. dtSource.Columns.Add("Days", typeof(string));
  12620. dtSource.Columns.Add("Date", typeof(string));
  12621. dtSource.Columns.Add("Week", typeof(string));
  12622. dtSource.Columns.Add("Traffic", typeof(string));
  12623. dtSource.Columns.Add("Trip", typeof(string));
  12624. //获取数据,放到datatable
  12625. foreach (var item in _travelList)
  12626. {
  12627. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  12628. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  12629. .Replace(tagContent.TagFormat.Item2, string.Empty)
  12630. .Replace("[++]", string.Empty);
  12631. DataRow dr = dtSource.NewRow();
  12632. dr["Days"] = item.Days;
  12633. dr["Date"] = item.Date;
  12634. dr["Week"] = item.WeekDay;
  12635. dr["Traffic"] = item.Traffic_First
  12636. + "\r\n"
  12637. + item.Traffic_Second;
  12638. dr["Trip"] = item.Trip;
  12639. dtSource.Rows.Add(dr);
  12640. }
  12641. Dictionary<string, string> dic = new Dictionary<string, string>();
  12642. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  12643. dic.Add("City", CityStr);
  12644. dic.Add("Days", Find.VisitDays.ToString());
  12645. dic.Add("DeleCode", Find.TourCode);
  12646. dic.Add("Pnum", Find.VisitPNumber.ToString());
  12647. //模板路径
  12648. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  12649. //载入模板
  12650. Document doc = null;
  12651. DocumentBuilder builder = null;
  12652. try
  12653. {
  12654. //载入模板
  12655. doc = new Document(tempPath);
  12656. builder = new DocumentBuilder(doc);
  12657. }
  12658. catch (Exception)
  12659. {
  12660. jw.Msg = "模板位置不存在!";
  12661. return Ok(jw);
  12662. }
  12663. foreach (var key in dic.Keys)
  12664. {
  12665. Bookmark bookmark = doc.Range.Bookmarks[key];
  12666. if (bookmark != null)
  12667. {
  12668. builder.MoveToBookmark(key);
  12669. builder.Write(dic[key]);
  12670. }
  12671. }
  12672. //获取word里所有表格
  12673. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12674. //获取所填表格的序数
  12675. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12676. try
  12677. {
  12678. //循环赋值
  12679. for (int i = 0; i < dtSource.Rows.Count; i++)
  12680. {
  12681. builder.MoveToCell(0, i + 1, 0, 0);
  12682. builder.Write(dtSource.Rows[i]["Days"].ToString());
  12683. builder.MoveToCell(0, i + 1, 1, 0);
  12684. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  12685. builder.MoveToCell(0, i + 1, 2, 0);
  12686. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  12687. var trip = dtSource.Rows[i]["Trip"].ToString();
  12688. builder.MoveToCell(0, i + 1, 3, 0);
  12689. builder.Write(trip);
  12690. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  12691. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12692. // 获取特定索引的段落
  12693. Paragraph paragraph = (Paragraph)paragraphs[0];
  12694. Run run = paragraph.Runs[0];
  12695. Aspose.Words.Font font = run.Font;
  12696. font.Name = "黑体";
  12697. //设置双休红色
  12698. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  12699. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12700. paragraph = (Paragraph)paragraphs[1];
  12701. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  12702. {
  12703. run = paragraph.Runs[0];
  12704. font = run.Font;
  12705. font.Color = Color.Red;
  12706. }
  12707. }
  12708. }
  12709. catch (Exception ex)
  12710. {
  12711. }
  12712. //删除多余行
  12713. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  12714. {
  12715. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  12716. }
  12717. var targetTextList = new List<string>();
  12718. // 遍历文档中的表格
  12719. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  12720. {
  12721. foreach (Aspose.Words.Tables.Row row in table.Rows)
  12722. {
  12723. var cellIndex = 0;
  12724. foreach (Cell cell in row.Cells)
  12725. {
  12726. if (cellIndex == 1 && row.Cells.Count == 4)
  12727. {
  12728. foreach (var target in targetTextDic.Keys)
  12729. {
  12730. if (cell.GetText().Contains(target))
  12731. {
  12732. targetTextList = targetTextDic[target];
  12733. break;
  12734. }
  12735. }
  12736. }
  12737. // 遍历单元格中的所有段落
  12738. foreach (Paragraph paragraph in cell.Paragraphs)
  12739. {
  12740. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  12741. List<Run> runs = new List<Run>();
  12742. foreach (Run run in paragraph.Runs)
  12743. {
  12744. runs.Add(run);
  12745. }
  12746. foreach (Run run in runs)
  12747. {
  12748. foreach (var targetText in targetTextList)
  12749. {
  12750. // 检查文字是否包含指定文字
  12751. if (run.Text.Contains(targetText))
  12752. {
  12753. // 将包含的部分设置为红色
  12754. HighlightText(run, targetText, Color.Red);
  12755. }
  12756. }
  12757. }
  12758. }
  12759. cellIndex++;
  12760. }
  12761. }
  12762. }
  12763. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  12764. if (!Directory.Exists(savePath))
  12765. {
  12766. try
  12767. {
  12768. Directory.CreateDirectory(savePath);
  12769. }
  12770. catch
  12771. {
  12772. }
  12773. }
  12774. string path = savePath + Find.TeamName + "出访日程";
  12775. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  12776. try
  12777. {
  12778. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  12779. string postfix = ".docx";
  12780. if (dto.IsPDF == 1)
  12781. {
  12782. saveFormat = Aspose.Words.SaveFormat.Pdf;
  12783. postfix = ".pdf";
  12784. }
  12785. doc.Save(path + postfix, saveFormat);
  12786. jw = JsonView(true, "导出成功", ftpPath + postfix);
  12787. }
  12788. catch (Exception)
  12789. {
  12790. jw = JsonView(false);
  12791. }
  12792. return Ok(jw);
  12793. }
  12794. /// <summary>
  12795. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  12796. /// </summary>
  12797. /// <param name="num"></param>
  12798. /// <returns></returns>
  12799. string GetNum(string num)
  12800. {
  12801. string str = "";
  12802. switch (num)
  12803. {
  12804. case "1":
  12805. str = "一";
  12806. break;
  12807. case "2":
  12808. str = "二";
  12809. break;
  12810. case "3":
  12811. str = "三";
  12812. break;
  12813. case "4":
  12814. str = "四";
  12815. break;
  12816. case "5":
  12817. str = "五";
  12818. break;
  12819. case "6":
  12820. str = "六";
  12821. break;
  12822. case "7":
  12823. str = "七";
  12824. break;
  12825. case "8":
  12826. str = "八";
  12827. break;
  12828. case "9":
  12829. str = "九";
  12830. break;
  12831. case "10":
  12832. str = "十";
  12833. break;
  12834. case "11":
  12835. str = "十一";
  12836. break;
  12837. case "12":
  12838. str = "十二";
  12839. break;
  12840. case "一":
  12841. str = "1";
  12842. break;
  12843. case "二":
  12844. str = "2";
  12845. break;
  12846. case "三":
  12847. str = "3";
  12848. break;
  12849. case "四":
  12850. str = "4";
  12851. break;
  12852. case "五":
  12853. str = "5";
  12854. break;
  12855. case "六":
  12856. str = "6";
  12857. break;
  12858. case "七":
  12859. str = "7";
  12860. break;
  12861. case "八":
  12862. str = "8";
  12863. break;
  12864. case "九":
  12865. str = "9";
  12866. break;
  12867. case "十":
  12868. str = "10";
  12869. break;
  12870. case "十一":
  12871. str = "11";
  12872. break;
  12873. case "十二":
  12874. str = "12";
  12875. break;
  12876. }
  12877. return str;
  12878. }
  12879. // 高亮包含指定文字的部分
  12880. void HighlightText(Run run, string targetText, Color color)
  12881. {
  12882. string text = run.Text;
  12883. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  12884. if (startIndex >= 0)
  12885. {
  12886. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  12887. // 前部分
  12888. if (startIndex > 0)
  12889. {
  12890. Run beforeRun = (Run)run.Clone(true);
  12891. beforeRun.Text = text.Substring(0, startIndex);
  12892. parentParagraph.InsertBefore(beforeRun, run);
  12893. }
  12894. // 匹配部分
  12895. Run matchRun = (Run)run.Clone(true);
  12896. matchRun.Text = text.Substring(startIndex, targetText.Length);
  12897. matchRun.Font.Color = color;
  12898. parentParagraph.InsertBefore(matchRun, run);
  12899. // 后部分
  12900. if (startIndex + targetText.Length < text.Length)
  12901. {
  12902. Run afterRun = (Run)run.Clone(true);
  12903. afterRun.Text = text.Substring(startIndex + targetText.Length);
  12904. parentParagraph.InsertBefore(afterRun, run);
  12905. }
  12906. // 删除原始Run
  12907. run.Remove();
  12908. }
  12909. }
  12910. #endregion
  12911. #endregion
  12912. #region 团组成本
  12913. /// <summary>
  12914. /// 团组成本数据初始化
  12915. /// </summary>
  12916. /// <param name="dto"></param>
  12917. /// <returns></returns>
  12918. [HttpPost]
  12919. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  12920. {
  12921. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  12922. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  12923. WHEN COUNT(*) >= 0 THEN 'True'
  12924. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  12925. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  12926. ").ToList(); //团组列表
  12927. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  12928. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  12929. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  12930. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  12931. if (groupinfoValue != null)
  12932. {
  12933. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  12934. var spArr = new string[1] { countryArr };
  12935. if (countryArr.Contains("|"))
  12936. {
  12937. spArr = countryArr.Split("|");
  12938. }
  12939. else if (countryArr.Contains("、"))
  12940. {
  12941. spArr = countryArr.Split("、");
  12942. }
  12943. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  12944. {
  12945. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  12946. if (dbQueryCountry != null)
  12947. {
  12948. visaCountryInfoArr.Add(dbQueryCountry);
  12949. }
  12950. }
  12951. }
  12952. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  12953. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  12954. #region 屏蔽黑屏代码生成
  12955. //var create = _GroupCostRepository.
  12956. // CreateGroupCostByBlackCode(dto.Diid);
  12957. //if (groupCost.Count == 0 && create.Code == 0)
  12958. //{
  12959. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  12960. //}
  12961. #endregion
  12962. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  12963. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  12964. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  12965. groupCostMap = groupCostMap.Select(x =>
  12966. {
  12967. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  12968. {
  12969. x.Date = dataForamt.ToString("yyyy-MM-dd");
  12970. }
  12971. return x;
  12972. }).ToList();
  12973. //GroupCostParameter.Add(new
  12974. // Grp_GroupCostParameter());
  12975. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  12976. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  12977. return Ok(JsonView(new
  12978. {
  12979. groupList,
  12980. groupInfo,
  12981. groupChecks,
  12982. groupCost = groupCostMap,
  12983. hotelNumber,
  12984. GroupCostParameter = GroupCostParameterMap,
  12985. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  12986. {
  12987. x.VisaCountry,
  12988. x.VisaPrice,
  12989. x.Id,
  12990. }).ToList(),
  12991. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  12992. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x=>x.IsDel == 0 && x.DiId == diid).Any() , //create.Code == 0 ? true : false,
  12993. hotelIsTrue = hotelIsTrue,
  12994. }));
  12995. }
  12996. /// <summary>
  12997. /// 团组成本信息保存
  12998. /// </summary>
  12999. /// <param name="dto"></param>
  13000. /// <returns></returns>
  13001. [HttpPost]
  13002. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  13003. {
  13004. if (dto.Diid <= 0 || dto.Userid <= 0)
  13005. {
  13006. return Ok(JsonView(false));
  13007. }
  13008. JsonView jw = null;
  13009. bool isTrue = false;
  13010. #region 复制团组成本
  13011. //if (dto.Diid == 2581)
  13012. //{
  13013. // dto.Diid = 2599;
  13014. // dto.CheckBoxs.ForEach(x =>
  13015. // {
  13016. // x.Diid = 2599;
  13017. // });
  13018. // dto.GroupCosts.ForEach(x =>
  13019. // {
  13020. // x.Diid = 2599;
  13021. // });
  13022. // dto.CostTypeHotelNumbers.ForEach(x =>
  13023. // {
  13024. // x.Diid = 2599;
  13025. // });
  13026. // dto.GroupCostParameters.ForEach(x =>
  13027. // {
  13028. // x.DiId = 2599;
  13029. // });
  13030. //}
  13031. #endregion
  13032. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  13033. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  13034. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  13035. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  13036. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  13037. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  13038. try
  13039. {
  13040. _sqlSugar.BeginTran();
  13041. isTrue = await _GroupCostRepository.
  13042. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  13043. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  13044. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  13045. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  13046. _sqlSugar.CommitTran();
  13047. jw = JsonView(true, "保存成功!", isTrue);
  13048. }
  13049. catch (Exception)
  13050. {
  13051. _sqlSugar.RollbackTran();
  13052. jw = JsonView(false);
  13053. }
  13054. return Ok(jw);
  13055. }
  13056. /// <summary>
  13057. /// 司兼导数据
  13058. /// </summary>
  13059. /// <param name="dto"></param>
  13060. /// <returns></returns>
  13061. [HttpPost]
  13062. public IActionResult GetCarGuides(CarGuidesDto dto)
  13063. {
  13064. JsonView jw = null;
  13065. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  13066. jw = JsonView(true, "获取成功!", Data);
  13067. return Ok(jw);
  13068. }
  13069. /// <summary>
  13070. /// 导游数据
  13071. /// </summary>
  13072. /// <param name="dto"></param>
  13073. /// <returns></returns>
  13074. [HttpPost]
  13075. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  13076. {
  13077. JsonView jw = null;
  13078. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  13079. // 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
  13080. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  13081. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  13082. jw = JsonView(true, "获取成功!", Data);
  13083. return Ok(jw);
  13084. }
  13085. /// <summary>
  13086. /// 成本车数据
  13087. /// </summary>
  13088. /// <param name="dto"></param>
  13089. /// <returns></returns>
  13090. [HttpPost]
  13091. public IActionResult GetCarInfo(CarGuidesDto dto)
  13092. {
  13093. JsonView jw = null;
  13094. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  13095. jw = JsonView(true, "获取成功!", Data);
  13096. return Ok(jw);
  13097. }
  13098. /// <summary>
  13099. /// 景点数据
  13100. /// </summary>
  13101. /// <param name="dto"></param>
  13102. /// <returns></returns>
  13103. [HttpPost]
  13104. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  13105. {
  13106. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  13107. return Ok(JsonView(true, "获取成功!", Data));
  13108. }
  13109. /// <summary>
  13110. /// 成本通知
  13111. /// </summary>
  13112. /// <param name="dto"></param>
  13113. /// <returns></returns>
  13114. [HttpPost]
  13115. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  13116. {
  13117. if (dto.Diid < 0)
  13118. {
  13119. return Ok(JsonView(false));
  13120. }
  13121. JsonView jw = null;
  13122. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  13123. if (GroupCostParameter != null)
  13124. {
  13125. int IsShare = 0;
  13126. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  13127. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  13128. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  13129. string msg = string.Empty;
  13130. if (isTrue)
  13131. {
  13132. if (IsShare == 0)
  13133. {
  13134. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  13135. }
  13136. else
  13137. {
  13138. #region 企微通知对应岗位用户
  13139. try
  13140. {
  13141. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  13142. }
  13143. catch (Exception ex)
  13144. {
  13145. }
  13146. #endregion
  13147. msg = "通知成功,其他模块操作人员可见此成本信息!";
  13148. }
  13149. jw = JsonView(isTrue, msg, new { IsShare });
  13150. }
  13151. else
  13152. {
  13153. msg = "修改失败!";
  13154. jw = JsonView(isTrue, msg);
  13155. }
  13156. }
  13157. else
  13158. {
  13159. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  13160. }
  13161. return Ok(jw);
  13162. }
  13163. /// <summary>
  13164. /// 导出报价单
  13165. /// </summary>
  13166. /// <param name="dto"></param>
  13167. /// <returns></returns>
  13168. [HttpPost]
  13169. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  13170. {
  13171. if (dto.Diid == 0)
  13172. {
  13173. return Ok(JsonView(false, "请传递团组id"));
  13174. }
  13175. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13176. if (deleInfo.Code != 0)
  13177. {
  13178. return Ok(JsonView(false, "团组信息查询失败!"));
  13179. }
  13180. var di = deleInfo.Data as DelegationInfoWebView;
  13181. if (di != null)
  13182. {
  13183. di.TeamName = di.TeamName.Replace("|", "、");
  13184. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  13185. //文件名
  13186. string strFileName = di.TeamName + "-收款账单.doc";
  13187. //获取模板
  13188. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  13189. //载入模板
  13190. Document doc = new Document(tmppath);
  13191. decimal TotalPrice = 0.00M;
  13192. string itemStr = string.Empty;
  13193. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  13194. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  13195. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  13196. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  13197. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  13198. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  13199. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  13200. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  13201. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  13202. foreach (var cost in groupCostType)
  13203. {
  13204. var List = cost.ToList();
  13205. if (cost.Key == "A")
  13206. {
  13207. foreach (var ListItem in List)
  13208. {
  13209. if (ListItem.number > 0)
  13210. {
  13211. if (ListItem.code.Contains("TBR"))
  13212. {
  13213. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13214. }
  13215. else
  13216. {
  13217. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13218. }
  13219. TotalPrice += (ListItem.number * ListItem.price);
  13220. }
  13221. }
  13222. }
  13223. else
  13224. {
  13225. itemStr = itemStr.Insert(0, "A段\r\n");
  13226. itemStr += "B段\r\n";
  13227. foreach (var ListItem in List)
  13228. {
  13229. if (ListItem.number > 0)
  13230. {
  13231. if (ListItem.code.Contains("TBR"))
  13232. {
  13233. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13234. }
  13235. else
  13236. {
  13237. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13238. }
  13239. TotalPrice += (ListItem.number * ListItem.price);
  13240. }
  13241. }
  13242. }
  13243. }
  13244. #region 替换Word模板书签内容
  13245. Dictionary<string, string> marks = new Dictionary<string, string>();
  13246. marks.Add("To", di.ClientUnit);//付款方
  13247. marks.Add("ToTel", di.TellPhone);//付款方电话
  13248. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  13249. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  13250. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  13251. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  13252. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  13253. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  13254. marks.Add("PayItemContent", itemStr);//详细信息
  13255. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  13256. #endregion
  13257. ////注
  13258. //if (doc.Range.Bookmarks["Attention"] != null)
  13259. //{
  13260. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  13261. // mark.Text = frList[0].Attention;
  13262. //}
  13263. foreach (var item in marks.Keys)
  13264. {
  13265. if (doc.Range.Bookmarks[item] != null)
  13266. {
  13267. Bookmark mark = doc.Range.Bookmarks[item];
  13268. mark.Text = marks[item];
  13269. }
  13270. }
  13271. byte[] bytes = null;
  13272. using (MemoryStream stream = new MemoryStream())
  13273. {
  13274. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13275. bytes = stream.ToArray();
  13276. }
  13277. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  13278. return Ok(JsonView(true, "", new
  13279. {
  13280. Data = bytes,
  13281. strFileName,
  13282. }));
  13283. }
  13284. else
  13285. {
  13286. return Ok(JsonView(false, "团组信息不存在!"));
  13287. }
  13288. }
  13289. /// <summary>
  13290. /// 导出团组成本
  13291. /// </summary>
  13292. /// <param name="dto"></param>
  13293. /// <returns></returns>
  13294. [HttpPost]
  13295. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  13296. {
  13297. var jw = JsonView(false);
  13298. if (dto.Diid == 0)
  13299. {
  13300. return Ok(JsonView(false, "请传递团组id"));
  13301. }
  13302. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13303. if (deleInfo.Code != 0)
  13304. {
  13305. return Ok(JsonView(false, "团组信息查询失败!"));
  13306. }
  13307. var di = deleInfo.Data as DelegationInfoWebView;
  13308. if (di == null)
  13309. {
  13310. return Ok(JsonView(false, "团组信息查询失败!"));
  13311. }
  13312. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  13313. WorkbookDesigner designer = new WorkbookDesigner();
  13314. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  13315. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  13316. for (int i = 0; i < List_GC.Count; i++)
  13317. {
  13318. GroupCost_Excel gc = new GroupCost_Excel();
  13319. gc.Id = List_GC[i].Id;
  13320. gc.Diid = List_GC[i].Diid.ToString();
  13321. gc.DAY = List_GC[i].DAY;
  13322. string week = "";
  13323. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  13324. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  13325. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  13326. gc.ITIN = List_GC[i].ITIN;
  13327. gc.CarType = List_GC[i].CarType;
  13328. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  13329. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  13330. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  13331. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  13332. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  13333. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  13334. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  13335. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  13336. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  13337. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  13338. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  13339. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  13340. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  13341. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  13342. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  13343. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  13344. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  13345. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  13346. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  13347. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  13348. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  13349. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  13350. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  13351. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  13352. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  13353. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  13354. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  13355. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  13356. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  13357. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  13358. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  13359. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  13360. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  13361. List_GC1.Add(gc);
  13362. }
  13363. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  13364. dt.TableName = "TB";
  13365. //报表标题等不用dt的值
  13366. designer.SetDataSource("TeamName", dto.title.TeamName);
  13367. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  13368. designer.SetDataSource("Tax", dto.title.Tax);
  13369. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  13370. designer.SetDataSource("Currency", dto.title.Currency);
  13371. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  13372. designer.SetDataSource("Rate", dto.title.Rate);
  13373. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  13374. var Aparams = hotels.Find(x => x.Type == "Default");
  13375. if (Aparams == null)
  13376. {
  13377. return Ok(jw);
  13378. }
  13379. //酒店数量
  13380. var txtSGRNumber = Aparams.SGR.ToString();
  13381. var txtTBRNumber = Aparams.TBR.ToString();
  13382. var txtJSESNumber = Aparams.JSES.ToString();
  13383. var txtSUITENumbe = Aparams.SUITE.ToString();
  13384. if (dto.costType == "B")
  13385. {
  13386. Aparams = hotels.Find(x => x.Type == "A");
  13387. var Bparams = hotels.Find(x => x.Type == "B");
  13388. if (Aparams == null || Bparams == null)
  13389. {
  13390. return Ok(jw);
  13391. }
  13392. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  13393. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  13394. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  13395. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  13396. }
  13397. designer.SetDataSource("SGRNumber", txtSGRNumber);
  13398. designer.SetDataSource("TBRNumber", txtTBRNumber);
  13399. designer.SetDataSource("JSESNumber", txtJSESNumber);
  13400. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  13401. var ws = designer.Workbook.Worksheets[0];
  13402. int Row = List_GC.Count;
  13403. int startIndex = 11;
  13404. int HideRows = 0;
  13405. List<int> hideRowsList = new List<int>();
  13406. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  13407. #region A段left数据
  13408. var left = dto.leftInfo.Find(x => x.Type == "A");
  13409. if (left == null)
  13410. {
  13411. return Ok(jw);
  13412. }
  13413. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  13414. if (leftBindData != null)
  13415. {
  13416. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  13417. designer.SetDataSource("VisaRS", leftBindData.rs);
  13418. designer.SetDataSource("VisaXS", leftBindData.xs);
  13419. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13420. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13421. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13422. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13423. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13424. }
  13425. else
  13426. {
  13427. hideRowsList.Add(Row + startIndex + HideRows);
  13428. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13429. }
  13430. HideRows += 2;
  13431. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  13432. if (leftBindData != null)
  13433. {
  13434. designer.SetDataSource("BXDRCB", leftBindData.cb);
  13435. designer.SetDataSource("BXRS", leftBindData.rs);
  13436. designer.SetDataSource("BXXS", leftBindData.xs);
  13437. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13438. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13439. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13440. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13441. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13442. }
  13443. else
  13444. {
  13445. hideRowsList.Add(Row + startIndex + HideRows);
  13446. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13447. }
  13448. HideRows += 2;
  13449. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  13450. if (leftBindData != null)
  13451. {
  13452. designer.SetDataSource("HSDRCB", leftBindData.cb);
  13453. designer.SetDataSource("HSRS", leftBindData.rs);
  13454. designer.SetDataSource("HSXS", leftBindData.xs);
  13455. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13456. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13457. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13458. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13459. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13460. }
  13461. else
  13462. {
  13463. hideRowsList.Add(Row + startIndex + HideRows);
  13464. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13465. }
  13466. HideRows += 2;
  13467. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  13468. if (leftBindData != null)
  13469. {
  13470. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  13471. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  13472. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  13473. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13474. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13475. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13476. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13477. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13478. }
  13479. else
  13480. {
  13481. hideRowsList.Add(Row + startIndex + HideRows);
  13482. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13483. }
  13484. HideRows += 2;
  13485. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  13486. if (leftBindData != null)
  13487. {
  13488. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  13489. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  13490. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  13491. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13492. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13493. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13494. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13495. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13496. }
  13497. else
  13498. {
  13499. hideRowsList.Add(Row + startIndex + HideRows);
  13500. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13501. }
  13502. HideRows += 2;
  13503. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  13504. if (leftBindData != null)
  13505. {
  13506. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  13507. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  13508. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  13509. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13510. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13511. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13512. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13513. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13514. }
  13515. else
  13516. {
  13517. hideRowsList.Add(Row + startIndex + HideRows);
  13518. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13519. }
  13520. HideRows += 2;
  13521. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  13522. if (leftBindData != null)
  13523. {
  13524. ////TBR
  13525. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  13526. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  13527. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  13528. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13529. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13530. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13531. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13532. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13533. }
  13534. else
  13535. {
  13536. hideRowsList.Add(Row + startIndex + HideRows);
  13537. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13538. }
  13539. HideRows += 2;
  13540. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  13541. if (leftBindData != null)
  13542. {
  13543. ////SGR
  13544. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  13545. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  13546. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  13547. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13548. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13549. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13550. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13551. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13552. }
  13553. else
  13554. {
  13555. hideRowsList.Add(Row + startIndex + HideRows);
  13556. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13557. }
  13558. HideRows += 2;
  13559. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  13560. if (leftBindData != null)
  13561. {
  13562. ////JS/ES
  13563. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  13564. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  13565. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  13566. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13567. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13568. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13569. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13570. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13571. }
  13572. else
  13573. {
  13574. hideRowsList.Add(Row + startIndex + HideRows);
  13575. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13576. }
  13577. HideRows += 2;
  13578. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  13579. if (leftBindData != null)
  13580. {
  13581. ////SUITE
  13582. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  13583. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  13584. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  13585. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13586. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13587. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13588. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13589. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13590. }
  13591. else
  13592. {
  13593. hideRowsList.Add(Row + startIndex + HideRows);
  13594. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13595. }
  13596. HideRows += 2;
  13597. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  13598. if (leftBindData != null)
  13599. {
  13600. designer.SetDataSource("DJDRCB", leftBindData.cb);
  13601. designer.SetDataSource("DJRS", leftBindData.rs);
  13602. designer.SetDataSource("DJXS", leftBindData.xs);
  13603. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13604. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13605. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13606. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13607. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13608. }
  13609. else
  13610. {
  13611. hideRowsList.Add(Row + startIndex + HideRows);
  13612. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13613. }
  13614. HideRows += 2;
  13615. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13616. if (leftBindData != null)
  13617. {
  13618. designer.SetDataSource("HCPCB", leftBindData.cb);
  13619. designer.SetDataSource("HCPRS", leftBindData.rs);
  13620. designer.SetDataSource("HCPXS", leftBindData.xs);
  13621. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13622. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13623. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13624. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13625. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13626. }
  13627. else
  13628. {
  13629. hideRowsList.Add(Row + startIndex + HideRows);
  13630. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13631. }
  13632. HideRows += 2;
  13633. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13634. if (leftBindData != null)
  13635. {
  13636. designer.SetDataSource("CPCB", leftBindData.cb);
  13637. designer.SetDataSource("CPRS", leftBindData.rs);
  13638. designer.SetDataSource("CPXS", leftBindData.xs);
  13639. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13640. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13641. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13642. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13643. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13644. }
  13645. else
  13646. {
  13647. hideRowsList.Add(Row + startIndex + HideRows);
  13648. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13649. }
  13650. HideRows += 2;
  13651. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13652. if (leftBindData != null)
  13653. {
  13654. designer.SetDataSource("GWDRCD", leftBindData.cb);
  13655. designer.SetDataSource("GWRS", leftBindData.rs);
  13656. designer.SetDataSource("GWXS", leftBindData.xs);
  13657. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13658. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13659. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13660. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13661. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13662. }
  13663. else
  13664. {
  13665. hideRowsList.Add(Row + startIndex + HideRows);
  13666. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13667. }
  13668. HideRows += 2;
  13669. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13670. if (leftBindData != null)
  13671. {
  13672. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  13673. designer.SetDataSource("LYJRS", leftBindData.rs);
  13674. designer.SetDataSource("LYJXS", leftBindData.xs);
  13675. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13676. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13677. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13678. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13679. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13680. }
  13681. else
  13682. {
  13683. hideRowsList.Add(Row + startIndex + HideRows);
  13684. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13685. }
  13686. #endregion
  13687. #region A段Right信息
  13688. var right = dto.rightInfo.Find(x => x.Type == "A");
  13689. if (right == null)
  13690. {
  13691. return Ok(jw);
  13692. }
  13693. HideRows += 4;
  13694. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13695. if (rightBindData != null)
  13696. {
  13697. //经济舱 + 双人间 TBR
  13698. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  13699. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  13700. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13701. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  13702. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13703. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13704. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13705. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13706. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13707. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13708. }
  13709. else
  13710. {
  13711. hideRowsList.Add(Row + startIndex + HideRows);
  13712. }
  13713. HideRows += 2;
  13714. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13715. if (rightBindData != null)
  13716. {
  13717. //经济舱 + 单人间 SGR
  13718. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  13719. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  13720. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13721. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  13722. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13723. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13724. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13725. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13726. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13727. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13728. }
  13729. else
  13730. {
  13731. hideRowsList.Add(Row + startIndex + HideRows);
  13732. }
  13733. HideRows += 2;
  13734. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13735. if (rightBindData != null)
  13736. {
  13737. //公务舱 + 单人间 SGR
  13738. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  13739. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  13740. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13741. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  13742. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13743. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13744. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13745. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13746. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13747. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13748. }
  13749. else
  13750. {
  13751. hideRowsList.Add(Row + startIndex + HideRows);
  13752. }
  13753. HideRows += 2;
  13754. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13755. if (rightBindData != null)
  13756. {
  13757. //公务舱 + 小套房 JSES
  13758. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  13759. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  13760. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13761. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  13762. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13763. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13764. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13765. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13766. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13767. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13768. }
  13769. else
  13770. {
  13771. hideRowsList.Add(Row + startIndex + HideRows);
  13772. }
  13773. HideRows += 2;
  13774. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13775. if (rightBindData != null)
  13776. {
  13777. //公务舱 + 小套房 JSES
  13778. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  13779. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  13780. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13781. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  13782. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13783. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13784. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13785. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13786. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13787. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13788. }
  13789. else
  13790. {
  13791. hideRowsList.Add(Row + startIndex + HideRows);
  13792. }
  13793. HideRows += 2;
  13794. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13795. if (rightBindData != null)
  13796. {
  13797. //经济舱 + 大套房
  13798. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  13799. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  13800. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13801. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  13802. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13803. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13804. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13805. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13806. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13807. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13808. }
  13809. else
  13810. {
  13811. hideRowsList.Add(Row + startIndex + HideRows);
  13812. }
  13813. HideRows += 2;
  13814. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13815. if (rightBindData != null)
  13816. {
  13817. //头等舱 + 小套房 JSES
  13818. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  13819. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  13820. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13821. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  13822. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13823. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13824. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13825. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13826. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13827. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13828. }
  13829. else
  13830. {
  13831. hideRowsList.Add(Row + startIndex + HideRows);
  13832. }
  13833. HideRows += 2;
  13834. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13835. if (rightBindData != null)
  13836. {
  13837. //头等舱 + 大套房
  13838. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  13839. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  13840. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13841. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  13842. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13843. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13844. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13845. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13846. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13847. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13848. }
  13849. else
  13850. {
  13851. hideRowsList.Add(Row + startIndex + HideRows);
  13852. }
  13853. #endregion
  13854. #region B段标题清空
  13855. designer.SetDataSource("CostBDRCB", "");
  13856. designer.SetDataSource("CostBRS", "");
  13857. designer.SetDataSource("CostBXS", "");
  13858. designer.SetDataSource("CostBZCB", "");
  13859. designer.SetDataSource("CostBDRBJ", "");
  13860. designer.SetDataSource("CostBZBJ", "");
  13861. designer.SetDataSource("CostBDRLR", "");
  13862. designer.SetDataSource("CostBZLR", "");
  13863. designer.SetDataSource("CostBDRCBOM", "");
  13864. designer.SetDataSource("CostBRSOM", "");
  13865. designer.SetDataSource("CostBZCBOM", "");
  13866. designer.SetDataSource("CostBDRBJOM", "");
  13867. designer.SetDataSource("CostBZBJOM", "");
  13868. designer.SetDataSource("CostBDRLROM", "");
  13869. designer.SetDataSource("CostBZLROM", "");
  13870. #endregion
  13871. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  13872. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  13873. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  13874. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  13875. designer.SetDataSource("DJName", "地接(CNY)");
  13876. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  13877. designer.SetDataSource("CPName", "地接-船票(CNY)");
  13878. designer.SetDataSource("GWName", "公务(CNY)");
  13879. designer.SetDataSource("YQHName", "邀请函(CNY)");
  13880. designer.SetDataSource("LYJName", "零用金(CNY)");
  13881. designer.SetDataSource("HSName", "核酸检测(CNY)");
  13882. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  13883. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  13884. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  13885. designer.SetDataSource("BXName", "保险(CNY)");
  13886. designer.SetDataSource("VisaName", "签证(CNY)");
  13887. #region B段基本数据
  13888. if (dto.costType == "B")
  13889. {
  13890. left = dto.leftInfo.Find(x => x.Type == "B");
  13891. if (left == null)
  13892. {
  13893. return Ok(jw);
  13894. }
  13895. #region B段left数据
  13896. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  13897. if (leftBindData != null)
  13898. {
  13899. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  13900. designer.SetDataSource("BHSRS", leftBindData.rs);
  13901. designer.SetDataSource("BHSXS", leftBindData.xs);
  13902. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13903. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13904. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13905. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13906. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13907. }
  13908. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  13909. if (leftBindData != null)
  13910. {
  13911. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  13912. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  13913. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  13914. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13915. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13916. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13917. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13918. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13919. }
  13920. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  13921. if (leftBindData != null)
  13922. {
  13923. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  13924. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  13925. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  13926. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13927. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13928. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13929. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13930. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13931. }
  13932. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  13933. if (leftBindData != null)
  13934. {
  13935. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  13936. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  13937. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  13938. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13939. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13940. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13941. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13942. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13943. }
  13944. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13945. if (leftBindData != null)
  13946. {
  13947. designer.SetDataSource("BHCPCB", leftBindData.cb);
  13948. designer.SetDataSource("BHCPRS", leftBindData.rs);
  13949. designer.SetDataSource("BHCPXS", leftBindData.xs);
  13950. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13951. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13952. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13953. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13954. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13955. }
  13956. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13957. if (leftBindData != null)
  13958. {
  13959. designer.SetDataSource("BCPCB", leftBindData.cb);
  13960. designer.SetDataSource("BCPRS", leftBindData.rs);
  13961. designer.SetDataSource("BCPXS", leftBindData.xs);
  13962. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13963. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13964. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13965. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13966. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13967. }
  13968. //TBR
  13969. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  13970. if (leftBindData != null)
  13971. {
  13972. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  13973. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  13974. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  13975. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13976. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13977. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13978. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13979. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13980. }
  13981. //SGR
  13982. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  13983. if (leftBindData != null)
  13984. {
  13985. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  13986. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  13987. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  13988. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13989. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13990. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13991. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13992. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13993. }
  13994. //JS/ES
  13995. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  13996. if (leftBindData != null)
  13997. {
  13998. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  13999. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  14000. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  14001. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14002. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14003. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14004. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14005. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14006. }
  14007. //SUITE
  14008. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14009. if (leftBindData != null)
  14010. {
  14011. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  14012. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  14013. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  14014. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14015. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14016. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14017. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14018. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14019. }
  14020. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14021. if (leftBindData != null)
  14022. {
  14023. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  14024. designer.SetDataSource("BDJRS", leftBindData.rs);
  14025. designer.SetDataSource("BDJXS", leftBindData.xs);
  14026. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14027. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14028. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14029. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14030. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14031. }
  14032. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14033. if (leftBindData != null)
  14034. {
  14035. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  14036. designer.SetDataSource("BGWRS", leftBindData.rs);
  14037. designer.SetDataSource("BGWXS", leftBindData.xs);
  14038. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14039. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14040. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14041. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14042. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14043. }
  14044. #region 优化方案
  14045. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  14046. //excelBind.Add("零用金", new {
  14047. //cb="",
  14048. //rs="",
  14049. //xs ="",
  14050. //zcb = "",
  14051. //});
  14052. #endregion
  14053. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14054. if (leftBindData != null)
  14055. {
  14056. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  14057. designer.SetDataSource("BLYJRS", leftBindData.rs);
  14058. designer.SetDataSource("BLYJXS", leftBindData.xs);
  14059. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14060. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14061. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14062. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14063. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14064. }
  14065. #endregion
  14066. #region B段Right信息
  14067. right = dto.rightInfo.Find(x => x.Type == "B");
  14068. if (right == null)
  14069. {
  14070. return Ok(jw);
  14071. }
  14072. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14073. if (rightBindData != null)
  14074. {
  14075. //经济舱 + 双人间 TBR
  14076. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  14077. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  14078. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14079. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  14080. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14081. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14082. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14083. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14084. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14085. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14086. }
  14087. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14088. if (rightBindData != null)
  14089. {
  14090. //经济舱 + 单人间 SGR
  14091. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  14092. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  14093. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14094. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  14095. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14096. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14097. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14098. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14099. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14100. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14101. }
  14102. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14103. if (rightBindData != null)
  14104. {
  14105. //公务舱 + 单人间 SGR
  14106. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  14107. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  14108. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14109. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  14110. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14111. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14112. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14113. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14114. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14115. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14116. }
  14117. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14118. if (rightBindData != null)
  14119. {
  14120. //公务舱 + 小套房 JSES
  14121. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  14122. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  14123. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14124. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  14125. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14126. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14127. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14128. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14129. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14130. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14131. }
  14132. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14133. if (rightBindData != null)
  14134. {
  14135. //公务舱 + 小套房 JSES
  14136. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  14137. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  14138. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14139. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  14140. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14141. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14142. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14143. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14144. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14145. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14146. }
  14147. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14148. if (rightBindData != null)
  14149. {
  14150. //经济舱 + 大套房
  14151. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  14152. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  14153. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14154. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  14155. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14156. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14157. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14158. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14159. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14160. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14161. }
  14162. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  14163. if (rightBindData != null)
  14164. {
  14165. //头等舱 + 小套房 JSES
  14166. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  14167. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  14168. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14169. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  14170. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14171. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14172. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14173. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14174. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14175. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14176. }
  14177. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  14178. if (rightBindData != null)
  14179. {
  14180. //头等舱 + 大套房
  14181. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  14182. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  14183. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14184. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  14185. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14186. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14187. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14188. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14189. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14190. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14191. }
  14192. #endregion
  14193. #region 标题
  14194. designer.SetDataSource("CostBDRCB", "单人成本");
  14195. designer.SetDataSource("CostBRS", "人数");
  14196. designer.SetDataSource("CostBXS", "系数");
  14197. designer.SetDataSource("CostBZCB", "总成本");
  14198. designer.SetDataSource("CostBDRBJ", "单人报价");
  14199. designer.SetDataSource("CostBZBJ", "总报价");
  14200. designer.SetDataSource("CostBDRLR", "单人利润");
  14201. designer.SetDataSource("CostBZLR", "总利润");
  14202. designer.SetDataSource("CostBDRCBOM", "单人成本");
  14203. designer.SetDataSource("CostBRSOM", "人数");
  14204. designer.SetDataSource("CostBZCBOM", "总成本");
  14205. designer.SetDataSource("CostBDRBJOM", "单人报价");
  14206. designer.SetDataSource("CostBZBJOM", "总报价");
  14207. designer.SetDataSource("CostBDRLROM", "单人利润");
  14208. designer.SetDataSource("CostBZLROM", "总利润");
  14209. #endregion
  14210. }
  14211. #endregion
  14212. designer.SetDataSource("TzZCB2", TzZCB2);
  14213. designer.SetDataSource("TzZBJ2", TzZBJ2);
  14214. designer.SetDataSource("TzZLR2", TzZLR2);
  14215. string[] dataSourceKeys = new string[]
  14216. {
  14217. "VF",
  14218. "TGS",
  14219. "TGOF",
  14220. "TGM",
  14221. "TGA",
  14222. "TGTF",
  14223. "TGEF",
  14224. "CFM",
  14225. "CFOF",
  14226. "B",
  14227. "L",
  14228. "D",
  14229. "TBR",
  14230. "SGR",
  14231. "JSES",
  14232. "Suite",
  14233. "TV",
  14234. "1L",
  14235. "IF",
  14236. "EF",
  14237. "BRF",
  14238. "TE",
  14239. "TGT",
  14240. "DRVT",
  14241. "PC",
  14242. "TLF",
  14243. "ECT"
  14244. };
  14245. foreach (var item in dataSourceKeys)
  14246. {
  14247. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  14248. if (find != null)
  14249. {
  14250. designer.SetDataSource(item, find.text);
  14251. }
  14252. else
  14253. {
  14254. designer.SetDataSource(item, 0);
  14255. }
  14256. }
  14257. designer.SetDataSource(dt);
  14258. //根据数据源处理生成报表内容
  14259. designer.Process();
  14260. designer.Workbook.Worksheets[0].Name = "清单";
  14261. Worksheet sheet = designer.Workbook.Worksheets[0];
  14262. foreach (var Rowindex in hideRowsList)
  14263. {
  14264. ws.Cells.HideRows(Rowindex, 2);
  14265. }
  14266. byte[] bytes = null;
  14267. string strFileName = di.TeamName + "-团组-成本.xls";
  14268. using (MemoryStream stream = new MemoryStream())
  14269. {
  14270. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  14271. bytes = stream.ToArray();
  14272. }
  14273. return Ok(JsonView(true, "", new
  14274. {
  14275. Data = bytes,
  14276. strFileName,
  14277. }));
  14278. }
  14279. /// <summary>
  14280. /// 导出客户报表
  14281. /// </summary>
  14282. /// <returns></returns>
  14283. [HttpPost]
  14284. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  14285. {
  14286. var jw = JsonView(false);
  14287. if (dto.Diid == 0)
  14288. {
  14289. return Ok(JsonView(false, "请传递团组id"));
  14290. }
  14291. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14292. if (deleInfo.Code != 0)
  14293. {
  14294. return Ok(JsonView(false, "团组信息查询失败!"));
  14295. }
  14296. var di = deleInfo.Data as DelegationInfoWebView;
  14297. if (di == null)
  14298. {
  14299. return Ok(JsonView(false, "团组信息查询失败!"));
  14300. }
  14301. //文件名
  14302. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  14303. //获取模板
  14304. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  14305. //载入模板
  14306. Document doc = new Document(tmppath);
  14307. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  14308. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  14309. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  14310. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  14311. var AParameter = ParameterList.Find(x => x.CostType == "A");
  14312. var BParameter = ParameterList.Find(x => x.CostType == "B");
  14313. if (AParameter == null)
  14314. {
  14315. return Ok(JsonView(false, "系数不存在!"));
  14316. }
  14317. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  14318. , TzAirDesc, TzZCost;
  14319. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  14320. = TzAirDesc = TzZCost = string.Empty;
  14321. TzNumber = AParameter.CostTypenumber.ToString();
  14322. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  14323. CarGuides1 = dto.CarGuides1;
  14324. Meal = dto.Meal;
  14325. SubsidizedMeals = dto.SubsidizedMeals;
  14326. NightRepair = dto.NightRepair;
  14327. AttractionsTickets = dto.AttractionsTickets;
  14328. MiscellaneousFees = dto.MiscellaneousFees;
  14329. ATip = dto.ATip;
  14330. TzHotelDesc = "";
  14331. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  14332. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  14333. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  14334. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  14335. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  14336. TzAirDesc = "";
  14337. TzZCost = dto.TzZCost;
  14338. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  14339. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  14340. var index = 1;
  14341. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  14342. foreach (var item in TzHotelDescArr)
  14343. {
  14344. if (AinfoArr != null)
  14345. {
  14346. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14347. if (Ainfo != null)
  14348. {
  14349. if (int.Parse(Ainfo.rs) <= 0)
  14350. {
  14351. continue;
  14352. }
  14353. var hotelText = string.Empty;
  14354. switch (item)
  14355. {
  14356. case "SGR":
  14357. hotelText = "单人间";
  14358. break;
  14359. case "JSES":
  14360. hotelText = "小套房";
  14361. break;
  14362. case "SUITE":
  14363. hotelText = "套房";
  14364. break;
  14365. case "TBR":
  14366. hotelText = "双人间";
  14367. break;
  14368. }
  14369. if (item != "TBR")
  14370. {
  14371. 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";
  14372. }
  14373. else
  14374. {
  14375. 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";
  14376. }
  14377. index++;
  14378. }
  14379. }
  14380. }
  14381. index = 1;
  14382. foreach (var item in TzAirDescArr)
  14383. {
  14384. if (AinfoArr != null)
  14385. {
  14386. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14387. if (Ainfo != null)
  14388. {
  14389. if (int.Parse(Ainfo.rs) <= 0)
  14390. {
  14391. continue;
  14392. }
  14393. 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";
  14394. index++;
  14395. }
  14396. }
  14397. }
  14398. if (dto.costType == "B")
  14399. {
  14400. if (BParameter == null)
  14401. {
  14402. return Ok(JsonView(false, "B段系数不存在!"));
  14403. }
  14404. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  14405. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  14406. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  14407. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  14408. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  14409. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  14410. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  14411. foreach (var item in TzHotelDescArr)
  14412. {
  14413. if (AinfoArr != null)
  14414. {
  14415. TzHotelDesc += "B段信息 \r\n";
  14416. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14417. if (Ainfo != null)
  14418. {
  14419. if (int.Parse(Ainfo.rs) <= 0)
  14420. {
  14421. continue;
  14422. }
  14423. var hotelText = string.Empty;
  14424. switch (item)
  14425. {
  14426. case "SGR":
  14427. hotelText = "单人间";
  14428. break;
  14429. case "JSES":
  14430. hotelText = "小套房";
  14431. break;
  14432. case "SUITE":
  14433. hotelText = "套房";
  14434. break;
  14435. case "TBR":
  14436. hotelText = "双人间";
  14437. break;
  14438. }
  14439. if (item != "TBR")
  14440. {
  14441. 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";
  14442. }
  14443. else
  14444. {
  14445. 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";
  14446. }
  14447. index++;
  14448. }
  14449. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  14450. }
  14451. }
  14452. index = 1;
  14453. foreach (var item in TzAirDescArr)
  14454. {
  14455. if (AinfoArr != null)
  14456. {
  14457. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14458. if (Ainfo != null)
  14459. {
  14460. if (int.Parse(Ainfo.rs) <= 0)
  14461. {
  14462. continue;
  14463. }
  14464. 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";
  14465. index++;
  14466. }
  14467. }
  14468. }
  14469. }
  14470. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  14471. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  14472. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  14473. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  14474. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  14475. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  14476. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  14477. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  14478. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  14479. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  14480. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  14481. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  14482. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  14483. DickeyValue.Add("Visa", Visa); // 签证单人报价
  14484. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  14485. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  14486. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  14487. DickeyValue.Add("TzZCost", TzZCost);
  14488. foreach (var key in DickeyValue.Keys)
  14489. {
  14490. if (doc.Range.Bookmarks[key] != null)
  14491. {
  14492. Bookmark mark = doc.Range.Bookmarks[key];
  14493. mark.Text = DickeyValue[key];
  14494. }
  14495. }
  14496. byte[] bytes = null;
  14497. string strFileName = di.TeamName + "-客户报价.doc";
  14498. using (MemoryStream stream = new MemoryStream())
  14499. {
  14500. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14501. bytes = stream.ToArray();
  14502. }
  14503. return Ok(JsonView(true, "", new
  14504. {
  14505. Data = bytes,
  14506. strFileName,
  14507. }));
  14508. }
  14509. /// <summary>
  14510. /// 团组成本 各模块(酒店,地接,机票)成本提示
  14511. /// </summary>
  14512. /// <param name="dto"></param>
  14513. /// <returns></returns>
  14514. [HttpPost]
  14515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14516. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  14517. {
  14518. try
  14519. {
  14520. #region 参数验证
  14521. if (dto.DiId < 0)
  14522. {
  14523. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  14524. }
  14525. List<int> cTableIds = new List<int>() {
  14526. 76 ,//酒店预订
  14527. 77 ,//行程
  14528. 79 ,//车/导游地接
  14529. 80 ,//签证
  14530. 81 ,//邀请/公务活
  14531. 82 ,//团组客户保险
  14532. 85 ,//机票预订
  14533. 98 ,//其他款项
  14534. 285 ,//收款退还
  14535. 751 ,//酒店早餐
  14536. 1015 // 超支费用
  14537. };
  14538. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  14539. {
  14540. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  14541. }
  14542. #endregion
  14543. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  14544. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  14545. if (_GroupCostParameters.Count <= 0)
  14546. {
  14547. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  14548. }
  14549. if (_GroupCostParameters[0].IsShare == 0)
  14550. {
  14551. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  14552. }
  14553. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  14554. //处理date为空问题
  14555. if (_GroupCosts.Count > 0)
  14556. {
  14557. for (int i = 0; i < _GroupCosts.Count; i++)
  14558. {
  14559. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  14560. {
  14561. if (i > 0)
  14562. {
  14563. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  14564. }
  14565. }
  14566. }
  14567. }
  14568. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  14569. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  14570. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  14571. string currCode = "";
  14572. #region currCode 验证
  14573. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  14574. if (isInt)
  14575. {
  14576. var currData = currDatas.Find(it => it.Id == intCurrency);
  14577. if (currData != null)
  14578. {
  14579. currCode = currData.Name;
  14580. }
  14581. }
  14582. else
  14583. {
  14584. currCode = _GroupCostParameters[0].Currency.Trim();
  14585. }
  14586. #endregion
  14587. //op,酒店单段模式存储
  14588. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  14589. {
  14590. CurrencyCode = currCode,
  14591. Rate = _GroupCostParameters[0].Rate,
  14592. CostType = _GroupCostParameters[0].CostType,
  14593. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  14594. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  14595. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  14596. };
  14597. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  14598. if (_GroupCostParameters.Count == 2)
  14599. {
  14600. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  14601. }
  14602. foreach (var item in _GroupCostParameters)
  14603. {
  14604. decimal _rate = 1;
  14605. decimal _rate1 = item.Rate;
  14606. decimal _scale = 1;
  14607. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  14608. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  14609. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  14610. //if (userInfo != null)
  14611. //{
  14612. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  14613. // {
  14614. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  14615. // {
  14616. // _scale = 1.00M;
  14617. // }
  14618. // }
  14619. //}
  14620. #endregion
  14621. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  14622. {
  14623. CurrencyCode = currCode,
  14624. Rate = _rate1,
  14625. CostType = item.CostType,
  14626. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  14627. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  14628. CostTypeNumber = item.CostTypenumber
  14629. };
  14630. if (_GroupCostParameters.Count > 1)
  14631. {
  14632. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  14633. }
  14634. else
  14635. {
  14636. modulePromptInfo.CostTypeNumber = item.LYJRS;
  14637. }
  14638. if (dto.CTable == 79)//
  14639. {
  14640. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  14641. modulePromptInfo.TotalCost = item.DJCB;
  14642. }
  14643. List<string> costTypes = new List<string>() { "A", "B" };
  14644. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  14645. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  14646. if (_GroupCostsDuplicates.Count() == 1)
  14647. {
  14648. _GroupCostsTypeData = _GroupCosts;
  14649. }
  14650. else
  14651. {
  14652. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  14653. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  14654. }
  14655. /*
  14656. * 76 酒店预订
  14657. * 77 行程
  14658. * 79 车/导游地接
  14659. * 80 签证
  14660. * 81 邀请/公务活动
  14661. * 82 团组客户保险
  14662. * 85 机票预订
  14663. * 98 其他款项
  14664. * 285 收款退还
  14665. * 751 酒店早餐
  14666. * 1015 超支费用
  14667. */
  14668. switch (dto.CTable)
  14669. {
  14670. case 76: // 酒店预订
  14671. _ModuleSubPromptInfo.AddRange(
  14672. _GroupCostsTypeData.Select(it => new
  14673. {
  14674. it.DAY,
  14675. it.Date,
  14676. it.ACCON,
  14677. it.ITIN,
  14678. it.SGR,
  14679. it.TBR,
  14680. it.JS_ES,
  14681. it.Suite
  14682. })
  14683. );
  14684. break;
  14685. case 79: // 车/导游地接
  14686. _ModuleSubPromptInfo.AddRange(
  14687. _GroupCostsTypeData.Select(it => new
  14688. {
  14689. Date = it.Date, //日期
  14690. CarFee = it.CarCost * _rate * _scale, //车费用
  14691. CarType = it.CarType, //车型
  14692. DriverFee = it.CFS * _rate * _scale, //司机工资
  14693. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  14694. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  14695. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  14696. GuideFee = it.TGS * _rate * _scale, //导游费用
  14697. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  14698. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  14699. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  14700. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  14701. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  14702. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  14703. Breakfast = it.B * _rate * _scale, //早餐费
  14704. Lunch = it.L * _rate * _scale, //午餐费
  14705. Dinner = it.D * _rate * _scale, //晚餐费
  14706. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  14707. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  14708. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  14709. TicketFee = it.EF * _rate * _scale, //门票费
  14710. TicketRemark = it.EFR, //门票费描述
  14711. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  14712. TravelSupplies = it.TE * _rate * _scale, //出行物资
  14713. SpentCash = it.PC * _rate * _scale, //零用金
  14714. LeadersFee = it.TLF * _rate * _scale, //领队费
  14715. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  14716. })
  14717. );
  14718. break;
  14719. case 85: // 机票
  14720. List<dynamic> datas = new List<dynamic>();
  14721. datas.Add(
  14722. new
  14723. {
  14724. AirType = "经济舱",
  14725. AirNum = item.JJCRS,
  14726. AirDRCB = item.JJCCB,
  14727. AirZCB = (item.JJCRS * item.JJCCB)
  14728. }
  14729. );
  14730. datas.Add(
  14731. new
  14732. {
  14733. AirType = "公务舱",
  14734. AirNum = item.GWCRS,
  14735. AirDRCB = item.GWCCB,
  14736. AirZCB = (item.GWCRS * item.GWCCB)
  14737. }
  14738. );
  14739. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  14740. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  14741. modulePromptInfo.Data = new
  14742. {
  14743. airFeeData = datas,
  14744. airInitData = initDatas
  14745. };
  14746. _ModulePromptInfos.Add(modulePromptInfo);
  14747. break;
  14748. default:
  14749. break;
  14750. }
  14751. }
  14752. if (dto.CTable != 85)
  14753. {
  14754. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  14755. _ModulePromptInfos.Add(_ModulePromptInfo);
  14756. }
  14757. _view.ModulePromptInfos = _ModulePromptInfos;
  14758. return Ok(JsonView(true, "操作成功!", _view));
  14759. }
  14760. catch (Exception ex)
  14761. {
  14762. return Ok(JsonView(false, ex.Message));
  14763. }
  14764. }
  14765. /// <summary>
  14766. /// 根据黑屏代码重新生成行程
  14767. /// </summary>
  14768. /// <param name="dto"></param>
  14769. /// <returns></returns>
  14770. [HttpPost]
  14771. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  14772. {
  14773. var jw = JsonView(false,"Error");
  14774. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  14775. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  14776. .Select(x=> new
  14777. {
  14778. x.Id,
  14779. x.Title
  14780. })
  14781. .ToList();
  14782. if (Create.Any())
  14783. {
  14784. jw.Msg = "获取成功!";
  14785. jw.Code = 200;
  14786. jw.Data = new
  14787. {
  14788. BlackCodeListSelect = Create,
  14789. blackCodeIsTrue = true
  14790. };
  14791. }
  14792. else
  14793. {
  14794. jw.Code = 400;
  14795. jw.Data = new
  14796. {
  14797. BlackCodeListSelect = Create,
  14798. blackCodeIsTrue = false,
  14799. };
  14800. }
  14801. return Ok(jw);
  14802. }
  14803. /// <summary>
  14804. /// 根据黑屏代码Id重新生成行程
  14805. /// </summary>
  14806. /// <param name="dto"></param>
  14807. /// <returns></returns>
  14808. [HttpPost]
  14809. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  14810. {
  14811. var jw = JsonView(false, "Error");
  14812. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  14813. if (result.Code == 0)
  14814. {
  14815. jw.Msg = "获取成功!";
  14816. jw.Code = 200;
  14817. jw.Data = new
  14818. {
  14819. groupCost = result.Data,
  14820. blackCodeIsTrue = true
  14821. };
  14822. }
  14823. else
  14824. {
  14825. jw.Code = 400;
  14826. jw.Data = new
  14827. {
  14828. groupCost = result.Data,
  14829. blackCodeIsTrue = false,
  14830. };
  14831. }
  14832. return Ok(jw);
  14833. }
  14834. /// <summary>
  14835. /// 成本获取OP历史车费用
  14836. /// </summary>
  14837. /// <param name="dto"></param>
  14838. /// <returns></returns>
  14839. [HttpPost]
  14840. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  14841. {
  14842. var jw = JsonView(false);
  14843. try
  14844. {
  14845. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  14846. //获取现有所有车的数据
  14847. if (!dto.Param.IsNullOrWhiteSpace())
  14848. {
  14849. string sql = $@"
  14850. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  14851. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  14852. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  14853. 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
  14854. AND gctggr.ServiceEndTime is not NULL
  14855. ORDER by gctggrc.id DESC
  14856. ";
  14857. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  14858. var numeberResult = await Task.Run(() =>
  14859. {
  14860. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  14861. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  14862. return numberArr;
  14863. });
  14864. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  14865. foreach (var item in numeberResult)
  14866. {
  14867. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  14868. {
  14869. Country = "数据异常!",
  14870. City = string.Empty,
  14871. };
  14872. item.Area = find.Country + " " + find.City;
  14873. }
  14874. dbResult.AddRange(numeberResult);
  14875. if (dto.Param.Contains("、"))
  14876. {
  14877. var sp = dto.Param.Split("、");
  14878. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14879. .Where(x =>
  14880. {
  14881. return System.Array.Exists(sp, e =>
  14882. {
  14883. bool where = false;
  14884. if (x.Area != null)
  14885. {
  14886. where = x.Area.Contains(e);
  14887. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14888. {
  14889. return false;
  14890. }
  14891. }
  14892. if (x.PriceName != null && !where)
  14893. {
  14894. where = x.PriceName.Contains(e);
  14895. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14896. {
  14897. return false;
  14898. }
  14899. }
  14900. return where;
  14901. });
  14902. }).ToList();
  14903. }
  14904. else
  14905. {
  14906. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14907. .Where(x =>
  14908. {
  14909. bool where = false;
  14910. if (x.Area != null)
  14911. {
  14912. where = x.Area.Contains(dto.Param);
  14913. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14914. {
  14915. return false;
  14916. }
  14917. }
  14918. if (x.PriceName != null && !where)
  14919. {
  14920. where = x.PriceName.Contains(dto.Param);
  14921. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14922. {
  14923. return false;
  14924. }
  14925. }
  14926. return where;
  14927. }
  14928. )
  14929. .ToList();
  14930. }
  14931. }
  14932. var view = dbResult.Select(x =>
  14933. {
  14934. decimal dp = 0.00M;
  14935. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  14936. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  14937. if (string.IsNullOrWhiteSpace(x.DatePrice))
  14938. {
  14939. if (startB && endB)
  14940. {
  14941. var timesp = endD.Subtract(startD);
  14942. if ((timesp.Days + 1) != 0)
  14943. {
  14944. dp = x.Price / (timesp.Days + 1);
  14945. }
  14946. }
  14947. }
  14948. else
  14949. {
  14950. dp = x.Price;
  14951. }
  14952. return new
  14953. {
  14954. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  14955. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  14956. x.Area,
  14957. x.id,
  14958. price = x.Price.ToString("F2"),
  14959. x.PriceName,
  14960. x.PriceContent,
  14961. x.TeamName,
  14962. x.DatePrice,
  14963. dayPrice = dp.ToString("F2"),
  14964. };
  14965. }).OrderByDescending(x => x.id).ToList();
  14966. jw = JsonView(true, "获取成功!", view);
  14967. }
  14968. catch (Exception e)
  14969. {
  14970. jw = JsonView(false, e.Message);
  14971. }
  14972. return Ok(jw);
  14973. }
  14974. [HttpPost]
  14975. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  14976. {
  14977. var jw = JsonView(true);
  14978. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  14979. if (string.IsNullOrWhiteSpace(dto.Keyword))
  14980. {
  14981. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14982. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14983. WHEN COUNT(*) >= 0 THEN 'True'
  14984. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14985. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14986. ")
  14987. .ToList();
  14988. }
  14989. else
  14990. {
  14991. string likeKey = string.Empty;
  14992. foreach (var item in dto.Keyword)
  14993. {
  14994. likeKey += "%" + item;
  14995. }
  14996. likeKey += "%";
  14997. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14998. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14999. WHEN COUNT(*) >= 0 THEN 'True'
  15000. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15001. Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  15002. ")
  15003. .ToList();
  15004. }
  15005. if (matches.Any())
  15006. {
  15007. jw.Data = matches;
  15008. }
  15009. else
  15010. {
  15011. jw.Code = 201;
  15012. jw.Msg = "empty list";
  15013. jw.Data = new List<string>(1);
  15014. }
  15015. return Ok(jw);
  15016. }
  15017. #endregion
  15018. #region 酒店预订 新 雷怡 2023-12-28 17:45
  15019. /// <summary>
  15020. /// 酒店预订
  15021. /// 酒店费用列表 根据团组Id查询
  15022. /// </summary>
  15023. /// <param name="_dto"></param>
  15024. /// <returns></returns>
  15025. [HttpPost]
  15026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15027. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  15028. {
  15029. #region 参数验证
  15030. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15031. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15032. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15033. #region 团组操作权限验证 76 酒店预定模块
  15034. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15035. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15036. #endregion
  15037. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15038. #region 页面操作权限验证
  15039. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15040. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15041. #endregion
  15042. #endregion
  15043. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  15044. }
  15045. /// <summary>
  15046. /// 酒店预订
  15047. /// 基础数据
  15048. /// </summary>
  15049. /// <param name="_dto"></param>
  15050. /// <returns></returns>
  15051. [HttpPost]
  15052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15053. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  15054. {
  15055. #region 参数验证
  15056. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15057. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15058. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15059. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15060. #region 页面操作权限验证
  15061. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15062. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15063. #endregion
  15064. #region 团组操作权限验证 76 酒店预定模块
  15065. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15066. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15067. #endregion
  15068. #endregion
  15069. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  15070. }
  15071. /// <summary>
  15072. /// 酒店预订
  15073. /// 创建 入住卷号码
  15074. /// </summary>
  15075. /// <param name="_dto"></param>
  15076. /// <returns></returns>
  15077. [HttpPost]
  15078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15079. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  15080. {
  15081. #region 参数验证
  15082. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15083. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15084. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15085. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15086. #region 页面操作权限验证
  15087. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15088. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15089. #endregion
  15090. #region 团组操作权限验证 76 酒店预定模块
  15091. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15092. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15093. #endregion
  15094. #endregion
  15095. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  15096. if (data.Code != 0)
  15097. {
  15098. return Ok(JsonView(false, data.Msg));
  15099. }
  15100. return Ok(JsonView(true, data.Msg, data.Data));
  15101. }
  15102. /// <summary>
  15103. /// 酒店预订
  15104. /// 详情
  15105. /// </summary>
  15106. /// <param name="_dto"></param>
  15107. /// <returns></returns>
  15108. [HttpPost]
  15109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15110. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  15111. {
  15112. #region 参数验证
  15113. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  15114. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15115. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  15116. #region 团组操作权限验证 76 酒店预定模块
  15117. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15118. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15119. #endregion
  15120. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15121. #region 页面操作权限验证
  15122. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15123. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15124. #endregion
  15125. #endregion
  15126. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  15127. }
  15128. /// <summary>
  15129. /// 酒店预订
  15130. /// Add Or Edit
  15131. /// </summary>
  15132. /// <param name="_dto"></param>
  15133. /// <returns></returns>
  15134. [HttpPost]
  15135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15136. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  15137. {
  15138. #region 参数验证
  15139. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15140. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15141. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15142. #region 团组操作权限验证 76 酒店预定模块
  15143. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15144. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15145. #endregion
  15146. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15147. #region 页面操作权限验证
  15148. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15149. if (_dto.Id == 0) // Add
  15150. {
  15151. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  15152. }
  15153. else if (_dto.Id > 1) // Edit
  15154. {
  15155. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  15156. }
  15157. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  15158. #endregion
  15159. #endregion
  15160. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  15161. if (_view.Code != 200)
  15162. {
  15163. return Ok(_view);
  15164. }
  15165. #region 成本无酒店价格数据进入超支
  15166. _sqlSugar.BeginTran();
  15167. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  15168. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  15169. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  15170. for (int i = 0; i < groupCost.Count; i++)
  15171. {
  15172. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  15173. {
  15174. groupCost[i].Date = groupCost[i - 1].Date;
  15175. }
  15176. }
  15177. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  15178. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  15179. List<Fin_GroupExtraCostDto_OP>();
  15180. if (start_Bool && end_Bool)
  15181. {
  15182. while (start_Time < end_Time)
  15183. {
  15184. foreach (var item in groupCost_Grp)
  15185. {
  15186. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  15187. {
  15188. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  15189. {
  15190. extraCostList.Add(new
  15191. Fin_GroupExtraCostDto_OP
  15192. {
  15193. Area = _dto.AreaId,
  15194. coefficient = 1.5M,
  15195. createUser = _dto.UserId,
  15196. currency = _dto.CardPriceCurrency,
  15197. diId = _dto.DiId,
  15198. ManagerConfirm = 0,
  15199. SupervisorConfirm = 0,
  15200. SYsupervisorConfirm = 0,
  15201. editType = 1,
  15202. PortType = 1,
  15203. price = _dto.CardPrice,
  15204. PriceCount = 1,
  15205. priceType = 1027,
  15206. priceDetailType = 1044,
  15207. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  15208. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  15209. });
  15210. }
  15211. }
  15212. }
  15213. start_Time = start_Time.AddDays(1);
  15214. }
  15215. }
  15216. if (extraCostList.Any())
  15217. {
  15218. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  15219. }
  15220. _sqlSugar.CommitTran();
  15221. #endregion
  15222. #region 应用推送
  15223. try
  15224. {
  15225. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  15226. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  15227. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  15228. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  15229. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  15230. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  15231. var diId = _dto.DiId;
  15232. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15233. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15234. #region 操作记录
  15235. var opInfo = new Crm_TableOperationRecord()
  15236. {
  15237. TableName = "Grp_HotelReservations",
  15238. PortType = _dto.PortType,
  15239. DataId = hotelId,
  15240. CreateUserId = _dto.UserId
  15241. };
  15242. //var opStatus = OperationEnum.NoOperation;
  15243. if (_dto.Id < 1) //添加操作
  15244. {
  15245. opInfo.OperationItem = OperationEnum.Add;
  15246. }
  15247. else if (_dto.Id > 0)
  15248. {
  15249. opInfo.OperationItem = OperationEnum.Edit;
  15250. }
  15251. string opRemark = string.Empty;
  15252. if (ccpInfo != null)
  15253. {
  15254. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  15255. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  15256. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  15257. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  15258. }
  15259. opInfo.Remark = opRemark;
  15260. await _tableorRep.AddAsync(opInfo);
  15261. #endregion
  15262. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  15263. //2024-10-21 新增LZ UID
  15264. var userIds = new List<int>() { 21 };
  15265. string title = $"费用审核";
  15266. string content = "";
  15267. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15268. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15269. try
  15270. {
  15271. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  15272. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  15273. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  15274. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  15275. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  15276. }
  15277. catch (Exception ex)
  15278. {
  15279. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  15280. }
  15281. }
  15282. catch (Exception ex)
  15283. {
  15284. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  15285. }
  15286. try
  15287. {
  15288. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  15289. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  15290. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  15291. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  15292. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  15293. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  15294. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15295. //自动审核
  15296. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  15297. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  15298. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  15299. //2024-10-21 新增LZ UID
  15300. var userIds = new List<int>() { 21 };
  15301. string title = $"系统通知";
  15302. var diId = _dto.DiId;
  15303. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15304. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15305. string content = "";
  15306. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15307. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15308. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15309. }
  15310. catch (Exception ex)
  15311. {
  15312. }
  15313. #endregion
  15314. return Ok(_view);
  15315. }
  15316. /// <summary>
  15317. /// 酒店自动审核测试
  15318. /// Add Or Edit
  15319. /// </summary>
  15320. /// <param name="diid"></param>
  15321. /// <param name="dataId"></param>
  15322. /// <returns></returns>
  15323. [HttpPost]
  15324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15325. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  15326. {
  15327. #region 应用推送
  15328. try
  15329. {
  15330. //自动审核
  15331. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  15332. }
  15333. catch (Exception ex)
  15334. {
  15335. return Ok(JsonView(false, "操作失败"));
  15336. }
  15337. #endregion
  15338. return Ok(JsonView(false, "操作成功"));
  15339. }
  15340. /// <summary>
  15341. /// 酒店预订
  15342. /// Del
  15343. /// </summary>
  15344. /// <param name="_dto"></param>
  15345. /// <returns></returns>
  15346. [HttpPost]
  15347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15348. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  15349. {
  15350. #region 参数验证
  15351. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15352. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15353. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15354. #region 团组操作权限验证 76 酒店预定模块
  15355. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15356. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15357. #endregion
  15358. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15359. #region 页面操作权限验证
  15360. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15361. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  15362. #endregion
  15363. #endregion
  15364. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  15365. #region 操作记录
  15366. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  15367. {
  15368. TableName = "Grp_HotelReservations",
  15369. PortType = _dto.PortType,
  15370. OperationItem = OperationEnum.Del,
  15371. DataId = _dto.Id,
  15372. CreateUserId = _dto.UserId
  15373. });
  15374. #endregion
  15375. return Ok(data);
  15376. }
  15377. /// <summary>
  15378. /// 酒店预订
  15379. /// 生成VOUCHER
  15380. /// 2024.05.06 之前版本
  15381. /// </summary>
  15382. /// <param name="_dto"></param>
  15383. /// <returns></returns>
  15384. [HttpPost]
  15385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15386. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  15387. {
  15388. try
  15389. {
  15390. #region 参数验证
  15391. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15392. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15393. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15394. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  15395. #region 团组操作权限验证 76 酒店预定模块
  15396. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15397. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15398. #endregion
  15399. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15400. #region 页面操作权限验证
  15401. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15402. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15403. #endregion
  15404. #endregion
  15405. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  15406. //判断数据是否完整
  15407. if (hr != null)
  15408. {
  15409. if (!string.IsNullOrEmpty(hr.DetermineNo))
  15410. {
  15411. string strFileName = "HotelStatement/";
  15412. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  15413. if (dele != null)
  15414. strFileName += dele.TourCode;
  15415. //载入模板
  15416. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  15417. Document doc = new Document(sss);
  15418. DocumentBuilder builder = new DocumentBuilder(doc);
  15419. #region 替换Word模板书签内容
  15420. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  15421. //入住卷预定号码
  15422. if (doc.Range.Bookmarks["VNO"] != null)
  15423. {
  15424. Bookmark mark = doc.Range.Bookmarks["VNO"];
  15425. mark.Text = hr.CheckNumber;
  15426. }
  15427. //酒店时间
  15428. if (doc.Range.Bookmarks["Date"] != null)
  15429. {
  15430. Bookmark mark = doc.Range.Bookmarks["Date"];
  15431. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  15432. }
  15433. //团号
  15434. if (doc.Range.Bookmarks["TNo"] != null)
  15435. {
  15436. Bookmark mark = doc.Range.Bookmarks["TNo"];
  15437. mark.Text = dele.TourCode;
  15438. }
  15439. //预定号码
  15440. if (doc.Range.Bookmarks["BookingId"] != null)
  15441. {
  15442. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  15443. mark.Text = hr.ReservationsNo;
  15444. }
  15445. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  15446. {
  15447. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  15448. mark.Text = hr.DetermineNo;
  15449. }
  15450. //酒店城市
  15451. if (doc.Range.Bookmarks["City"] != null)
  15452. {
  15453. Bookmark mark = doc.Range.Bookmarks["City"];
  15454. mark.Text = hr.City;
  15455. }
  15456. //酒店名称
  15457. if (doc.Range.Bookmarks["HName"] != null)
  15458. {
  15459. Bookmark mark = doc.Range.Bookmarks["HName"];
  15460. mark.Text = hr.HotelName;
  15461. }
  15462. //酒店地址
  15463. if (doc.Range.Bookmarks["Address"] != null)
  15464. {
  15465. Bookmark mark = doc.Range.Bookmarks["Address"];
  15466. mark.Text = hr.HotelAddress;
  15467. }
  15468. //酒店电话
  15469. if (doc.Range.Bookmarks["Tel"] != null)
  15470. {
  15471. Bookmark mark = doc.Range.Bookmarks["Tel"];
  15472. mark.Text = hr.HotelTel;
  15473. }
  15474. //酒店传真
  15475. if (doc.Range.Bookmarks["Fax"] != null)
  15476. {
  15477. Bookmark mark = doc.Range.Bookmarks["Fax"];
  15478. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  15479. {
  15480. mark.Text = hr.HotelFax;
  15481. }
  15482. }
  15483. //入住时间
  15484. if (doc.Range.Bookmarks["CIn"] != null)
  15485. {
  15486. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  15487. Bookmark mark = doc.Range.Bookmarks["CIn"];
  15488. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  15489. }
  15490. //退房时间
  15491. if (doc.Range.Bookmarks["COut"] != null)
  15492. {
  15493. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  15494. Bookmark mark = doc.Range.Bookmarks["COut"];
  15495. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  15496. }
  15497. //客户名称
  15498. if (doc.Range.Bookmarks["GName"] != null)
  15499. {
  15500. string guestName = "";
  15501. string[] clients = new string[] { };
  15502. if (hr.GuestName.Contains(","))
  15503. {
  15504. clients = hr.GuestName.Split(",");
  15505. }
  15506. else
  15507. {
  15508. clients = new string[] { hr.GuestName };
  15509. }
  15510. List<int> clientIds_int = new List<int>();
  15511. if (clients.Length > 0)
  15512. {
  15513. foreach (var item in clients)
  15514. {
  15515. if (item.IsNumeric())
  15516. {
  15517. clientIds_int.Add(int.Parse(item));
  15518. }
  15519. }
  15520. }
  15521. if (clientIds_int.Count > 0)
  15522. {
  15523. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  15524. foreach (var client in _clientDatas)
  15525. {
  15526. //男
  15527. if (client.Sex == 0) guestName += $"Mr.";
  15528. //女
  15529. else if (client.Sex == 1) guestName += $"Ms.";
  15530. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  15531. {
  15532. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  15533. }
  15534. //guestName += $"{client.Pinyin},";
  15535. }
  15536. if (guestName.Length > 0)
  15537. {
  15538. guestName = guestName.Substring(0, guestName.Length - 1);
  15539. }
  15540. }
  15541. else
  15542. {
  15543. guestName = hr.GuestName;
  15544. }
  15545. Bookmark mark = doc.Range.Bookmarks["GName"];
  15546. mark.Text = guestName;
  15547. }
  15548. //房间介绍
  15549. if (doc.Range.Bookmarks["ROOM"] != null)
  15550. {
  15551. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  15552. mark.Text = hr.RoomExplanation;
  15553. }
  15554. //报价描述
  15555. if (doc.Range.Bookmarks["NOTE"] != null)
  15556. {
  15557. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  15558. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  15559. if (ss != null)
  15560. mark.Text = ss.Name;
  15561. }
  15562. //入住时间
  15563. if (doc.Range.Bookmarks["CheckIn"] != null)
  15564. {
  15565. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  15566. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  15567. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  15568. }
  15569. //退房时间
  15570. if (doc.Range.Bookmarks["CheckOut"] != null)
  15571. {
  15572. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  15573. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  15574. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  15575. }
  15576. //日期
  15577. if (doc.Range.Bookmarks["DT"] != null)
  15578. {
  15579. Bookmark mark = doc.Range.Bookmarks["DT"];
  15580. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  15581. }
  15582. //名称
  15583. if (doc.Range.Bookmarks["VName"] != null)
  15584. {
  15585. Bookmark mark = doc.Range.Bookmarks["VName"];
  15586. mark.Text = hr.HotelName;
  15587. }
  15588. //号码
  15589. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  15590. {
  15591. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  15592. mark.Text = hr.CheckNumber;
  15593. }
  15594. #endregion
  15595. strFileName += "VOUCHER.doc";
  15596. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15597. doc.Save(fileDir);
  15598. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15599. return Ok(JsonView(true, "操作成功!", Url));
  15600. }
  15601. else
  15602. {
  15603. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  15604. }
  15605. }
  15606. else
  15607. {
  15608. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  15609. }
  15610. }
  15611. catch (Exception ex)
  15612. {
  15613. return Ok(JsonView(false, ex.Message));
  15614. }
  15615. }
  15616. /// <summary>
  15617. /// 酒店预订
  15618. /// 生成VOUCHER
  15619. /// 2024.05.06 之后版本
  15620. /// </summary>
  15621. /// <param name="_dto"></param>
  15622. /// <returns></returns>
  15623. [HttpPost]
  15624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15625. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  15626. {
  15627. #region 参数验证
  15628. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15629. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15630. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15631. #region 团组操作权限验证 76 酒店预定模块
  15632. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15633. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15634. #endregion
  15635. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15636. #region 页面操作权限验证
  15637. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15638. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15639. #endregion
  15640. #endregion
  15641. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  15642. //判断数据是否完整
  15643. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  15644. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15645. string strFileName = "HotelStatement/";
  15646. string guestNames = ""; //格式Mr.xxx Ms.xxx
  15647. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  15648. #region 数据处理
  15649. List<int> guestIds = new List<int>();
  15650. //int index = 0;
  15651. foreach (var item in hrDtas)
  15652. {
  15653. if (item.GuestName.Contains(","))
  15654. {
  15655. string[] guestIdArr = item.GuestName.Split(',');
  15656. foreach (var guestIdStr in guestIdArr)
  15657. {
  15658. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  15659. if (guestBool)
  15660. {
  15661. guestIds.Add(guestId);
  15662. }
  15663. }
  15664. }
  15665. else guestNames += item.GuestName;
  15666. var voucherInfo = new HotelVoucherInfoView()
  15667. {
  15668. HotelName = item.HotelName,
  15669. CheckInDate = item.CheckInDate,
  15670. CheckOutDate = item.CheckOutDate,
  15671. ConfirmationNumber = item.DetermineNo.Trim(),
  15672. RoomType = item.RoomExplanation
  15673. };
  15674. vouchers.Add(voucherInfo);
  15675. }
  15676. if (guestIds.Count > 0)
  15677. {
  15678. guestIds = guestIds.Distinct().ToList();
  15679. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  15680. if (guestDatas.Count > 0)
  15681. {
  15682. guestNames = "";
  15683. foreach (var guest in guestDatas)
  15684. {
  15685. string guestName = "";
  15686. if (guest.Sex == 0) guestName += @"MR.";
  15687. else if (guest.Sex == 1) guestName += @"MS.";
  15688. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  15689. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  15690. guestNames += @$"{guestName.Trim()}、";
  15691. }
  15692. if (guestNames.Length > 0)
  15693. {
  15694. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  15695. }
  15696. }
  15697. }
  15698. #endregion
  15699. //载入模板
  15700. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  15701. Document doc = new Document(sss);
  15702. DocumentBuilder builder = new DocumentBuilder(doc);
  15703. if (doc.Range.Bookmarks["GuestName"] != null)
  15704. {
  15705. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  15706. mark.Text = guestNames;
  15707. }
  15708. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15709. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  15710. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  15711. for (int i = 1; i <= vouchers.Count; i++)
  15712. {
  15713. HotelVoucherInfoView hviv = vouchers[i - 1];
  15714. builder.MoveToCell(0, i, 0, 0);
  15715. builder.Write(hviv.HotelName);
  15716. builder.MoveToCell(0, i, 1, 0);
  15717. builder.Write(hviv.CheckInDate);
  15718. builder.MoveToCell(0, i, 2, 0);
  15719. builder.Write(hviv.CheckOutDate);
  15720. builder.MoveToCell(0, i, 3, 0);
  15721. builder.Write(hviv.RoomType);
  15722. builder.MoveToCell(0, i, 4, 0);
  15723. builder.Write(hviv.ConfirmationNumber);
  15724. }
  15725. //删除多余行
  15726. int currRowIndex = vouchers.Count + 1;
  15727. int delRows = 21 - currRowIndex;
  15728. if (delRows > 0)
  15729. {
  15730. for (int i = 0; i < delRows; i++)
  15731. {
  15732. table.Rows.RemoveAt(currRowIndex);
  15733. //cultivateRowIndex++;
  15734. }
  15735. }
  15736. strFileName += "VOUCHER.docx";
  15737. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15738. doc.Save(fileDir);
  15739. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15740. return Ok(JsonView(true, "操作成功!", Url));
  15741. }
  15742. /// <summary>
  15743. /// 酒店预订
  15744. /// 生成VOUCHER 批量生成
  15745. /// New
  15746. /// </summary>
  15747. /// <param name="_dto"></param>
  15748. /// <returns></returns>
  15749. [HttpPost]
  15750. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15751. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  15752. {
  15753. #region 参数验证
  15754. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15755. if (_dto.PageId < 1) _dto.PageId = 28;
  15756. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15757. #region 团组操作权限验证 76 酒店预定模块
  15758. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15759. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15760. #endregion
  15761. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15762. #region 页面操作权限验证
  15763. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15764. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15765. #endregion
  15766. #endregion
  15767. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  15768. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  15769. .OrderBy(x => x.CheckInDate)
  15770. .ToListAsync();
  15771. //判断数据是否完整
  15772. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  15773. string strFileName = "HotelStatement/";
  15774. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  15775. if (dele != null)
  15776. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  15777. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  15778. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  15779. .Where(it => it.IsDel == 0)
  15780. .ToListAsync();
  15781. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  15782. for (int i = 0; i < hrDtas.Count; i++)
  15783. {
  15784. string guestNames = string.Empty;
  15785. List<int> guestIds = new List<int>();
  15786. var item = hrDtas[i];
  15787. //处理客户姓名
  15788. if (item.GuestName.Contains(","))
  15789. {
  15790. string[] guestIdArr = item.GuestName.Split(',');
  15791. foreach (var guestIdStr in guestIdArr)
  15792. if (int.TryParse(guestIdStr, out int guestId))
  15793. guestIds.Add(guestId);
  15794. }
  15795. else
  15796. {
  15797. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  15798. if (guestIdBool)
  15799. {
  15800. guestIds.Add(guestId);
  15801. }
  15802. //NaN
  15803. if (item.GuestName.Contains("NaN"))
  15804. {
  15805. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  15806. }
  15807. }
  15808. if (guestIds.Count > 0)
  15809. {
  15810. guestIds = guestIds.Distinct().ToList();
  15811. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  15812. if (guestDatas1.Count > 0)
  15813. {
  15814. guestNames = "";
  15815. foreach (var guest in guestDatas1)
  15816. {
  15817. string guestName = "";
  15818. if (guest.Sex == 0) guestName += @"MR.";
  15819. else if (guest.Sex == 1) guestName += @"MS.";
  15820. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  15821. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  15822. guestNames += @$"{guestName.Trim()}、";
  15823. }
  15824. if (guestNames.Length > 0)
  15825. {
  15826. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  15827. }
  15828. }
  15829. }
  15830. //if (!string.IsNullOrEmpty(guestNames))
  15831. //{
  15832. hrDtas[i].GuestName = guestNames;
  15833. //}
  15834. }
  15835. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  15836. Document doc = new Document();
  15837. DocumentBuilder builder = new DocumentBuilder(doc);
  15838. try
  15839. {
  15840. builder.MoveToDocumentStart();
  15841. foreach (var item in hrDtas)
  15842. {
  15843. //标题
  15844. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15845. builder.ParagraphFormat.LineSpacing = 1;
  15846. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15847. builder.ParagraphFormat.Style.Font.Size = 9;
  15848. builder.ParagraphFormat.Style.Font.Bold = true;
  15849. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15850. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  15851. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15852. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15853. builder.ParagraphFormat.LineSpacing = 1;
  15854. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15855. builder.ParagraphFormat.Style.Font.Size = 9;
  15856. builder.ParagraphFormat.Style.Font.Bold = true;
  15857. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  15858. builder.StartTable();
  15859. // 设置边框颜色
  15860. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  15861. //设置边框样式
  15862. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  15863. //表格
  15864. #region 第一行
  15865. builder.InsertCell();
  15866. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15867. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15868. //builder.CellFormat.AllowAutoFit = false;
  15869. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15870. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15871. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15872. builder.CellFormat.WrapText = true; //自动换行
  15873. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15874. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  15875. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15876. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15877. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15878. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15879. builder.Write("TOUR NO:");
  15880. builder.InsertCell();
  15881. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15882. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15883. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15884. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15885. builder.ParagraphFormat.Style.Font.Bold = false;
  15886. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15887. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15888. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15889. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15890. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15891. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15892. builder.Write($"{dele?.TourCode ?? "-"}");
  15893. builder.InsertCell();
  15894. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15895. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15896. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15897. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15898. builder.ParagraphFormat.Style.Font.Bold = false;
  15899. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15900. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15901. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15902. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15903. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15904. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15905. builder.Write($"CITY:");
  15906. builder.InsertCell();
  15907. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15908. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15909. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15910. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15911. builder.ParagraphFormat.Style.Font.Bold = false;
  15912. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15913. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15914. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15915. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15916. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15917. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15918. builder.Write($"{item.City}");
  15919. builder.EndRow();
  15920. #endregion
  15921. #region 第二行
  15922. builder.InsertCell();
  15923. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15924. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15925. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15926. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15927. builder.ParagraphFormat.Style.Font.Bold = false;
  15928. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15929. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15930. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15931. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15932. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15933. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15934. builder.Write("CONFIRMATION NO:");
  15935. builder.InsertCell();
  15936. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15937. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15938. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15939. builder.ParagraphFormat.Style.Font.Bold = false;
  15940. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15941. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15942. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15943. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15944. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15945. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15946. builder.CellFormat.VerticalMerge = CellMerge.None;
  15947. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15948. builder.Write($"{item.DetermineNo}");
  15949. builder.InsertCell();
  15950. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15951. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15952. builder.InsertCell();
  15953. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15954. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15955. builder.EndRow();
  15956. #endregion
  15957. #region 第三行
  15958. builder.InsertCell();
  15959. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15960. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15961. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15962. builder.ParagraphFormat.Style.Font.Bold = false;
  15963. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15964. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15965. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15966. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15967. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15968. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15969. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15970. builder.Write($"HOTEL NAME:");
  15971. builder.InsertCell();
  15972. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15973. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15974. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15975. builder.ParagraphFormat.Style.Font.Bold = false;
  15976. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15977. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15978. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15979. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15980. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15981. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15982. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15983. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15984. builder.Write($"{item.HotelName}");
  15985. builder.InsertCell();
  15986. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15987. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15988. builder.InsertCell();
  15989. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15990. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15991. builder.EndRow();
  15992. #endregion
  15993. #region 第四行
  15994. builder.InsertCell();
  15995. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15996. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15997. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15998. builder.ParagraphFormat.Style.Font.Bold = false;
  15999. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16000. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16001. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16002. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16003. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16004. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16005. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16006. builder.Write($"HOTEL ADDRESS:");
  16007. builder.InsertCell();
  16008. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16009. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16010. builder.ParagraphFormat.Style.Font.Size = 8;
  16011. builder.ParagraphFormat.Style.Font.Bold = false;
  16012. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16013. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16014. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16015. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16016. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16017. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16018. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16019. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16020. builder.Write($"{item.HotelAddress}");
  16021. builder.InsertCell();
  16022. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16023. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16024. builder.InsertCell();
  16025. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16026. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16027. builder.EndRow();
  16028. #endregion
  16029. #region 第五行
  16030. builder.InsertCell();
  16031. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16032. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16033. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16034. builder.ParagraphFormat.Style.Font.Bold = false;
  16035. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16036. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16037. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16038. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16039. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16040. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16041. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16042. builder.Write("TEL:");
  16043. builder.InsertCell();
  16044. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16045. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16046. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16047. builder.ParagraphFormat.Style.Font.Bold = false;
  16048. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16049. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16050. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16051. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16052. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16053. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16054. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16055. builder.Write($"{item.HotelTel}");
  16056. builder.InsertCell();
  16057. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16058. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16059. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16060. builder.ParagraphFormat.Style.Font.Bold = false;
  16061. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16062. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16063. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16064. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16065. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16066. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16067. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16068. builder.Write($"FAX:");
  16069. builder.InsertCell();
  16070. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16071. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16072. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16073. builder.ParagraphFormat.Style.Font.Bold = false;
  16074. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16075. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16076. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16077. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16078. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16079. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16080. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16081. builder.Write($"{item.HotelFax}");
  16082. builder.EndRow();
  16083. #endregion
  16084. #region 第六行
  16085. builder.InsertCell();
  16086. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16087. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16088. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16089. builder.ParagraphFormat.Style.Font.Bold = false;
  16090. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16091. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16092. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16093. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16094. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16095. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16096. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16097. builder.Write("CHECK IN:");
  16098. builder.InsertCell();
  16099. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16100. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16101. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16102. builder.ParagraphFormat.Style.Font.Bold = false;
  16103. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16104. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16105. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16106. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16107. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16108. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16109. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16110. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  16111. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  16112. builder.Write($"{checkInStr}");
  16113. builder.InsertCell();
  16114. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16115. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16116. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16117. builder.ParagraphFormat.Style.Font.Bold = false;
  16118. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16119. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16120. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16121. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16122. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16123. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16124. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16125. builder.Write($"CHECK OUT:");
  16126. builder.InsertCell();
  16127. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16128. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16129. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16130. builder.ParagraphFormat.Style.Font.Bold = false;
  16131. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16132. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16133. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16134. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16135. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16136. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16137. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16138. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  16139. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  16140. builder.Write($"{checkOutStr}");
  16141. builder.EndRow();
  16142. #endregion
  16143. #region 第七行
  16144. builder.InsertCell();
  16145. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16146. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16147. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16148. builder.ParagraphFormat.Style.Font.Bold = false;
  16149. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16150. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16151. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16152. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16153. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16154. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16155. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16156. builder.Write($"GUEST NAME:");
  16157. builder.InsertCell();
  16158. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16159. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16160. builder.ParagraphFormat.Style.Font.Size = 8;
  16161. builder.ParagraphFormat.Style.Font.Bold = false;
  16162. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16163. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16164. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16165. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16166. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16167. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16168. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16169. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16170. builder.Write($"{item.GuestName}");
  16171. builder.InsertCell();
  16172. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16173. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16174. builder.InsertCell();
  16175. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16176. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16177. builder.EndRow();
  16178. #endregion
  16179. #region 第八行
  16180. builder.InsertCell();
  16181. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16182. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16183. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16184. builder.ParagraphFormat.Style.Font.Bold = false;
  16185. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16186. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16187. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16188. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16189. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16190. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16191. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16192. builder.Write($"ROOM TYPE:");
  16193. builder.InsertCell();
  16194. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16195. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16196. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16197. builder.ParagraphFormat.Style.Font.Bold = false;
  16198. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16199. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16200. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16201. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16202. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16203. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16204. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16205. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16206. builder.Write($"{item.RoomExplanation}");
  16207. builder.InsertCell();
  16208. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16209. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16210. builder.InsertCell();
  16211. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16212. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16213. builder.EndRow();
  16214. #endregion
  16215. #region 第九行
  16216. builder.InsertCell();
  16217. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16218. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16219. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16220. builder.ParagraphFormat.Style.Font.Bold = false;
  16221. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16222. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16223. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16224. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16225. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16226. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16227. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16228. builder.Write($"NOTE:");
  16229. builder.InsertCell();
  16230. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16231. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16232. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16233. builder.ParagraphFormat.Style.Font.Bold = false;
  16234. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16235. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16236. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16237. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16238. 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.");
  16239. builder.InsertCell();
  16240. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16241. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16242. builder.InsertCell();
  16243. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16244. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16245. builder.EndRow();
  16246. #endregion
  16247. builder.EndTable();
  16248. //换行
  16249. builder.Writeln("");
  16250. builder.Writeln("");
  16251. }
  16252. #region 获取文档中的所有表格 设置文字自适应
  16253. // 获取文档中的所有表格。
  16254. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  16255. {
  16256. // 遍历表格中的所有行。
  16257. foreach (Aspose.Words.Tables.Row row in table.Rows)
  16258. {
  16259. foreach (Cell cell in row.Cells)
  16260. {
  16261. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  16262. cellFormat.Width = 0;
  16263. }
  16264. }
  16265. }
  16266. #endregion
  16267. #region 设置页眉
  16268. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  16269. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  16270. if (System.IO.File.Exists(voucherHeaderPath))
  16271. {
  16272. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  16273. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  16274. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  16275. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  16276. // 调整图片位置
  16277. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  16278. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  16279. shape.Top = 50; // 将图片距离页眉上边缘的距离
  16280. shape.Left = 0; // 将图片距离页面左边缘的距离
  16281. shape.Width = 81; // 设置图片宽度
  16282. shape.Height = 36; // 设置图片高度
  16283. }
  16284. //靠右
  16285. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  16286. //// 设置页脚上下边距
  16287. //builder.PageSetup.HeaderDistance = 42;
  16288. // 添加页眉线
  16289. Aspose.Words.Border borderHeader = null;
  16290. try
  16291. {
  16292. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  16293. }
  16294. catch (Exception e)
  16295. {
  16296. // TODO Auto-generated catch block
  16297. //e.printStackTrace();
  16298. }
  16299. borderHeader.Shadow = true;
  16300. borderHeader.DistanceFromText = 2;
  16301. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  16302. #endregion
  16303. }
  16304. catch (Exception ex)
  16305. {
  16306. }
  16307. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  16308. doc.Save(fileDir);
  16309. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  16310. return Ok(JsonView(true, "操作成功!", Url));
  16311. }
  16312. /// <summary>
  16313. /// 酒店预订
  16314. /// 生成 预定成本 Excel
  16315. /// </summary>
  16316. /// <param name="_dto"></param>
  16317. /// <returns></returns>
  16318. [HttpPost]
  16319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16320. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  16321. {
  16322. #region 参数验证
  16323. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  16324. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  16325. if (!vadalitorRes.IsValid)
  16326. {
  16327. var errors = new StringBuilder();
  16328. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  16329. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  16330. }
  16331. #region 团组操作权限验证 76 酒店预定模块
  16332. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16333. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16334. #endregion
  16335. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16336. #region 页面操作权限验证
  16337. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16338. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16339. #endregion
  16340. #endregion
  16341. decimal _rate = 1.00M;
  16342. string _currency = string.Empty;
  16343. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  16344. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  16345. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  16346. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  16347. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  16348. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  16349. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  16350. if (_GroupCostParameter == null)
  16351. {
  16352. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  16353. bool isIntType = int.TryParse(_currency, out int currId);
  16354. if (isIntType)
  16355. {
  16356. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  16357. }
  16358. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  16359. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  16360. if (currInfo == null)
  16361. {
  16362. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  16363. }
  16364. else _rate = currInfo.Rate;
  16365. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  16366. {
  16367. _rate = _GroupCostParameter.Rate;
  16368. }
  16369. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  16370. //string strFileName = "HotelStatement/";
  16371. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  16372. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  16373. var rateDatas = new List<dynamic>();
  16374. #region 数据处理
  16375. foreach (var item in hrDtas)
  16376. {
  16377. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  16378. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  16379. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  16380. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  16381. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  16382. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  16383. {
  16384. continue;
  16385. }
  16386. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  16387. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  16388. string singleRoomFeeStr = string.Empty,
  16389. doubleRoomFeeStr = string.Empty,
  16390. suiteRoomFeeStr = string.Empty,
  16391. otherRoomFeeStr = string.Empty,
  16392. payMoneyStr = string.Empty,
  16393. cardPriceStr = string.Empty;
  16394. if (roomCurr.Equals("CNY"))
  16395. {
  16396. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  16397. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  16398. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  16399. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  16400. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  16401. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  16402. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  16403. }
  16404. else
  16405. {
  16406. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  16407. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  16408. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  16409. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  16410. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  16411. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  16412. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16413. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16414. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16415. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16416. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  16417. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  16418. if (ccpPaymentCurrency.Equals("CNY"))
  16419. {
  16420. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  16421. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  16422. }
  16423. else
  16424. {
  16425. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  16426. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  16427. }
  16428. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  16429. if (hotelcardPriceCurrency.Equals("CNY"))
  16430. {
  16431. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  16432. }
  16433. else
  16434. {
  16435. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  16436. }
  16437. }
  16438. string breakfastPriceStr = string.Empty,
  16439. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  16440. governmentRentStr = string.Empty,
  16441. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  16442. cityTaxStr = string.Empty,
  16443. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  16444. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  16445. if (!string.IsNullOrEmpty(breakfastCurrency1))
  16446. {
  16447. if (breakfastCurrency1.Equals("CNY"))
  16448. {
  16449. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  16450. }
  16451. else
  16452. {
  16453. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  16454. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  16455. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  16456. }
  16457. }
  16458. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  16459. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  16460. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  16461. {
  16462. if (governmentRentCurrency.Equals("CNY"))
  16463. {
  16464. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  16465. }
  16466. else
  16467. {
  16468. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  16469. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  16470. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  16471. }
  16472. }
  16473. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  16474. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  16475. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  16476. {
  16477. if (cityTaxStrCurrency1.Equals("CNY"))
  16478. {
  16479. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  16480. }
  16481. else
  16482. {
  16483. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  16484. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  16485. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  16486. }
  16487. }
  16488. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  16489. int payDId = roomInfo?.PayDId ?? 0;
  16490. pcfds.Add(new HotelReservations_PCFD_View()
  16491. {
  16492. City = item.City,
  16493. HotelName = item.HotelName,
  16494. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  16495. // SingleRoomCount = item.SingleRoomCount,
  16496. SingleRoomPrice = singleRoomFeeStr,
  16497. // DoubleRoomCount = item.DoubleRoomCount,
  16498. DoubleRoomPrice = doubleRoomFeeStr,
  16499. //SuiteRoomCount = item.SuiteRoomCount,
  16500. SuiteRoomPrice = suiteRoomFeeStr,
  16501. OtherRoomPrice = otherRoomFeeStr,
  16502. //OtherRoomCount = item.OtherRoomCount,
  16503. BreakfastPrice = breakfastPriceStr,
  16504. GovernmentRent = governmentRentStr,
  16505. CityTax = cityTaxStr,
  16506. RoomExplanation = item.RoomExplanation,
  16507. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  16508. PayTime = roomInfo?.ConsumptionDate,
  16509. BankNo = roomInfo?.BankNo,
  16510. PayMoney = payMoneyStr,
  16511. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  16512. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  16513. CardPrice = cardPriceStr,
  16514. Remark = ccpInfo.Remark
  16515. });
  16516. }
  16517. #endregion
  16518. //载入模板
  16519. WorkbookDesigner designer = new WorkbookDesigner();
  16520. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  16521. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  16522. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  16523. designer.SetDataSource("TourNo", groupInfo.TourCode);
  16524. var rateDatas1 = rateDatas.Distinct();
  16525. var rateStr = string.Empty;
  16526. foreach (var item in rateDatas1)
  16527. {
  16528. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  16529. }
  16530. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  16531. designer.SetDataSource("Opertor", userInfo.CnName);
  16532. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  16533. dt.TableName = "ViewMyHotelReservations";
  16534. designer.SetDataSource(dt);
  16535. designer.Process();
  16536. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  16537. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  16538. designer.Workbook.Save(serverPath);
  16539. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  16540. #region 删除指定行
  16541. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  16542. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  16543. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  16544. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  16545. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  16546. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  16547. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  16548. cssIndex = dt.Columns["CityTax"].Ordinal,
  16549. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  16550. remarkIndex = dt.Columns["Remark"].Ordinal;
  16551. //删除指定列
  16552. foreach (DataRow item in dt.Rows)
  16553. {
  16554. string singleStr = item["SingleRoomPrice"].ToString();
  16555. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  16556. if (containsDigitButNotZero1) singleDel = false;
  16557. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  16558. string doubleStr = item["DoubleRoomPrice"].ToString();
  16559. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16560. if (containsDigitButNotZero2) doubleDel = false;
  16561. string suiteStr = item["SuiteRoomPrice"].ToString();
  16562. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16563. if (containsDigitButNotZero3) suiteDel = false;
  16564. string otherStr = item["OtherRoomPrice"].ToString();
  16565. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  16566. if (containsDigitButNotZero4) otherDel = false;
  16567. string zcStr = item["BreakfastPrice"].ToString();
  16568. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  16569. if (containsDigitButNotZero5) zcDel = false;
  16570. string dsStr = item["GovernmentRent"].ToString();
  16571. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  16572. if (containsDigitButNotZero6) dsDel = false;
  16573. string cssStr = item["CityTax"].ToString();
  16574. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  16575. if (containsDigitButNotZero7) cssDel = false;
  16576. string cpStr = item["ConsumptionPatterns"].ToString();
  16577. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  16578. string remarkStr = item["Remark"].ToString();
  16579. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  16580. }
  16581. DeleteColumn(serverPath, remarkIndex, remarkDel);
  16582. DeleteColumn(serverPath, cpIndex, cpDel);
  16583. DeleteColumn(serverPath, dsIndex, dsDel);
  16584. DeleteColumn(serverPath, cssIndex, cssDel);
  16585. DeleteColumn(serverPath, zcIndex, zcDel);
  16586. DeleteColumn(serverPath, otherIndex, otherDel);
  16587. DeleteColumn(serverPath, suiteIndex, suiteDel);
  16588. DeleteColumn(serverPath, doubleIndex, doubleDel);
  16589. DeleteColumn(serverPath, singleIndex, singleDel);
  16590. #endregion
  16591. //只保留第一个表格
  16592. DeleteSheet(serverPath);
  16593. return Ok(JsonView(true, "操作成功", url = rst));
  16594. }
  16595. else
  16596. {
  16597. _currency = _GroupCostParameter.Currency;
  16598. bool isIntType = int.TryParse(_currency, out int currId);
  16599. if (isIntType)
  16600. {
  16601. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  16602. }
  16603. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  16604. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  16605. if (currInfo == null)
  16606. {
  16607. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  16608. }
  16609. if (!_currency.ToUpper().Equals("CNY"))
  16610. {
  16611. _rate = _GroupCostParameter.Rate;
  16612. }
  16613. _rate = currInfo.Rate;
  16614. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  16615. //string strFileName = "HotelStatement/";
  16616. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  16617. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  16618. #region 数据处理
  16619. foreach (var item in hrDtas)
  16620. {
  16621. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  16622. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  16623. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  16624. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  16625. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  16626. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  16627. string singleRoomFeeStr = string.Empty,
  16628. doubleRoomFeeStr = string.Empty,
  16629. suiteRoomFeeStr = string.Empty,
  16630. otherRoomFeeStr = string.Empty,
  16631. payMoneyStr = string.Empty,
  16632. cardPriceStr = string.Empty;
  16633. if (roomCurr.Equals(_currency))
  16634. {
  16635. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  16636. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  16637. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  16638. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  16639. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  16640. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  16641. }
  16642. else
  16643. {
  16644. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  16645. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  16646. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  16647. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  16648. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  16649. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  16650. }
  16651. string breakfastPriceStr = string.Empty,
  16652. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  16653. governmentRentStr = string.Empty,
  16654. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  16655. cityTaxStrStr = string.Empty,
  16656. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  16657. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  16658. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  16659. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  16660. int payDId = roomInfo?.PayDId ?? 0;
  16661. pcfds.Add(new HotelReservations_PCFD_View()
  16662. {
  16663. City = item.City,
  16664. HotelName = item.HotelName,
  16665. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  16666. // SingleRoomCount = item.SingleRoomCount,
  16667. SingleRoomPrice = singleRoomFeeStr,
  16668. // DoubleRoomCount = item.DoubleRoomCount,
  16669. DoubleRoomPrice = doubleRoomFeeStr,
  16670. //SuiteRoomCount = item.SuiteRoomCount,
  16671. SuiteRoomPrice = suiteRoomFeeStr,
  16672. OtherRoomPrice = otherRoomFeeStr,
  16673. //OtherRoomCount = item.OtherRoomCount,
  16674. BreakfastPrice = breakfastPriceStr,
  16675. GovernmentRent = governmentRentStr,
  16676. CityTax = cityTaxStrStr,
  16677. RoomExplanation = item.RoomExplanation,
  16678. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  16679. PayTime = roomInfo?.ConsumptionDate,
  16680. BankNo = roomInfo?.BankNo,
  16681. PayMoney = payMoneyStr,
  16682. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  16683. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  16684. CardPrice = cardPriceStr,
  16685. Remark = ccpInfo.Remark
  16686. });
  16687. }
  16688. #endregion
  16689. //载入模板
  16690. WorkbookDesigner designer = new WorkbookDesigner();
  16691. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  16692. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  16693. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  16694. designer.SetDataSource("TourNo", groupInfo.TourCode);
  16695. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  16696. designer.SetDataSource("Opertor", userInfo.CnName);
  16697. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  16698. dt.TableName = "ViewMyHotelReservations";
  16699. designer.SetDataSource(dt);
  16700. designer.Process();
  16701. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  16702. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  16703. designer.Workbook.Save(serverPath);
  16704. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  16705. #region 删除指定行
  16706. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  16707. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  16708. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  16709. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  16710. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  16711. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  16712. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  16713. cssIndex = dt.Columns["CityTax"].Ordinal,
  16714. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  16715. remarkIndex = dt.Columns["Remark"].Ordinal;
  16716. //删除指定列
  16717. foreach (DataRow item in dt.Rows)
  16718. {
  16719. string singleStr = item["SingleRoomPrice"].ToString();
  16720. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  16721. if (containsDigitButNotZero1) singleDel = false;
  16722. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  16723. string doubleStr = item["DoubleRoomPrice"].ToString();
  16724. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16725. if (containsDigitButNotZero2) doubleDel = false;
  16726. string suiteStr = item["SuiteRoomPrice"].ToString();
  16727. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16728. if (containsDigitButNotZero3) suiteDel = false;
  16729. string otherStr = item["OtherRoomPrice"].ToString();
  16730. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  16731. if (containsDigitButNotZero4) otherDel = false;
  16732. string zcStr = item["BreakfastPrice"].ToString();
  16733. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  16734. if (containsDigitButNotZero5) zcDel = false;
  16735. string dsStr = item["GovernmentRent"].ToString();
  16736. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  16737. if (containsDigitButNotZero6) dsDel = false;
  16738. string cssStr = item["CityTax"].ToString();
  16739. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  16740. if (containsDigitButNotZero7) cssDel = false;
  16741. string cpStr = item["ConsumptionPatterns"].ToString();
  16742. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  16743. string remarkStr = item["Remark"].ToString();
  16744. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  16745. }
  16746. DeleteColumn(serverPath, remarkIndex, remarkDel);
  16747. DeleteColumn(serverPath, cpIndex, cpDel);
  16748. DeleteColumn(serverPath, dsIndex, dsDel);
  16749. DeleteColumn(serverPath, cssIndex, cssDel);
  16750. DeleteColumn(serverPath, zcIndex, zcDel);
  16751. DeleteColumn(serverPath, otherIndex, otherDel);
  16752. DeleteColumn(serverPath, suiteIndex, suiteDel);
  16753. DeleteColumn(serverPath, doubleIndex, doubleDel);
  16754. DeleteColumn(serverPath, singleIndex, singleDel);
  16755. #endregion
  16756. //只保留第一个表格
  16757. DeleteSheet(serverPath);
  16758. return Ok(JsonView(true, "操作成功", url = rst));
  16759. }
  16760. //return Ok(JsonView(false));
  16761. }
  16762. /// <summary>
  16763. /// 删除指定列
  16764. /// </summary>
  16765. /// <param name="file"></param>
  16766. /// <param name="columnIndex"></param>
  16767. /// <param name="isDel"></param>
  16768. private void DeleteColumn(string file, int columnIndex, bool isDel)
  16769. {
  16770. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16771. //wb.Save(file);
  16772. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  16773. if (sheet1 != null)
  16774. {
  16775. if (isDel)
  16776. {
  16777. Cells cells = sheet1.Cells;
  16778. cells.DeleteColumn(columnIndex);
  16779. }
  16780. }
  16781. wb.Save(file);
  16782. }
  16783. /// <summary>
  16784. /// 删除sheet
  16785. /// </summary>
  16786. /// <param name="file"></param>
  16787. /// <param name="sheetName"></param>
  16788. private void DeleteSheet(string file, string sheetName = "")
  16789. {
  16790. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16791. //wb.Save(file);
  16792. List<string> sheets = new List<string>();
  16793. foreach (var item in wb.Worksheets)
  16794. {
  16795. sheets.Add(item.Name);
  16796. }
  16797. if (sheets.Count > 0)
  16798. {
  16799. sheets.RemoveAt(0);//不删除第一个sheet
  16800. foreach (var item in sheets)
  16801. {
  16802. wb.Worksheets.RemoveAt(item);
  16803. }
  16804. }
  16805. wb.Save(file);
  16806. }
  16807. /// <summary>
  16808. /// 酒店预订
  16809. /// 确认单
  16810. /// </summary>
  16811. /// <param name="_dto"></param>
  16812. /// <returns></returns>
  16813. [HttpPost]
  16814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16815. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  16816. {
  16817. try
  16818. {
  16819. #region 参数验证
  16820. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  16821. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16822. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  16823. #region 团组操作权限验证 76 酒店预定模块
  16824. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16825. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  16826. #endregion
  16827. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16828. #region 页面操作权限验证
  16829. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16830. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16831. #endregion
  16832. #endregion
  16833. //团组信息
  16834. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  16835. //酒店数据
  16836. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  16837. if (listhoteldata.Count < 0)
  16838. {
  16839. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  16840. }
  16841. //利datatable存储
  16842. DataTable dt = new DataTable();
  16843. dt.Columns.Add("CheckInDate", typeof(string));
  16844. dt.Columns.Add("City", typeof(string));
  16845. dt.Columns.Add("Hotel", typeof(string));
  16846. dt.Columns.Add("Room", typeof(string));
  16847. for (int i = 0; i < listhoteldata.Count; i++)
  16848. {
  16849. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  16850. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  16851. while (dayStart < dayEnd)
  16852. {
  16853. string temp = "";
  16854. DataRow row = dt.NewRow();
  16855. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  16856. row["City"] = listhoteldata[i].City;
  16857. row["Hotel"] = listhoteldata[i].HotelName;
  16858. if (listhoteldata[i].SingleRoomCount > 0)
  16859. {
  16860. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  16861. }
  16862. if (listhoteldata[i].DoubleRoomCount > 0)
  16863. {
  16864. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  16865. }
  16866. if (listhoteldata[i].SuiteRoomCount > 0)
  16867. {
  16868. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  16869. }
  16870. if (listhoteldata[i].OtherRoomCount > 0)
  16871. {
  16872. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  16873. }
  16874. row["Room"] = temp;
  16875. dt.Rows.Add(row);
  16876. dayStart = dayStart.AddDays(1);
  16877. }
  16878. }
  16879. Dictionary<string, string> dic = new Dictionary<string, string>();
  16880. dic.Add("Dele", di.TeamName);
  16881. dic.Add("City", di.VisitCountry);
  16882. //模板路径
  16883. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  16884. //载入模板
  16885. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  16886. DocumentBuilder builder = new DocumentBuilder(doc);
  16887. foreach (var key in dic.Keys)
  16888. {
  16889. builder.MoveToBookmark(key);
  16890. builder.Write(dic[key]);
  16891. }
  16892. //获取word里所有表格
  16893. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16894. //获取所填表格的序数
  16895. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16896. var rowStart = tableOne.Rows[0]; //获取第1行
  16897. //循环赋值
  16898. for (int i = 0; i < dt.Rows.Count; i++)
  16899. {
  16900. builder.MoveToCell(0, i + 1, 0, 0);
  16901. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  16902. builder.MoveToCell(0, i + 1, 1, 0);
  16903. builder.Write(dt.Rows[i]["City"].ToString());
  16904. builder.MoveToCell(0, i + 1, 2, 0);
  16905. builder.Write(dt.Rows[i]["Hotel"].ToString());
  16906. builder.MoveToCell(0, i + 1, 3, 0);
  16907. builder.Write(dt.Rows[i]["Room"].ToString());
  16908. }
  16909. //删除多余行
  16910. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  16911. {
  16912. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  16913. }
  16914. string strFileName = di.TeamName + "酒店确认单.doc";
  16915. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  16916. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  16917. return Ok(JsonView(true, "成功", url));
  16918. }
  16919. catch (Exception ex)
  16920. {
  16921. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  16922. }
  16923. }
  16924. #endregion
  16925. #region 团组状态
  16926. /// <summary>
  16927. /// 团组状态列表 Page
  16928. /// </summary>
  16929. /// <param name="dto">团组列表请求dto</param>
  16930. /// <returns></returns>
  16931. [HttpPost]
  16932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16933. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  16934. {
  16935. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16936. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  16937. {
  16938. string sqlWhere = string.Empty;
  16939. if (dto.IsSure == 0) //未完成
  16940. {
  16941. sqlWhere += string.Format(@" And IsSure = 0");
  16942. }
  16943. else if (dto.IsSure == 1) //已完成
  16944. {
  16945. sqlWhere += string.Format(@" And IsSure = 1");
  16946. }
  16947. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  16948. {
  16949. string tj = dto.SearchCriteria;
  16950. 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}%')",
  16951. tj, tj, tj, tj, tj);
  16952. }
  16953. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  16954. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  16955. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  16956. From (
  16957. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  16958. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  16959. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  16960. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  16961. From Grp_DelegationInfo gdi
  16962. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  16963. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  16964. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  16965. Where gdi.IsDel = 0 {0}
  16966. ) temp ", sqlWhere);
  16967. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  16968. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  16969. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  16970. }
  16971. else
  16972. {
  16973. return Ok(JsonView(false, "查询失败"));
  16974. }
  16975. }
  16976. /// <summary>
  16977. /// 团组状态
  16978. /// 设置操作完成
  16979. /// </summary>
  16980. /// <param name="dto">团组列表请求dto</param>
  16981. /// <returns></returns>
  16982. [HttpPost]
  16983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16984. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  16985. {
  16986. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16987. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  16988. {
  16989. Id = dto.Id,
  16990. IsSure = 1
  16991. };
  16992. var result = await _sqlSugar.Updateable(_DelegationInfo)
  16993. .UpdateColumns(it => new { it.IsSure })
  16994. .WhereColumns(it => new { it.Id })
  16995. .ExecuteCommandAsync();
  16996. if (result > 0)
  16997. {
  16998. return Ok(JsonView(true, "操作完成!"));
  16999. }
  17000. return Ok(JsonView(false, "操作失败!"));
  17001. }
  17002. #endregion
  17003. #region 保险费用录入
  17004. /// <summary>
  17005. /// 根据团组Id查询保险费用列表
  17006. /// </summary>
  17007. /// <param name="dto"></param>
  17008. /// <returns></returns>
  17009. [HttpPost]
  17010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17011. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  17012. {
  17013. Result groupData = await _customersRep.CustomersByDiId(dto);
  17014. if (groupData.Code != 0)
  17015. {
  17016. return Ok(JsonView(false, groupData.Msg));
  17017. }
  17018. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  17019. }
  17020. /// <summary>
  17021. /// 根据保险费用Id查询保险费用详细
  17022. /// </summary>
  17023. /// <param name="dto"></param>
  17024. /// <returns></returns>
  17025. [HttpPost]
  17026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17027. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  17028. {
  17029. try
  17030. {
  17031. Result groupData = await _customersRep.CustomersById(dto);
  17032. if (groupData.Code != 0)
  17033. {
  17034. return Ok(JsonView(false, groupData.Msg));
  17035. }
  17036. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  17037. }
  17038. catch (Exception ex)
  17039. {
  17040. return Ok(JsonView(false, ex.Message));
  17041. }
  17042. }
  17043. /// <summary>
  17044. /// 保险费用录入页面初始化绑定
  17045. /// </summary>
  17046. /// <param name="dto"></param>
  17047. /// <returns></returns>
  17048. [HttpPost]
  17049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17050. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  17051. {
  17052. try
  17053. {
  17054. Result groupData = await _customersRep.CustomersInitialize(dto);
  17055. if (groupData.Code != 0)
  17056. {
  17057. return Ok(JsonView(false, groupData.Msg));
  17058. }
  17059. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  17060. }
  17061. catch (Exception ex)
  17062. {
  17063. return Ok(JsonView(false, ex.Message));
  17064. }
  17065. }
  17066. /// <summary>
  17067. /// 保险费用操作(Status:1.新增,2.修改)
  17068. /// </summary>
  17069. /// <param name="dto"></param>
  17070. /// <returns></returns>
  17071. [HttpPost]
  17072. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17073. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  17074. {
  17075. Result groupData = await _customersRep.OpCustomers(dto);
  17076. if (groupData.Code != 0)
  17077. {
  17078. return Ok(JsonView(false, groupData.Msg));
  17079. }
  17080. #region 应用推送
  17081. try
  17082. {
  17083. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  17084. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  17085. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  17086. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17087. //自动审核
  17088. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  17089. //2024-10-21 新增LZ UID
  17090. var userIds = new List<int>() { 21 };
  17091. string title = $"系统通知";
  17092. var diId = dto.DiId;
  17093. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17094. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17095. string content = "";
  17096. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17097. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17098. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17099. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  17100. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  17101. }
  17102. catch (Exception ex)
  17103. {
  17104. }
  17105. #endregion
  17106. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  17107. }
  17108. /// <summary>
  17109. /// 保险文件上传
  17110. /// </summary>
  17111. /// <param name="file"></param>
  17112. /// <returns></returns>
  17113. [HttpPost]
  17114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17115. public async Task<IActionResult> UploadCus(IFormFile file)
  17116. {
  17117. try
  17118. {
  17119. if (file != null)
  17120. {
  17121. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  17122. //文件名称
  17123. string projectFileName = file.FileName;
  17124. //上传的文件的路径
  17125. string filePath = "";
  17126. if (!Directory.Exists(fileDir))
  17127. {
  17128. Directory.CreateDirectory(fileDir);
  17129. }
  17130. //上传的文件的路径
  17131. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  17132. using (FileStream fs = System.IO.File.Create(filePath))
  17133. {
  17134. file.CopyTo(fs);
  17135. fs.Flush();
  17136. }
  17137. return Ok(JsonView(true, "上传成功!", projectFileName));
  17138. }
  17139. else
  17140. {
  17141. return Ok(JsonView(false, "上传失败!"));
  17142. }
  17143. }
  17144. catch (Exception ex)
  17145. {
  17146. return Ok(JsonView(false, "程序错误!"));
  17147. throw;
  17148. }
  17149. }
  17150. /// <summary>
  17151. /// 保险删除指定文件
  17152. /// </summary>
  17153. /// <param name="dto"></param>
  17154. /// <returns></returns>
  17155. [HttpPost]
  17156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17157. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  17158. {
  17159. try
  17160. {
  17161. string filePath = "";
  17162. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  17163. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  17164. //int id = 0;
  17165. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  17166. // 删除该文件
  17167. try
  17168. {
  17169. System.IO.File.Delete(filePath);
  17170. 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()
  17171. {
  17172. Attachment = "",
  17173. }).ExecuteCommandAsync();
  17174. if (result != 0)
  17175. {
  17176. return Ok(JsonView(true, "成功!"));
  17177. }
  17178. else
  17179. {
  17180. return Ok(JsonView(false, "失败!"));
  17181. }
  17182. }
  17183. catch (Exception)
  17184. {
  17185. 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()
  17186. {
  17187. Attachment = "",
  17188. }).ExecuteCommandAsync();
  17189. if (result != 0)
  17190. {
  17191. return Ok(JsonView(true, "成功!"));
  17192. }
  17193. else
  17194. {
  17195. return Ok(JsonView(false, "失败!"));
  17196. }
  17197. }
  17198. }
  17199. catch (Exception ex)
  17200. {
  17201. return Ok(JsonView(false, "程序错误!"));
  17202. throw;
  17203. }
  17204. }
  17205. /// <summary>
  17206. /// 保险费用操作(删除)
  17207. /// </summary>
  17208. /// <param name="dto"></param>
  17209. /// <returns></returns>
  17210. [HttpPost]
  17211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17212. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  17213. {
  17214. try
  17215. {
  17216. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  17217. if (!res)
  17218. {
  17219. return Ok(JsonView(false, "删除失败"));
  17220. }
  17221. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  17222. {
  17223. IsDel = 1,
  17224. DeleteUserId = dto.DeleteUserId,
  17225. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  17226. }).ExecuteCommandAsync();
  17227. return Ok(JsonView(true, "删除成功!"));
  17228. }
  17229. catch (Exception ex)
  17230. {
  17231. return Ok(JsonView(false, "程序错误!"));
  17232. throw;
  17233. }
  17234. }
  17235. #endregion
  17236. #region 接团客户名单 PageId 104
  17237. /// <summary>
  17238. /// 接团客户名单
  17239. /// 迁移数据(慎用!)
  17240. /// </summary>
  17241. /// <returns></returns>
  17242. [HttpPost]
  17243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17244. public async Task<IActionResult> PostTourClientListChange()
  17245. {
  17246. try
  17247. {
  17248. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  17249. //var groupClinetData1
  17250. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  17251. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  17252. int updateCount = 0;
  17253. if (oldOAClientList.Count > 0)
  17254. {
  17255. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  17256. _sqlSugar.BeginTran();
  17257. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  17258. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  17259. foreach (var item in oldOAClientList)
  17260. {
  17261. int comId = 0;
  17262. string format = "yyyy-MM-dd HH:mm:ss";
  17263. string data11 = "1990-01-01 00:00";
  17264. var data1 = IsValidDate(item.OPdate, format);
  17265. if (data1) data11 = item.OPdate;
  17266. //客户公司验证
  17267. if (!string.IsNullOrEmpty(item.Company))
  17268. {
  17269. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  17270. if (clientComInfo == null) // add
  17271. {
  17272. var addInfo = new Crm_CustomerCompany()
  17273. {
  17274. CompanyAbbreviation = "",
  17275. CompanyFullName = item.Company,
  17276. Address = "",
  17277. PostCodes = "",
  17278. LastedOpUserId = item.OPer,
  17279. LastedOpDt = Convert.ToDateTime(data11),
  17280. CreateUserId = item.OPer,
  17281. CreateTime = Convert.ToDateTime(data11),
  17282. IsDel = 0
  17283. };
  17284. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  17285. if (comId1 > 0) comId = comId1;
  17286. }
  17287. else comId = clientComInfo.Id;
  17288. }
  17289. //客户人员验证
  17290. int clientId = 0;
  17291. string name = item.LastName + item.Name;
  17292. if (!string.IsNullOrEmpty(name))
  17293. {
  17294. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  17295. if (clientInfo == null)
  17296. {
  17297. DateTime? dateTime = null;
  17298. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  17299. if (isDt) dateTime = birthDayDt;
  17300. var addInfo1 = new Crm_DeleClient()
  17301. {
  17302. CrmCompanyId = comId,
  17303. DiId = -1,
  17304. LastName = item.LastName,
  17305. FirstName = item.Name,
  17306. OldName = "",
  17307. Pinyin = item.Pinyin,
  17308. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  17309. Marriage = 0,
  17310. Phone = item.Phone,
  17311. Job = item.Job,
  17312. BirthDay = dateTime
  17313. };
  17314. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  17315. if (clientId1 > 0) clientId = clientId1;
  17316. }
  17317. else clientId = clientInfo.Id;
  17318. }
  17319. if (clientId < 1)
  17320. {
  17321. continue;
  17322. }
  17323. int airType = 0;
  17324. if (item.AirType == "超经舱") airType = 459;
  17325. else if (item.AirType == "公务舱") airType = 458;
  17326. else if (item.AirType == "经济舱") airType = 460;
  17327. else if (item.AirType == "其他") airType = 565;
  17328. else if (item.AirType == "头等舱") airType = 457;
  17329. var _TourClientListEntity = new Grp_TourClientList()
  17330. {
  17331. DiId = item.Diid,
  17332. ClientId = clientId,
  17333. CreateUserId = item.OPer,
  17334. CreateTime = Convert.ToDateTime(data11),
  17335. Remark = item.Remark,
  17336. IsDel = item.Isdel,
  17337. ShippingSpaceTypeId = airType,
  17338. ShippingSpaceSpecialNeeds = item.AirRemark,
  17339. HotelSpecialNeeds = item.RoomType
  17340. };
  17341. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  17342. if (_TourClientList > 0)
  17343. {
  17344. updateCount++;
  17345. }
  17346. }
  17347. _sqlSugar.CommitTran();
  17348. }
  17349. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  17350. }
  17351. catch (Exception ex)
  17352. {
  17353. _sqlSugar.RollbackTran();
  17354. return Ok(JsonView(false, ex.Message));
  17355. }
  17356. //return Ok(JsonView(true));
  17357. }
  17358. private bool IsValidDate(string dateString, string format)
  17359. {
  17360. DateTime dateValue;
  17361. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  17362. return valid;
  17363. }
  17364. /// <summary>
  17365. /// 接团客户名单
  17366. /// 根据团组Id查询List
  17367. /// </summary>
  17368. /// <param name="_dto"></param>
  17369. /// <returns></returns>
  17370. [HttpPost]
  17371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17372. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  17373. {
  17374. #region 参数验证
  17375. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  17376. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  17377. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  17378. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17379. #region 页面操作权限验证
  17380. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17381. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17382. #endregion
  17383. #endregion
  17384. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  17385. if (viewData.Code != 0)
  17386. {
  17387. return Ok(JsonView(false, viewData.Msg));
  17388. }
  17389. return Ok(JsonView(viewData.Data));
  17390. }
  17391. /// <summary>
  17392. /// 接团客户名单
  17393. /// 基础数据 Init
  17394. /// </summary>
  17395. /// <param name="_dto"></param>
  17396. /// <returns></returns>
  17397. [HttpPost]
  17398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17399. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  17400. {
  17401. #region 参数验证
  17402. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17403. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17404. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17405. #region 页面操作权限验证
  17406. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17407. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17408. #endregion
  17409. #endregion
  17410. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  17411. }
  17412. /// <summary>
  17413. /// 接团客户名单
  17414. /// 根据 Id查询 Details
  17415. /// </summary>
  17416. /// <param name="_dto"></param>
  17417. /// <returns></returns>
  17418. [HttpPost]
  17419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17420. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  17421. {
  17422. #region 参数验证
  17423. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17424. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17425. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  17426. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17427. #region 页面操作权限验证
  17428. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17429. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17430. #endregion
  17431. #endregion
  17432. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  17433. if (viewData.Code != 0)
  17434. {
  17435. return Ok(JsonView(false, viewData.Msg));
  17436. }
  17437. return Ok(JsonView(viewData.Data));
  17438. }
  17439. /// <summary>
  17440. /// 接团客户名单
  17441. /// Add Or Edit
  17442. /// </summary>
  17443. /// <param name="_dto"></param>
  17444. /// <returns></returns>
  17445. [HttpPost]
  17446. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17447. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  17448. {
  17449. #region 参数验证
  17450. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17451. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17452. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  17453. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17454. #region 页面操作权限验证
  17455. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17456. if (_dto.Id == 0) //添加
  17457. {
  17458. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17459. }
  17460. else if (_dto.Id >= 0) //修改
  17461. {
  17462. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  17463. }
  17464. #endregion
  17465. #endregion
  17466. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  17467. if (viewData.Code != 0)
  17468. {
  17469. return Ok(JsonView(false, viewData.Msg));
  17470. }
  17471. return Ok(JsonView(true));
  17472. }
  17473. /// <summary>
  17474. /// 接团客户名单
  17475. /// json字符串 AddMultiple(添加多个)
  17476. /// </summary>
  17477. /// <param name="_dto"></param>
  17478. /// <returns></returns>
  17479. [HttpPost]
  17480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17481. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  17482. {
  17483. #region 参数验证
  17484. string jsonLabel = _dto.JsonLabel;
  17485. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17486. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17487. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17488. #region 页面操作权限验证
  17489. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17490. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17491. #endregion
  17492. #endregion
  17493. var request = new TourClientListAddMultipleDto();
  17494. request.DiId = _dto.DiId;
  17495. request.UserId = _dto.UserId;
  17496. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  17497. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  17498. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  17499. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  17500. var infos = new List<TourClientListInfo>();
  17501. foreach (var data in datas)
  17502. {
  17503. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  17504. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  17505. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  17506. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  17507. {
  17508. continue;
  17509. }
  17510. infos.Add(new TourClientListInfo()
  17511. {
  17512. IsAccompany = 1,
  17513. LastName = lastName,
  17514. FirstName = firstName,
  17515. Pinyin = lastNameEn + @"/" + firstNameEn,
  17516. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  17517. CompanyFullName = data.CompanyFullName,
  17518. Job = data.Job
  17519. });
  17520. }
  17521. if (infos.Any())
  17522. {
  17523. var viewData = await _tourClientListRep._AddMultiple(request);
  17524. if (viewData.Code != 0)
  17525. {
  17526. return Ok(JsonView(false, viewData.Msg));
  17527. }
  17528. return Ok(JsonView(true));
  17529. }
  17530. return Ok(JsonView(false));
  17531. }
  17532. /// <summary>
  17533. /// 接团客户名单
  17534. /// AddMultiple(添加多个)
  17535. /// </summary>
  17536. /// <param name="_dto"></param>
  17537. /// <returns></returns>
  17538. [HttpPost]
  17539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17540. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  17541. {
  17542. #region 参数验证
  17543. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17544. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17545. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17546. #region 页面操作权限验证
  17547. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17548. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17549. #endregion
  17550. #endregion
  17551. var viewData = await _tourClientListRep._AddMultiple(_dto);
  17552. if (viewData.Code != 0)
  17553. {
  17554. return Ok(JsonView(false, viewData.Msg));
  17555. }
  17556. return Ok(JsonView(true));
  17557. }
  17558. /// <summary>
  17559. /// 接团客户名单
  17560. /// Del
  17561. /// </summary>
  17562. /// <param name="_dto"></param>
  17563. /// <returns></returns>
  17564. [HttpPost]
  17565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17566. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  17567. {
  17568. #region 参数验证
  17569. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17570. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17571. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17572. #region 页面操作权限验证
  17573. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17574. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  17575. #endregion
  17576. #endregion
  17577. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  17578. if (viewData.Code != 0)
  17579. {
  17580. return Ok(JsonView(false, viewData.Msg));
  17581. }
  17582. return Ok(JsonView(true));
  17583. }
  17584. /// <summary>
  17585. /// 接团客户名单
  17586. /// 文件下载 客户名单
  17587. /// </summary>
  17588. /// <param name="_dto"></param>
  17589. /// <returns></returns>
  17590. [HttpPost]
  17591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17592. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  17593. {
  17594. #region 参数验证
  17595. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17596. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17597. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  17598. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17599. #region 页面操作权限验证
  17600. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17601. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17602. #endregion
  17603. #endregion
  17604. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  17605. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  17606. From Grp_TourClientList tcl
  17607. Left Join
  17608. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  17609. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  17610. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  17611. From Crm_DeleClient dc
  17612. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  17613. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  17614. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  17615. Where dc.IsDel = 0) temp
  17616. On temp.DcId =tcl.ClientId
  17617. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  17618. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  17619. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  17620. //载入模板
  17621. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  17622. if (_dto.Language == 1)
  17623. {
  17624. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  17625. }
  17626. //载入模板
  17627. var doc = new Document(tempPath);
  17628. DocumentBuilder builder = new DocumentBuilder(doc);
  17629. //获取word里所有表格
  17630. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17631. //获取所填表格的序数
  17632. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  17633. var rowStart = tableOne.Rows[0]; //获取第1行
  17634. if (_dto.Language == 0)
  17635. {
  17636. //循环赋值
  17637. for (int i = 0; i < DcList.Count; i++)
  17638. {
  17639. EncryptionProcessor.DecryptProperties(DcList[i]);
  17640. builder.MoveToCell(0, i + 1, 0, 0);
  17641. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  17642. builder.MoveToCell(0, i + 1, 1, 0);
  17643. int sex = DcList[i].Sex;
  17644. string sexStr = string.Empty;
  17645. if (sex == 0) sexStr = "男";
  17646. else if (sex == 1) sexStr = "女";
  17647. else sexStr = "未设置";
  17648. builder.Write(sexStr);
  17649. builder.MoveToCell(0, i + 1, 2, 0);
  17650. string birthDay = DcList[i].BirthDay;
  17651. string birthDayStr = string.Empty;
  17652. if (!string.IsNullOrEmpty(birthDay))
  17653. {
  17654. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  17655. }
  17656. builder.Write(birthDayStr);
  17657. builder.MoveToCell(0, i + 1, 3, 0);
  17658. string company = "";
  17659. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  17660. {
  17661. company = DcList[i].CompanyFullName.ToString();
  17662. }
  17663. builder.Write(company);
  17664. builder.MoveToCell(0, i + 1, 4, 0);
  17665. builder.Write(DcList[i].Job);
  17666. }
  17667. }
  17668. else if (_dto.Language == 1)
  17669. {
  17670. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  17671. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  17672. List<string> transArrayStr = new List<string>();
  17673. string transStrRes1 = "";
  17674. for (int i = 0; i < DcList.Count; i++)
  17675. {
  17676. var dc = DcList[i];
  17677. EncryptionProcessor.DecryptProperties(dc);
  17678. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  17679. if (dc.Job.Equals("暂无")) dc.Job = "-";
  17680. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  17681. if (DcList.Count - 1 == i) transStrRes1 += str1;
  17682. else transStrRes1 += $"{str1}|";
  17683. }
  17684. //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";
  17685. string transStrRes = "";
  17686. if (transStrRes1.Length > 0)
  17687. {
  17688. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  17689. }
  17690. //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
  17691. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  17692. //List<string> transArray = new List<string> { };
  17693. List<TranslateInfo> transArray = new List<TranslateInfo>();
  17694. if (transStrRes.Contains("|"))
  17695. {
  17696. string[] transArray1 = transStrRes.Split('|');
  17697. if (transArray1.Length > 0)
  17698. {
  17699. foreach (var item in transArray1)
  17700. {
  17701. if (item.Contains("&"))
  17702. {
  17703. string[] transArray2 = item.Split('&');
  17704. int index = 0;
  17705. string companyName = "", job = "";
  17706. if (transArray2.Length > 0)
  17707. {
  17708. bool success = int.TryParse(transArray2[0].Trim(), out index);
  17709. if (1 < transArray2.Length) companyName = transArray2[1];
  17710. if (2 < transArray2.Length) job = transArray2[2];
  17711. }
  17712. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  17713. }
  17714. }
  17715. }
  17716. }
  17717. //循环赋值
  17718. for (int i = 0; i < DcList.Count; i++)
  17719. {
  17720. string PYName = "";
  17721. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  17722. {
  17723. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  17724. string PY_First = DcList[i].Pinyin.Split('/')[1];
  17725. PYName = PY_First + " " + PY_Last;
  17726. }
  17727. else
  17728. {
  17729. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  17730. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  17731. PYName = PY_First + " " + PY_Last;
  17732. }
  17733. builder.MoveToCell(0, i + 1, 0, 0);
  17734. builder.Write(PYName);
  17735. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  17736. builder.MoveToCell(0, i + 1, 1, 0);
  17737. builder.Write(sex);
  17738. DateTime birthDt;
  17739. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  17740. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  17741. builder.MoveToCell(0, i + 1, 2, 0);
  17742. builder.Write(birthday);
  17743. string company = string.Empty, job = string.Empty;
  17744. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  17745. if (dcTransInfo != null)
  17746. {
  17747. company = dcTransInfo.CompanyName;
  17748. job = dcTransInfo.Job;
  17749. }
  17750. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  17751. {
  17752. //查询对照表
  17753. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  17754. if (tempCec != null)
  17755. {
  17756. company = tempCec.enName;
  17757. }
  17758. //翻译
  17759. else
  17760. {
  17761. }
  17762. }
  17763. builder.MoveToCell(0, i + 1, 3, 0);
  17764. builder.Write(company);
  17765. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  17766. {
  17767. //查询对照表
  17768. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  17769. if (tempPec != null)
  17770. {
  17771. job = tempPec.enName;
  17772. }
  17773. //翻译
  17774. else
  17775. {
  17776. }
  17777. }
  17778. builder.MoveToCell(0, i + 1, 4, 0);
  17779. builder.Write(job);
  17780. }
  17781. }
  17782. //删除多余行
  17783. while (tableOne.Rows.Count > DcList.Count + 1)
  17784. {
  17785. tableOne.Rows.RemoveAt(DcList.Count + 1);
  17786. }
  17787. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  17788. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  17789. doc.Save(fileDir);
  17790. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  17791. return Ok(JsonView(true, "操作成功!", Url));
  17792. }
  17793. private class TranslateInfo
  17794. {
  17795. public int Index { get; set; }
  17796. public string CompanyName { get; set; }
  17797. public string Job { get; set; }
  17798. }
  17799. #endregion
  17800. #region 团组倒推表
  17801. /// <summary>
  17802. /// 倒推表基础数据
  17803. /// Init
  17804. /// </summary>
  17805. /// <returns></returns>
  17806. [HttpPost]
  17807. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17808. public async Task<IActionResult> PostInvertedListInit()
  17809. {
  17810. var viewData = await _invertedListRep._Init();
  17811. if (viewData.Code != 0)
  17812. {
  17813. return Ok(JsonView(false, viewData.Msg));
  17814. }
  17815. return Ok(JsonView(viewData.Data));
  17816. }
  17817. /// <summary>
  17818. /// 倒推表
  17819. /// Info
  17820. /// </summary>
  17821. /// <param name="dto"></param>
  17822. /// <returns></returns>
  17823. [HttpPost]
  17824. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17825. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  17826. {
  17827. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  17828. if (viewData.Code != 0)
  17829. {
  17830. return Ok(JsonView(false, viewData.Msg));
  17831. }
  17832. return Ok(JsonView(viewData.Data));
  17833. }
  17834. /// <summary>
  17835. /// 倒推表
  17836. /// Create
  17837. /// </summary>
  17838. /// <param name="dto"></param>
  17839. /// <returns></returns>
  17840. [HttpPost]
  17841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17842. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  17843. {
  17844. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  17845. if (viewData.Code != 0)
  17846. {
  17847. return Ok(JsonView(false, viewData.Msg));
  17848. }
  17849. return Ok(JsonView(viewData.Data));
  17850. }
  17851. /// <summary>
  17852. /// 倒推表
  17853. /// Update
  17854. /// </summary>
  17855. /// <param name="dto"></param>
  17856. /// <returns></returns>
  17857. [HttpPost]
  17858. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17859. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  17860. {
  17861. var viewData = await _invertedListRep._Update(dto);
  17862. if (viewData.Code != 0)
  17863. {
  17864. return Ok(JsonView(false, viewData.Msg));
  17865. }
  17866. return Ok(JsonView(viewData.Data));
  17867. }
  17868. /// <summary>
  17869. /// 倒推表
  17870. /// File Download
  17871. /// </summary>
  17872. /// <param name="dto"></param>
  17873. /// <returns></returns>
  17874. [HttpPost]
  17875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17876. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  17877. {
  17878. var info2 = await _invertedListRep._Info(1, dto.DiId);
  17879. if (info2.Code != 0)
  17880. {
  17881. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  17882. }
  17883. var info1 = info2.Data as InvertedListInfoView;
  17884. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  17885. string teamName = "";
  17886. if (info != null) teamName = info.TeamName;
  17887. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  17888. var doc = new Document();
  17889. var builder = new DocumentBuilder(doc);
  17890. #region old insert
  17891. ////载入模板
  17892. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  17893. //Document doc = new Document(tempPath);
  17894. //DocumentBuilder builder = new DocumentBuilder(doc);
  17895. //利用键值对存放数据
  17896. //Dictionary<string, string> dic = new Dictionary<string, string>();
  17897. //dic.Add("TeamName", teamName);
  17898. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  17899. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  17900. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  17901. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  17902. //dic.Add("SQRemark", info1.ApprovalRemark);
  17903. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  17904. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  17905. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  17906. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  17907. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  17908. //dic.Add("QZRemark", info1.VisaInformationRemark);
  17909. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  17910. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  17911. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  17912. //dic.Add("CQRemark", info1.IssueVisaRemark);
  17913. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  17914. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  17915. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  17916. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  17917. //#region 填充word模板书签内容
  17918. //foreach (var key in dic.Keys)
  17919. //{
  17920. // builder.MoveToBookmark(key);
  17921. // builder.Write(dic[key]);
  17922. //}
  17923. //#endregion
  17924. #endregion
  17925. #region New Insert
  17926. string titleFont = $"仿宋",
  17927. contentFont = $"仿宋";
  17928. var fontColor = Color.FromArgb(64, 64, 64);
  17929. //设置标题 团组名称
  17930. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17931. builder.Font.Name = titleFont;
  17932. builder.Font.Color = fontColor;
  17933. builder.Font.Size = 12;
  17934. builder.Font.Bold = true;
  17935. builder.Writeln(teamName);
  17936. //设置副标题 团组出访时间
  17937. builder.Font.Size = 12;
  17938. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  17939. builder.Writeln();
  17940. var backgroundColor = Color.FromArgb(199, 199, 199);
  17941. var table = builder.StartTable();
  17942. builder.InsertCell();
  17943. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  17944. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  17945. builder.CellFormat.Borders.LineWidth = 1;
  17946. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  17947. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  17948. builder.RowFormat.Height = 40;
  17949. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17950. builder.Font.Name = contentFont;
  17951. builder.Font.Size = 12;
  17952. builder.Font.Bold = true;
  17953. builder.Font.Color = fontColor;
  17954. builder.Write("时间");
  17955. builder.InsertCell();
  17956. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  17957. builder.Write("流程");
  17958. builder.InsertCell();
  17959. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  17960. builder.Write("说明");
  17961. builder.EndRow();
  17962. //报批资料准备
  17963. if (info1.IsSelectedAirportd)
  17964. {
  17965. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  17966. }
  17967. //报批/提供送签资料
  17968. if (info1.IsSelectedApprovalData)
  17969. {
  17970. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  17971. }
  17972. //出批件护照办理
  17973. if (info1.IsSelectedIssueApproval)
  17974. {
  17975. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  17976. }
  17977. //签证资料准备
  17978. if (info1.IsSelectedVisaInfo)
  17979. {
  17980. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  17981. }
  17982. //送签
  17983. if (info1.IsSelectedSendVisa)
  17984. {
  17985. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  17986. }
  17987. //出签
  17988. if (info1.IsSelectedIssueVisa)
  17989. {
  17990. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  17991. }
  17992. //机票
  17993. if (info1.IsSelectedAirTicket)
  17994. {
  17995. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  17996. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  17997. }
  17998. //酒店
  17999. if (info1.IsSelectedHotel)
  18000. {
  18001. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  18002. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  18003. }
  18004. //开行前会
  18005. if (info1.IsSelectedPreTripMeeting)
  18006. {
  18007. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  18008. }
  18009. //送机
  18010. if (info1.IsSelectedAirportdDropOff)
  18011. {
  18012. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  18013. }
  18014. builder.EndTable();
  18015. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  18016. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  18017. for (int i = 0; i < table.Rows.Count; i++)
  18018. {
  18019. var row = table.Rows[i];
  18020. //设置宽度
  18021. row.Cells[0].CellFormat.Width = 20.00;
  18022. row.Cells[1].CellFormat.Width = 30.00;
  18023. row.Cells[2].CellFormat.Width = 50.00;
  18024. if (i != 0)
  18025. {
  18026. //边框设置
  18027. InvertedListFileDownloadSetBorders(row.Cells, 0);
  18028. InvertedListFileDownloadSetBorders(row.Cells, 1);
  18029. InvertedListFileDownloadSetBorders(row.Cells, 2);
  18030. }
  18031. }
  18032. #region 页脚插入图片
  18033. // 创建页脚
  18034. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  18035. doc.FirstSection.HeadersFooters.Add(footer);
  18036. Paragraph para = new Paragraph(doc);
  18037. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  18038. footer.AppendChild(para);
  18039. builder.MoveTo(para);
  18040. string imagePath = "./Images/FMGJ_Log.png";
  18041. builder.InsertImage(imagePath);
  18042. #endregion
  18043. #endregion
  18044. var fileDir = AppSettingsHelper.Get("WordBasePath");
  18045. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  18046. string filePath = fileDir + $@"InvertedList/{fileName}";
  18047. doc.Save(filePath);
  18048. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  18049. return Ok(JsonView(true, "操作成功!", Url));
  18050. }
  18051. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  18052. {
  18053. var fontColor = Color.FromArgb(64, 64, 64);
  18054. builder.InsertCell();
  18055. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  18056. builder.RowFormat.Height = 40;
  18057. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  18058. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  18059. builder.Font.Name = fontName;
  18060. builder.Font.Size = 8;
  18061. builder.Font.Bold = true;
  18062. builder.Font.Color = fontColor;
  18063. builder.Write(dateTime);
  18064. builder.InsertCell();
  18065. builder.Font.Size = 9;
  18066. builder.Font.Bold = true;
  18067. builder.Font.Color = fontColor;
  18068. builder.Write(content);
  18069. builder.InsertCell();
  18070. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  18071. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  18072. builder.Font.Size = 9;
  18073. builder.Font.Bold = false;
  18074. builder.Font.Color = fontColor;
  18075. builder.Write(reamrk);
  18076. builder.EndRow();
  18077. }
  18078. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  18079. {
  18080. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  18081. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  18082. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  18083. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  18084. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  18085. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  18086. }
  18087. #endregion
  18088. #region 会务倒推表
  18089. /// <summary>
  18090. /// 会务倒推表
  18091. /// Init
  18092. /// </summary>
  18093. /// <returns></returns>
  18094. [HttpPost]
  18095. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18096. public async Task<IActionResult> InforRetrogressTableInit()
  18097. {
  18098. var groupData = await _groupRepository.PostShareGroupInfos(1);
  18099. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  18100. return Ok(JsonView(false, groupData.Msg));
  18101. }
  18102. /// <summary>
  18103. /// 会务倒推表
  18104. /// ExcelDownload
  18105. /// </summary>
  18106. /// <param name="dto"></param>
  18107. /// <returns></returns>
  18108. [HttpPost]
  18109. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  18110. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18111. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  18112. {
  18113. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  18114. var validatorRes = await validator.ValidateAsync(dto);
  18115. if (!validatorRes.IsValid)
  18116. {
  18117. StringBuilder sb = new StringBuilder();
  18118. foreach (var item in validatorRes.Errors)
  18119. {
  18120. sb.AppendLine(item.ErrorMessage);
  18121. }
  18122. return Ok(JsonView(false, sb.ToString()));
  18123. }
  18124. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  18125. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  18126. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  18127. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  18128. #region Excel
  18129. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  18130. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  18131. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  18132. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  18133. var fileNamePrefix = string.Empty;
  18134. if (days >= 30)
  18135. {
  18136. tempPath += $"会务工作倒推进度表(30天).xlsx";
  18137. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  18138. }
  18139. else if (days < 30 && days > 7)
  18140. {
  18141. tempPath += $"会务工作倒推进度表(15天).xlsx";
  18142. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  18143. }
  18144. else if (days <= 7)
  18145. {
  18146. tempPath += $"会务工作倒推进度表(7天).xlsx";
  18147. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  18148. }
  18149. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  18150. fileName = CommonFun.ValidFileName(fileName);
  18151. //载入模板
  18152. WorkbookDesigner designer = new WorkbookDesigner();
  18153. designer.Workbook = new Workbook(tempPath);
  18154. designer.Process();
  18155. if (!Directory.Exists(savePath))
  18156. {
  18157. Directory.CreateDirectory(savePath);
  18158. }
  18159. string serverPath = $"{savePath}{fileName}";
  18160. designer.Workbook.Save(serverPath);
  18161. string rst = $"{servicePath}{ftpPath}{fileName}";
  18162. #endregion
  18163. return Ok(JsonView(new { url = rst }));
  18164. }
  18165. #endregion
  18166. #region 三公签证费用(签证费、代办费)
  18167. /// <summary>
  18168. /// 三公签证费用(签证费、代办费)
  18169. /// List
  18170. /// </summary>
  18171. /// <returns></returns>
  18172. [HttpPost]
  18173. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18174. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  18175. {
  18176. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  18177. if (_view.Code != 0)
  18178. {
  18179. return Ok(JsonView(false, _view.Msg));
  18180. }
  18181. return Ok(JsonView(true, "操作成功!", _view.Data));
  18182. }
  18183. /// <summary>
  18184. /// 三公签证费用(签证费、代办费)
  18185. /// Add Or Update
  18186. /// </summary>
  18187. /// <returns></returns>
  18188. [HttpPost]
  18189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18190. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  18191. {
  18192. var _view = await _visaFeeInfoRep._Update(_dto);
  18193. if (_view.Code != 0)
  18194. {
  18195. return Ok(JsonView(false, _view.Msg));
  18196. }
  18197. return Ok(JsonView(true, _view.Msg));
  18198. }
  18199. #endregion
  18200. #region 酒店询价
  18201. /// <summary>
  18202. /// 酒店询价
  18203. /// Init
  18204. /// </summary>
  18205. /// <returns></returns>
  18206. [HttpPost]
  18207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18208. public async Task<IActionResult> PostHotelInquiryInit()
  18209. {
  18210. var res = await _hotelInquiryRep._Init();
  18211. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18212. return Ok(JsonView(true, res.Msg, res.Data));
  18213. }
  18214. /// <summary>
  18215. /// 酒店询价
  18216. /// page Item
  18217. /// </summary>
  18218. /// <param name="_dto"></param>
  18219. /// <returns></returns>
  18220. [HttpPost]
  18221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18222. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  18223. {
  18224. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  18225. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18226. var view = res.Data as PageDataViewBase;
  18227. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  18228. }
  18229. /// <summary>
  18230. /// 酒店询价
  18231. /// info
  18232. /// </summary>
  18233. /// <param name="_dto"></param>
  18234. /// <returns></returns>
  18235. [HttpPost]
  18236. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18237. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  18238. {
  18239. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  18240. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18241. return Ok(JsonView(true, res.Msg, res.Data));
  18242. }
  18243. /// <summary>
  18244. /// 酒店询价
  18245. /// Add Or Edit
  18246. /// </summary>
  18247. /// <param name="_dto"></param>
  18248. /// <returns></returns>
  18249. [HttpPost]
  18250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18251. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  18252. {
  18253. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  18254. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18255. return Ok(JsonView(true, res.Msg, res.Data));
  18256. }
  18257. /// <summary>
  18258. /// 酒店询价
  18259. /// Del
  18260. /// </summary>
  18261. /// <param name="_dto"></param>
  18262. /// <returns></returns>
  18263. [HttpPost]
  18264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18265. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  18266. {
  18267. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  18268. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18269. return Ok(JsonView(true, res.Msg, res.Data));
  18270. }
  18271. #endregion
  18272. #region 下载匹配op行程单
  18273. /// <summary>
  18274. /// 匹配op行程单
  18275. /// Init
  18276. /// </summary>
  18277. /// <param name="dto">团组列表请求dto</param>
  18278. /// <returns></returns>
  18279. [HttpPost]
  18280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18281. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  18282. {
  18283. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  18284. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18285. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  18286. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  18287. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  18288. .Where(it => it.IsDel == 0)
  18289. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  18290. .OrderByDescending(it => it.VisitStartDate)
  18291. .ToList();
  18292. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  18293. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  18294. var diids = groupInfos.Select(it => it.Id).ToList();
  18295. List<string> countrys = new List<string>();
  18296. foreach (var item in country)
  18297. {
  18298. var data = _groupRepository.FormartTeamName(item);
  18299. var dataArray = _groupRepository.GroupSplitCountry(data);
  18300. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  18301. }
  18302. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  18303. List<string> areaArray = new List<string>(); //GetGroupCityLine
  18304. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  18305. foreach (var item in areaItem)
  18306. {
  18307. string areaStr = item.Value;
  18308. if (!string.IsNullOrEmpty(areaStr))
  18309. {
  18310. string[] str1 = areaStr.Split("-");
  18311. if (str1.Length > 0)
  18312. {
  18313. areaArray.AddRange(str1);
  18314. }
  18315. }
  18316. }
  18317. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  18318. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  18319. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  18320. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  18321. .ToList();
  18322. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  18323. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  18324. .Where(it => countriesIds.Contains(it.Id))
  18325. .Select(it => new { it.Id, Name = it.Name_CN })
  18326. .ToList();
  18327. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  18328. .Select(it => it.TeamName).ToList();
  18329. stopwatch.Stop();
  18330. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  18331. }
  18332. ///// <summary>
  18333. ///// 匹配op行程单
  18334. ///// Init 查询区域数据
  18335. ///// </summary>
  18336. ///// <param name="dto">团组列表请求dto</param>
  18337. ///// <returns></returns>
  18338. //[HttpPost]
  18339. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18340. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  18341. //{
  18342. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  18343. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  18344. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  18345. // if (string.IsNullOrEmpty(countriesDataStr))
  18346. // {
  18347. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  18348. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  18349. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  18350. // }
  18351. // else
  18352. // {
  18353. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  18354. // }
  18355. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  18356. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  18357. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  18358. // List<dynamic> childList = new List<dynamic>();
  18359. // int parentId = dto.CountriesId;
  18360. // if (provinceData.Count > 1)
  18361. // {
  18362. // foreach (var item1 in provinceData)
  18363. // {
  18364. // List<dynamic> childList1 = new List<dynamic>();
  18365. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  18366. // foreach (var item2 in citiesData1)
  18367. // {
  18368. // List<dynamic> childList2 = new List<dynamic>();
  18369. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  18370. // foreach (var item3 in countiesData1)
  18371. // {
  18372. // childList2.Add(new
  18373. // {
  18374. // id = item3.Id,
  18375. // parentId = item2.Id,
  18376. // level = "district",
  18377. // name = item3.Name_CN,
  18378. // });
  18379. // }
  18380. // childList1.Add(new
  18381. // {
  18382. // id = item2.Id,
  18383. // parentId = item1.Id,
  18384. // level = "city",
  18385. // name = item2.Name_CN,
  18386. // childList = childList2
  18387. // });
  18388. // }
  18389. // childList.Add(new
  18390. // {
  18391. // id = item1.Id,
  18392. // parentId = parentId,
  18393. // level = "province",
  18394. // name = item1.Name_CN,
  18395. // childList = childList1
  18396. // });
  18397. // }
  18398. // //城市
  18399. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  18400. // foreach (var item2 in citiesData2)
  18401. // {
  18402. // List<dynamic> childList22 = new List<dynamic>();
  18403. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  18404. // foreach (var item3 in countiesData1)
  18405. // {
  18406. // childList22.Add(new
  18407. // {
  18408. // id = item3.Id,
  18409. // parentId = item2.Id,
  18410. // level = "district",
  18411. // name = item3.Name_CN,
  18412. // });
  18413. // }
  18414. // childList.Add(new
  18415. // {
  18416. // id = item2.Id,
  18417. // parentId = parentId,
  18418. // level = "city",
  18419. // name = item2.Name_CN,
  18420. // childList = childList22
  18421. // });
  18422. // }
  18423. // }
  18424. // else
  18425. // {
  18426. // foreach (var item2 in citiesData)
  18427. // {
  18428. // string cname = item2.Name_CN;
  18429. // List<dynamic> childList1 = new List<dynamic>();
  18430. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  18431. // foreach (var item3 in countiesData1)
  18432. // {
  18433. // childList1.Add(new
  18434. // {
  18435. // Id = item3.Id,
  18436. // parentId = item2.Id,
  18437. // level = "district",
  18438. // name = item3.Name_CN
  18439. // });
  18440. // }
  18441. // childList.Add(new
  18442. // {
  18443. // id = item2.Id,
  18444. // parentId = parentId,
  18445. // level = "city",
  18446. // name = item2.Name_CN,
  18447. // childList = childList1
  18448. // });
  18449. // }
  18450. // }
  18451. // stopwatch.Stop();
  18452. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  18453. //}
  18454. /// <summary>
  18455. /// 匹配op行程单
  18456. /// 接团信息列表 Page
  18457. /// </summary>
  18458. /// <param name="dto">团组列表请求dto</param>
  18459. /// <returns></returns>
  18460. [HttpPost]
  18461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18462. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  18463. {
  18464. var swatch = new Stopwatch();
  18465. swatch.Start();
  18466. #region 参数验证
  18467. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18468. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  18469. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18470. #region 页面操作权限验证
  18471. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  18472. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  18473. #endregion
  18474. #endregion
  18475. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  18476. {
  18477. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  18478. //string sqlWhere = "";
  18479. if (!string.IsNullOrEmpty(dto.Country))
  18480. {
  18481. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  18482. }
  18483. if (!string.IsNullOrEmpty(dto.Area))
  18484. {
  18485. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  18486. }
  18487. if (!string.IsNullOrEmpty(dto.TeamName))
  18488. {
  18489. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  18490. }
  18491. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  18492. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  18493. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  18494. swatch.Stop();
  18495. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  18496. }
  18497. else
  18498. {
  18499. return Ok(JsonView(false, "查询失败"));
  18500. }
  18501. }
  18502. /// <summary>
  18503. /// 匹配op行程单
  18504. /// 行程单下载
  18505. /// </summary>
  18506. /// <param name="dto">团组列表请求dto</param>
  18507. /// <returns></returns>
  18508. [HttpPost]
  18509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18510. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  18511. {
  18512. #region 参数验证
  18513. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18514. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  18515. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18516. #region 页面操作权限验证
  18517. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  18518. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  18519. #endregion
  18520. #endregion
  18521. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  18522. {
  18523. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  18524. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  18525. }
  18526. else
  18527. {
  18528. return Ok(JsonView(false, "下载失败!"));
  18529. }
  18530. }
  18531. #endregion
  18532. #region 国家信息 数据 注释
  18533. //[HttpPost]
  18534. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  18535. //{
  18536. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  18537. // foreach (var item in dto)
  18538. // {
  18539. // infos.Add(new Grp_GroupsTaskAssignment()
  18540. // {
  18541. // DIId = item,
  18542. // CTId = 82,
  18543. // UId = 248,
  18544. // IsEnable = 1,
  18545. // CreateUserId = 233,
  18546. // CreateTime = DateTime.Now,
  18547. // IsDel = 0
  18548. // });
  18549. // infos.Add(new Grp_GroupsTaskAssignment()
  18550. // {
  18551. // DIId = item,
  18552. // CTId = 82,
  18553. // UId = 286,
  18554. // IsEnable = 1,
  18555. // CreateUserId = 233,
  18556. // CreateTime = DateTime.Now,
  18557. // IsDel = 0
  18558. // });
  18559. // }
  18560. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  18561. // return Ok("操作成功");
  18562. //}
  18563. //public class paramJsonDto
  18564. //{
  18565. // public List<CountriesInfo> str { get; set; }
  18566. //}
  18567. //[HttpPost]
  18568. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  18569. //{
  18570. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  18571. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  18572. // List<Sys_Cities> cities = new List<Sys_Cities>();
  18573. // List<Sys_Cities> districts = new List<Sys_Cities>();
  18574. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  18575. // _sqlSugar.BeginTran();
  18576. // int countitiesIndex = 0;
  18577. // foreach (var item in dto.str)
  18578. // {
  18579. // dynamic data = item.c;
  18580. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  18581. // if (data != null)
  18582. // {
  18583. // countitiesIndex++;
  18584. // foreach (var item1 in data)
  18585. // {
  18586. // string cnname = item1.cn;
  18587. // string enname = item1.en;
  18588. // Sys_Cities provinceInfo = new Sys_Cities()
  18589. // {
  18590. // CountriesId = countriesId,
  18591. // Name_CN = cnname,
  18592. // Name_EN = enname,
  18593. // ParentId = 0,
  18594. // IsCapital = 1,
  18595. // CreateUserId = 208,
  18596. // CreateTime = DateTime.Now,
  18597. // IsDel = 0
  18598. // };
  18599. // if (item1.lv == "province") //省份
  18600. // {
  18601. // provinceInfo.Level = 1;
  18602. // int provinceId = 0;
  18603. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  18604. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  18605. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  18606. // var data1 = item1.c;
  18607. // foreach (var item2 in data1)
  18608. // {
  18609. // if (item2.lv == "city")
  18610. // {
  18611. // string citycnname = item2.cn;
  18612. // string cityenname = item2.en;
  18613. // Sys_Cities cityInfo = new Sys_Cities()
  18614. // {
  18615. // CountriesId = countriesId,
  18616. // ParentId = provinceId,
  18617. // Level = 2,
  18618. // Name_CN = citycnname,
  18619. // Name_EN = cityenname,
  18620. // IsCapital = 1,
  18621. // CreateUserId = 208,
  18622. // CreateTime = DateTime.Now,
  18623. // IsDel = 0
  18624. // };
  18625. // if (item2.c != null)
  18626. // {
  18627. // int cityId = 0;
  18628. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  18629. // if (citiesInfo != null) cityId = citiesInfo.Id;
  18630. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  18631. // foreach (var item3 in item2.c)
  18632. // {
  18633. // if (item3.lv == "district")
  18634. // {
  18635. // var districtInfo = new Sys_Cities()
  18636. // {
  18637. // CountriesId = countriesId,
  18638. // Name_CN = item3.cn,
  18639. // Name_EN = item3.en,
  18640. // Level = 3,
  18641. // ParentId = cityId,
  18642. // IsCapital = 1,
  18643. // CreateUserId = 208,
  18644. // CreateTime = DateTime.Now,
  18645. // IsDel = 0
  18646. // };
  18647. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  18648. // //{
  18649. // districts.Add(districtInfo);
  18650. // //}
  18651. // }
  18652. // }
  18653. // }
  18654. // else
  18655. // {
  18656. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  18657. // //{
  18658. // cities.Add(cityInfo);
  18659. // //}
  18660. // }
  18661. // }
  18662. // }
  18663. // }
  18664. // else if (item1.lv == "city")//城市
  18665. // {
  18666. // provinceInfo.Level = 2;
  18667. // if (item1.c != null)
  18668. // {
  18669. // int cityId = 0;
  18670. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  18671. // if (citiesInfo != null) cityId = citiesInfo.Id;
  18672. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  18673. // foreach (var item3 in item1.c)
  18674. // {
  18675. // if (item3.lv == "district")
  18676. // {
  18677. // var districtInfo = new Sys_Cities()
  18678. // {
  18679. // CountriesId = countriesId,
  18680. // Name_CN = item3.cn,
  18681. // Name_EN = item3.en,
  18682. // Level = 3,
  18683. // ParentId = cityId,
  18684. // IsCapital = 1,
  18685. // CreateUserId = 208,
  18686. // CreateTime = DateTime.Now,
  18687. // IsDel = 0
  18688. // };
  18689. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  18690. // //{
  18691. // districts.Add(districtInfo);
  18692. // //}
  18693. // }
  18694. // }
  18695. // }
  18696. // else
  18697. // {
  18698. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  18699. // //{
  18700. // cities.Add(provinceInfo);
  18701. // //}
  18702. // }
  18703. // }
  18704. // }
  18705. // }
  18706. // }
  18707. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  18708. // cities = cities.Distinct().ToList();
  18709. // districts = districts.Distinct().ToList();
  18710. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  18711. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  18712. // cities.AddRange(districts);
  18713. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  18714. // //_sqlSugar.RollbackTran();
  18715. // _sqlSugar.CommitTran();
  18716. // return Ok(JsonView(false, "操作成功!"));
  18717. //}
  18718. //[HttpPost]
  18719. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  18720. //{
  18721. // List<CountitiesInfo> infos = dto.MyProperty;
  18722. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  18723. // _sqlSugar.BeginTran();
  18724. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  18725. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  18726. // foreach (var item in infos)
  18727. // {
  18728. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  18729. // if (countryInfo != null)
  18730. // {
  18731. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  18732. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  18733. // if (cityInfo1 != null)
  18734. // {
  18735. // cityInfo1.IsCapital = 0;
  18736. // cityInfos.Add(cityInfo1);
  18737. // }
  18738. // }
  18739. // }
  18740. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  18741. // .UpdateColumns(it => it.IsCapital)
  18742. // .WhereColumns(it => it.Id)
  18743. // .ExecuteCommand();
  18744. // //_sqlSugar.RollbackTran();
  18745. // _sqlSugar.CommitTran();
  18746. // return Ok(JsonView(false, "操作成功!"));
  18747. //}
  18748. //public class CounrtiesDto
  18749. //{
  18750. // public List<CountitiesInfo> MyProperty { get; set; }
  18751. //}
  18752. //public class CountitiesInfo
  18753. //{
  18754. // /// <summary>
  18755. // /// 圣约翰
  18756. // /// </summary>
  18757. // public string capital_name_chinese { get; set; }
  18758. // /// <summary>
  18759. // ///
  18760. // /// </summary>
  18761. // public string capital_name { get; set; }
  18762. // /// <summary>
  18763. // ///
  18764. // /// </summary>
  18765. // public string country_type { get; set; }
  18766. // /// <summary>
  18767. // /// 安提瓜和巴布达
  18768. // /// </summary>
  18769. // public string country_name_chinese { get; set; }
  18770. // /// <summary>
  18771. // /// 安提瓜和巴布达
  18772. // /// </summary>
  18773. // public string country_name_chinese_short { get; set; }
  18774. // /// <summary>
  18775. // /// 安提瓜和巴布达
  18776. // /// </summary>
  18777. // public string country_name_chinese_UN { get; set; }
  18778. // /// <summary>
  18779. // ///
  18780. // /// </summary>
  18781. // public string country_name_english_abbreviation { get; set; }
  18782. // /// <summary>
  18783. // ///
  18784. // /// </summary>
  18785. // public string country_name_english_formal { get; set; }
  18786. // /// <summary>
  18787. // ///
  18788. // /// </summary>
  18789. // public string country_name_english_UN { get; set; }
  18790. // /// <summary>
  18791. // ///
  18792. // /// </summary>
  18793. // public string continent_name { get; set; }
  18794. // /// <summary>
  18795. // ///
  18796. // /// </summary>
  18797. // public string subregion_name { get; set; }
  18798. // /// <summary>
  18799. // ///
  18800. // /// </summary>
  18801. // public string country_code2 { get; set; }
  18802. // /// <summary>
  18803. // ///
  18804. // /// </summary>
  18805. // public string country_code3 { get; set; }
  18806. // /// <summary>
  18807. // ///
  18808. // /// </summary>
  18809. // public string phone_code { get; set; }
  18810. //}
  18811. //public class CountriesInfo : BasicInfo
  18812. //{
  18813. // public List<CitiesInfo> c { get; set; }
  18814. //}
  18815. //public class CitiesInfo : BasicInfo
  18816. //{
  18817. // public List<AreaInfo> c { get; set; }
  18818. //}
  18819. //public class AreaInfo : BasicInfo
  18820. //{
  18821. // public List<AreaInfo> c { get; set; }
  18822. //}
  18823. //public class BasicInfo
  18824. //{
  18825. // public string code { get; set; }
  18826. // public string cn { get; set; }
  18827. // public string lv { get; set; }
  18828. // public string en { get; set; }
  18829. //}
  18830. #endregion
  18831. #region 查看邀请方
  18832. /// <summary>
  18833. /// 查看邀请方
  18834. /// 邀请方信息 Init
  18835. /// </summary>
  18836. /// <param name="dto"></param>
  18837. /// <returns></returns>
  18838. [HttpPost]
  18839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18840. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  18841. {
  18842. string sqlWhere = string.Empty;
  18843. if (!string.IsNullOrEmpty(dto.Search))
  18844. {
  18845. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  18846. }
  18847. string sql = string.Format($@"Select
  18848. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  18849. Id,
  18850. UnitName
  18851. From Res_InvitationOfficialActivityData
  18852. Where IsDel = 0
  18853. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  18854. RefAsync<int> total = 0;
  18855. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18856. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  18857. }
  18858. /// <summary>
  18859. /// 查看邀请方
  18860. /// 国家信息 Init
  18861. /// </summary>
  18862. /// <param name="dto"></param>
  18863. /// <returns></returns>
  18864. [HttpPost]
  18865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18866. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  18867. {
  18868. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  18869. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  18870. var diids = groupInfos.Select(it => it.Id).ToList();
  18871. List<string> countrys = new List<string>();
  18872. foreach (var item in country)
  18873. {
  18874. var data = _groupRepository.FormartTeamName(item);
  18875. var dataArray = _groupRepository.GroupSplitCountry(data);
  18876. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  18877. }
  18878. countrys = countrys.Distinct().ToList();
  18879. for (int i = 0; i < countrys.Count; i++)
  18880. {
  18881. string item = countrys[i];
  18882. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  18883. {
  18884. countrys.Remove(item);
  18885. i--;
  18886. }
  18887. }
  18888. RefAsync<int> total = 0;
  18889. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  18890. .Where(it => countrys.Contains(it.Name_CN))
  18891. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18892. .Select(it => new { id = it.Id, name = it.Name_CN })
  18893. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18894. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18895. }
  18896. /// <summary>
  18897. /// 查看邀请方
  18898. /// 城市信息 Init
  18899. /// </summary>
  18900. /// <param name="dto"></param>
  18901. /// <returns></returns>
  18902. [HttpPost]
  18903. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18904. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  18905. {
  18906. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  18907. RefAsync<int> total = 0;
  18908. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  18909. .Where(it => it.CountriesId == dto.CountiesId)
  18910. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18911. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  18912. .Select(it => new { id = it.Id, name = it.Name_CN })
  18913. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18914. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18915. }
  18916. /// <summary>
  18917. /// 查看邀请方
  18918. /// 团组名称 Init
  18919. /// </summary>
  18920. /// <param name="dto"></param>
  18921. /// <returns></returns>
  18922. [HttpPost]
  18923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18924. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  18925. {
  18926. var watch = new Stopwatch();
  18927. watch.Start();
  18928. RefAsync<int> total = 0;
  18929. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  18930. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  18931. .Where((oa, di) => oa.IsDel == 0)
  18932. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  18933. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  18934. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  18935. .Distinct()
  18936. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18937. watch.Stop();
  18938. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  18939. }
  18940. /// <summary>
  18941. /// 查看邀请方
  18942. /// 团组 & 邀请方信息
  18943. /// </summary>
  18944. /// <param name="dto"></param>
  18945. /// <returns></returns>
  18946. [HttpPost]
  18947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18948. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  18949. {
  18950. var watch = new Stopwatch();
  18951. watch.Start();
  18952. RefAsync<int> total = 0;
  18953. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  18954. .AS("Grp_DelegationInfo")
  18955. .Includes(x => x.InvitingInfos)
  18956. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  18957. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  18958. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  18959. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  18960. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  18961. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  18962. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18963. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  18964. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  18965. infos.ForEach(x =>
  18966. {
  18967. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  18968. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  18969. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  18970. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  18971. });
  18972. watch.Stop();
  18973. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  18974. }
  18975. #endregion
  18976. #region 报批行程
  18977. /// <summary>
  18978. /// 报批行程初始化
  18979. /// </summary>
  18980. /// <param name="dto"></param>
  18981. /// <returns></returns>
  18982. [HttpPost]
  18983. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  18984. {
  18985. const int chiNumber = 5;
  18986. var jw = JsonView(false);
  18987. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  18988. var group = groupList.First();
  18989. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  18990. group = groupList.First(x => x.Id == diid);
  18991. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18992. .Where(x => x.DiId == diid && x.IsDel == 0)
  18993. .ToArray();
  18994. var count = 1;
  18995. foreach (var item in blackCodeList)
  18996. {
  18997. if (string.IsNullOrWhiteSpace(item.Title))
  18998. {
  18999. item.Title = "未设置名称数据" + count;
  19000. }
  19001. count++;
  19002. };
  19003. if (group == null)
  19004. {
  19005. jw.Msg = "暂无团组!";
  19006. return Ok(jw);
  19007. }
  19008. var data = new
  19009. {
  19010. groupList = groupList.Select(x => new
  19011. {
  19012. x.TeamName,
  19013. x.Id
  19014. }),
  19015. content = new ArrayList(),
  19016. groupInfo = new
  19017. {
  19018. group.VisitDays,
  19019. group.TourCode,
  19020. group.VisitPNumber,
  19021. group.TeamName,
  19022. group.Id,
  19023. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  19024. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  19025. },
  19026. blackCodeList = blackCodeList.Select(x => new
  19027. {
  19028. x.Title,
  19029. x.Id
  19030. }),
  19031. FileTempList = new ArrayList()
  19032. {
  19033. new { Index = 1,FileName = "旧模板" },
  19034. new { Index = 2,FileName = "省外办" },
  19035. new { Index = 3,FileName = "市外办" },
  19036. }
  19037. };
  19038. var resultArr = new ArrayList();
  19039. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  19040. #region 默认不生成行程
  19041. //if (content.Count == 0)
  19042. //{
  19043. // var stay = "-";
  19044. // var cityPath = "-";
  19045. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  19046. // .Where(x => x.DiId == diid && x.IsDel == 0)
  19047. // .ToList();
  19048. // //添加城市路径以及住宿地
  19049. // //黑屏代码数据
  19050. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  19051. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  19052. // {
  19053. // jw = JsonView(true, "黑屏代码有误!", data);
  19054. // return Ok(jw);
  19055. // }
  19056. // data = data with
  19057. // {
  19058. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  19059. // {
  19060. // x.Title,
  19061. // x.Id,
  19062. // }).ToArray())
  19063. // };
  19064. // foreach (DataRow row in dtBlack.Rows)
  19065. // {
  19066. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  19067. // {
  19068. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  19069. // return Ok(jw);
  19070. // }
  19071. // }
  19072. // //黑屏代码获取时间区间
  19073. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  19074. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  19075. // _sqlSugar.BeginTran();
  19076. // for (int i = 0; i < timeArr.Count; i++)
  19077. // {
  19078. // stay = "-";
  19079. // cityPath = "-";
  19080. // DateTime NewData = DateTime.Parse(timeArr[i]);
  19081. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  19082. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  19083. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  19084. // if (tbSelect.Length > 0)
  19085. // {
  19086. // List<string> threeCodeStr = new List<string>();
  19087. // foreach (var item in tbSelect)
  19088. // {
  19089. // var threeCode = item["Three"].ToString() ?? "";
  19090. // if (threeCode.Length == 6)
  19091. // {
  19092. // var start = threeCode.Substring(0, 3);
  19093. // var end = threeCode.Substring(3, 3);
  19094. // if (threeCodeStr.Count == 0)
  19095. // {
  19096. // threeCodeStr.Add(start);
  19097. // threeCodeStr.Add(end);
  19098. // }
  19099. // else
  19100. // {
  19101. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  19102. // {
  19103. // threeCodeStr.Add(end);
  19104. // }
  19105. // else
  19106. // {
  19107. // threeCodeStr.Add(start);
  19108. // threeCodeStr.Add(end);
  19109. // }
  19110. // }
  19111. // }
  19112. // }
  19113. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  19114. // var last = threeCodeStr.Last();
  19115. // foreach (var item in threeCodeStr)
  19116. // {
  19117. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  19118. // if (item.Equals(last))
  19119. // {
  19120. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  19121. // }
  19122. // }
  19123. // cityPath = cityPath.Trim('-');
  19124. // }
  19125. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  19126. // appro.Diid = diid ?? -1;
  19127. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  19128. // appro.Id = thisId;
  19129. // appro.CreateUserId = dto.UserId;
  19130. // appro.CreateTime = DateTime.Now;
  19131. // content.Add(appro);
  19132. // }
  19133. // _sqlSugar.CommitTran();
  19134. //}
  19135. #endregion
  19136. foreach (var x in content)
  19137. {
  19138. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  19139. if (chiList.Count < chiNumber)
  19140. {
  19141. for (int i = chiList.Count; i < chiNumber; i++)
  19142. {
  19143. chiList.Add(new Grp_ApprovalTravelDetails());
  19144. }
  19145. }
  19146. resultArr.Add(new
  19147. {
  19148. x.Id,
  19149. x.Date,
  19150. x.Diid,
  19151. chiList = chiList.Select(x1 => new
  19152. {
  19153. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  19154. x1.Details,
  19155. x1.ParentId,
  19156. x1.Id
  19157. })
  19158. });
  19159. }
  19160. data = data with
  19161. {
  19162. content = resultArr,
  19163. };
  19164. jw = JsonView(true, "获取成功!", data);
  19165. return Ok(jw);
  19166. }
  19167. /// <summary>
  19168. /// 报批行程删除
  19169. /// </summary>
  19170. /// <param name="dto"></param>
  19171. /// <returns></returns>
  19172. [HttpPost]
  19173. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  19174. {
  19175. var jw = JsonView(false);
  19176. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  19177. if (group == null)
  19178. {
  19179. jw.Msg = "团组参数有误!";
  19180. return Ok(jw);
  19181. }
  19182. try
  19183. {
  19184. _sqlSugar.BeginTran();
  19185. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  19186. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  19187. {
  19188. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  19189. DeleteUserId = dto.uesrId,
  19190. IsDel = 1
  19191. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  19192. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  19193. {
  19194. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  19195. DeleteUserId = dto.uesrId,
  19196. IsDel = 1
  19197. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  19198. _sqlSugar.CommitTran();
  19199. jw = JsonView(true, "删除成功");
  19200. }
  19201. catch (Exception ex)
  19202. {
  19203. jw = JsonView(false, ex.Message);
  19204. }
  19205. return Ok(jw);
  19206. }
  19207. /// <summary>
  19208. /// 报批行程保存
  19209. /// </summary>
  19210. /// <param name="dto"></param>
  19211. /// <returns></returns>
  19212. [HttpPost]
  19213. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  19214. {
  19215. var jw = JsonView(false);
  19216. var Find = dto.Arr.Find(x => x.id == 0);
  19217. if (Find != null)
  19218. {
  19219. jw.Msg = "生成的ID为0!";
  19220. return Ok(jw);
  19221. }
  19222. foreach (var item in dto.Arr)
  19223. {
  19224. foreach (var chi in item.chiList)
  19225. {
  19226. if (chi.parentId == 0)
  19227. {
  19228. chi.parentId = item.id;
  19229. }
  19230. }
  19231. }
  19232. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  19233. _sqlSugar.BeginTran();
  19234. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  19235. {
  19236. var parentIds = dto.Arr.Select(x => x.id).ToList();
  19237. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  19238. {
  19239. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  19240. DeleteUserId = dto.UserId,
  19241. IsDel = 1
  19242. }).ExecuteCommand();
  19243. }
  19244. try
  19245. {
  19246. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  19247. {
  19248. CreateTime = DateTime.Now,
  19249. CreateUserId = dto.UserId,
  19250. Details = x.details,
  19251. ParentId = x.parentId,
  19252. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  19253. Remark = "",
  19254. IsDel = 0
  19255. }).ToList()).ExecuteCommand();
  19256. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  19257. {
  19258. Id = x.id,
  19259. Details = x.details,
  19260. ParentId = x.parentId,
  19261. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  19262. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  19263. {
  19264. Details = x.Details,
  19265. ParentId = x.ParentId,
  19266. Time = x.Time
  19267. }).ExecuteCommand();
  19268. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  19269. {
  19270. Id = x.id,
  19271. Date = x.date,
  19272. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  19273. {
  19274. Date = x.Date
  19275. }).ExecuteCommand();
  19276. _sqlSugar.CommitTran();
  19277. jw = JsonView(true, "保存成功!");
  19278. }
  19279. catch (Exception ex)
  19280. {
  19281. _sqlSugar.RollbackTran();
  19282. jw = JsonView(false, "保存失败!" + ex.Message);
  19283. }
  19284. return Ok(jw);
  19285. }
  19286. /// <summary>
  19287. /// 报批行程生成
  19288. /// </summary>
  19289. /// <param name="dto"></param>
  19290. /// <returns></returns>
  19291. [HttpPost]
  19292. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  19293. {
  19294. var jw = JsonView(false);
  19295. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  19296. if (group == null)
  19297. {
  19298. jw.Msg = "暂无该团组!";
  19299. return Ok(jw);
  19300. }
  19301. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  19302. //黑屏代码数据
  19303. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  19304. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  19305. {
  19306. jw.Msg = "黑屏代码有误!";
  19307. return Ok(jw);
  19308. }
  19309. foreach (DataRow row in dtBlack.Rows)
  19310. {
  19311. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  19312. {
  19313. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  19314. return Ok(jw);
  19315. }
  19316. }
  19317. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  19318. var resultArr = new ArrayList();
  19319. //if (officialActivitiesArr.Count == 0)
  19320. //{
  19321. // jw.Msg = "暂无公务出访信息!";
  19322. // return Ok(jw);
  19323. //}
  19324. try
  19325. {
  19326. _sqlSugar.BeginTran();
  19327. DeleteApprovalJourney(new
  19328. Domain.Dtos.Groups.DeleteApprovalJourney
  19329. {
  19330. Diid = dto.Diid,
  19331. uesrId = dto.Userid
  19332. });
  19333. var stay = "-";
  19334. var cityPath = "-";
  19335. var arriveCountry = string.Empty;
  19336. //添加城市路径以及住宿地
  19337. //黑屏代码获取时间区间
  19338. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  19339. var empty = "【未收入该三字码!请机票同事录入】";
  19340. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  19341. #region 配置公务活动时间
  19342. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  19343. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  19344. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  19345. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  19346. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  19347. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  19348. {
  19349. 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" }),
  19350. 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"}),
  19351. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  19352. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  19353. };
  19354. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  19355. {
  19356. 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" }),
  19357. 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"}),
  19358. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  19359. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  19360. };
  19361. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  19362. {
  19363. 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" }),
  19364. 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"}),
  19365. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  19366. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  19367. };
  19368. #endregion
  19369. var nextDayNum = 0;
  19370. for (int i = 0; i < timeArr.Count; i++)
  19371. {
  19372. stay = "-";
  19373. cityPath = "-";
  19374. var chiarr = new List<Grp_ApprovalTravelDetails>();
  19375. DateTime NewData = DateTime.Parse(timeArr[i]);
  19376. //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();
  19377. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  19378. if (nextDayNum > 0)
  19379. {
  19380. nextDayNum--;
  19381. }
  19382. if (tbSelect.Length > 0)
  19383. {
  19384. List<string> threeCodeStr = new List<string>();
  19385. bool isTrade = false;
  19386. string trip = string.Empty;
  19387. foreach (var item in tbSelect)
  19388. {
  19389. if (nextDayNum == 0)
  19390. {
  19391. nextDayNum = Convert.ToInt32(item["Sign"]);
  19392. }
  19393. var airStartTime = item["StartTime"].ToString() ?? "0000";
  19394. var airEndTime = item["EndTime"].ToString() ?? "0000";
  19395. var takeOffTime = DateTime.Parse(timeArr[i]);
  19396. var fallToTime = DateTime.Parse(timeArr[i]);
  19397. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  19398. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  19399. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  19400. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  19401. if (nextDayNum > 0)
  19402. {
  19403. fallToTime = fallToTime.AddDays(nextDayNum);
  19404. }
  19405. trip = string.Empty;
  19406. var start = string.Empty;
  19407. var end = string.Empty;
  19408. var threeCode = item["Three"].ToString() ?? "";
  19409. if (threeCode.Length == 6)
  19410. {
  19411. start = threeCode.Substring(0, 3);
  19412. end = threeCode.Substring(3, 3);
  19413. if (threeCodeStr.Count == 0)
  19414. {
  19415. threeCodeStr.Add(start);
  19416. threeCodeStr.Add(end);
  19417. }
  19418. else
  19419. {
  19420. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  19421. {
  19422. threeCodeStr.Add(end);
  19423. }
  19424. else
  19425. {
  19426. threeCodeStr.Add(start);
  19427. threeCodeStr.Add(end);
  19428. }
  19429. }
  19430. }
  19431. //处理机票信息
  19432. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  19433. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  19434. if (start_Object == null)
  19435. {
  19436. start_Object = new Res_ThreeCode()
  19437. {
  19438. AirPort = empty,
  19439. AirPort_En = empty,
  19440. City = empty,
  19441. Country = empty,
  19442. Four = empty,
  19443. Three = empty,
  19444. };
  19445. }
  19446. if (end_Object == null)
  19447. {
  19448. end_Object = new Res_ThreeCode()
  19449. {
  19450. AirPort = empty,
  19451. AirPort_En = empty,
  19452. City = empty,
  19453. Country = empty,
  19454. Four = empty,
  19455. Three = empty,
  19456. };
  19457. }
  19458. //机型判断
  19459. string airModel = item["AirModel"].ToString();
  19460. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  19461. string flightTime = item["FlightTime"].ToString();
  19462. flightTime = ParseBlackTime(flightTime);
  19463. //航班号
  19464. string flightcode = item["Fliagtcode"].ToString();
  19465. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  19466. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  19467. if (aircompany == null)
  19468. {
  19469. aircompany = new Res_AirCompany
  19470. {
  19471. CnName = hsEmpty,
  19472. EnName = hsEmpty,
  19473. ShortCode = hsEmpty,
  19474. };
  19475. }
  19476. //航班前公务安排
  19477. if (tbSelect.First().Equals(item) && i != 0)
  19478. {
  19479. foreach (var takeoff in takeoffTimes)
  19480. {
  19481. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  19482. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  19483. {
  19484. foreach (var addTime in takeoff.Item2)
  19485. {
  19486. chiarr.Add(new Grp_ApprovalTravelDetails
  19487. {
  19488. Time = addTime,
  19489. CreateTime = DateTime.Now,
  19490. CreateUserId = dto.Userid,
  19491. ParentId = 0,
  19492. Details = "公务活动"
  19493. });
  19494. }
  19495. break;
  19496. }
  19497. }
  19498. }
  19499. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  19500. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  19501. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  19502. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  19503. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  19504. if (isTrade)
  19505. {
  19506. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  19507. trip += "(转机不出机场)。";
  19508. }
  19509. //else
  19510. //{
  19511. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  19512. //}
  19513. chiarr.Add(new Grp_ApprovalTravelDetails
  19514. {
  19515. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  19516. CreateTime = DateTime.Now,
  19517. CreateUserId = dto.Userid,
  19518. ParentId = 0,
  19519. Details = trip
  19520. });
  19521. //最后一条到达的时间安排公务
  19522. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  19523. {
  19524. bool isCheckCountry = false;
  19525. if (end_Object.Country != arriveCountry)
  19526. {
  19527. arriveCountry = end_Object.Country;
  19528. isCheckCountry = true;
  19529. }
  19530. if (nextDayNum == 0)
  19531. {
  19532. //需要入境的情况
  19533. if (isCheckCountry)
  19534. {
  19535. foreach (var fallTime in fallTimesCheckCountry)
  19536. {
  19537. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  19538. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  19539. {
  19540. foreach (var addTime in fallTime.Item2)
  19541. {
  19542. chiarr.Add(new Grp_ApprovalTravelDetails
  19543. {
  19544. Time = addTime,
  19545. CreateTime = DateTime.Now,
  19546. CreateUserId = dto.Userid,
  19547. ParentId = 0,
  19548. Details = "公务活动"
  19549. });
  19550. }
  19551. break;
  19552. }
  19553. }
  19554. }
  19555. else
  19556. {
  19557. foreach (var fallTime in fallTimesNotCheckCountry)
  19558. {
  19559. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  19560. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  19561. {
  19562. foreach (var addTime in fallTime.Item2)
  19563. {
  19564. chiarr.Add(new Grp_ApprovalTravelDetails
  19565. {
  19566. Time = addTime,
  19567. CreateTime = DateTime.Now,
  19568. CreateUserId = dto.Userid,
  19569. ParentId = 0,
  19570. Details = "公务活动"
  19571. });
  19572. }
  19573. break;
  19574. }
  19575. }
  19576. }
  19577. }
  19578. }
  19579. }
  19580. //添加乘车语句
  19581. //chiarr.Add(new Grp_ApprovalTravelDetails
  19582. //{
  19583. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  19584. // CreateTime = DateTime.Now,
  19585. // CreateUserId = dto.Userid,
  19586. // ParentId = 0,
  19587. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  19588. //});
  19589. //if (i != timeArr.Count - 1)
  19590. //{
  19591. // fallToTime = fallToTime.AddHours(2.5);
  19592. // foreach (var item in Times)
  19593. // {
  19594. // //排列公务时间
  19595. // if (fallToTime.Hour < item.Item1)
  19596. // {
  19597. // chiarr.Add(new Grp_ApprovalTravelDetails
  19598. // {
  19599. // Time = $"{item.Item2} - {item.Item3}",
  19600. // CreateTime = DateTime.Now,
  19601. // CreateUserId = dto.Userid,
  19602. // ParentId = 0,
  19603. // Details = "公务活动"
  19604. // });
  19605. // }
  19606. // }
  19607. //}
  19608. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  19609. var last = threeCodeStr.Last();
  19610. foreach (var item in threeCodeStr)
  19611. {
  19612. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  19613. if (item.Equals(last))
  19614. {
  19615. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  19616. }
  19617. }
  19618. cityPath = cityPath.Trim('-');
  19619. }
  19620. else
  19621. {
  19622. foreach (var item in Times)
  19623. {
  19624. chiarr.Add(new Grp_ApprovalTravelDetails
  19625. {
  19626. Time = $"{item.Item2} - {item.Item3}",
  19627. CreateTime = DateTime.Now,
  19628. CreateUserId = dto.Userid,
  19629. ParentId = 0,
  19630. Details = "公务活动"
  19631. });
  19632. }
  19633. }
  19634. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  19635. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  19636. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  19637. appro.Diid = dto.Diid;
  19638. appro.CreateUserId = dto.Userid;
  19639. appro.CreateTime = DateTime.Now;
  19640. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  19641. appro.Id = thisId;
  19642. //foreach (var item in gwinfo)
  19643. //{
  19644. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  19645. // chi.Details = "拜访" + item.Client;
  19646. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  19647. // {
  19648. // chi.Details += "," + item.ReqSample;
  19649. // }
  19650. // chi.ParentId = thisId;
  19651. // chi.Time = item.Time;
  19652. // chiarr.Add(chi);
  19653. //}
  19654. if (chiarr.Count < 6)
  19655. {
  19656. for (int j = chiarr.Count; j < 6; j++)
  19657. {
  19658. chiarr.Add(new
  19659. Grp_ApprovalTravelDetails());
  19660. }
  19661. }
  19662. resultArr.Add(new
  19663. {
  19664. appro.Id,
  19665. appro.Date,
  19666. appro.Diid,
  19667. chiList = chiarr.Select(x1 => new
  19668. {
  19669. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  19670. x1.Details,
  19671. x1.ParentId,
  19672. x1.Id
  19673. })
  19674. });
  19675. }
  19676. _sqlSugar.CommitTran();
  19677. jw = JsonView(true, "生成成功!", resultArr);
  19678. }
  19679. catch (Exception ex)
  19680. {
  19681. jw.Code = 400;
  19682. jw.Msg = "生成失败!" + ex.Message;
  19683. }
  19684. return Ok(jw);
  19685. }
  19686. /// <summary>
  19687. /// 报批行程word导出
  19688. /// </summary>
  19689. /// <param name="dto"></param>
  19690. /// <returns></returns>
  19691. [HttpPost]
  19692. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  19693. {
  19694. var jw = JsonView(false);
  19695. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  19696. if (group == null)
  19697. {
  19698. jw.Msg = "暂无该团组!";
  19699. return Ok(jw);
  19700. }
  19701. //模板路径
  19702. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  19703. var fileName = string.Empty;
  19704. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  19705. bool bold = false;
  19706. if (dto.FileIndex == 1)
  19707. {
  19708. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  19709. }
  19710. else if (dto.FileIndex == 2)
  19711. {
  19712. fileName = "省外办-报批.docx";
  19713. bold = false;
  19714. titleFont = "方正黑体简体";
  19715. timeFont = "Times New Roman";
  19716. contentFont = "方正仿宋_GBK";
  19717. }
  19718. else if (dto.FileIndex == 3)
  19719. {
  19720. fileName = "市外办-报批.docx";
  19721. titleFont = "方正黑体简体";
  19722. timeFont = "Times New Roman";
  19723. contentFont = "方正仿宋简体";
  19724. }
  19725. tempPath = tempPath + fileName;
  19726. //载入模板
  19727. Document doc = new Document(tempPath);
  19728. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19729. //获取所填表格的序数
  19730. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19731. Aspose.Words.Tables.Row titleRowClone = null;
  19732. Aspose.Words.Tables.Row CenterRowClone = null;
  19733. int index = 0;
  19734. int indexChi = 0;
  19735. int SetIndex = 0;
  19736. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  19737. //获取数据,放到datatable
  19738. foreach (var item in ApprovalTravelArr)
  19739. {
  19740. if (index > 0)
  19741. {
  19742. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  19743. tableOne.AppendChild(titleRowClone);
  19744. }
  19745. var textTime = item.Date;
  19746. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  19747. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  19748. SetIndex++;
  19749. if (ChiRep.Count > 0)
  19750. {
  19751. foreach (var itemChi in ChiRep)
  19752. {
  19753. var txtTime = itemChi.Time;
  19754. var txtDetail = itemChi.Details;
  19755. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  19756. {
  19757. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  19758. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  19759. //indexChi++;
  19760. //SetIndex++;
  19761. break;
  19762. }
  19763. if (indexChi > 0)
  19764. {
  19765. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  19766. tableOne.AppendChild(CenterRowClone);
  19767. }
  19768. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  19769. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  19770. indexChi++;
  19771. SetIndex++;
  19772. }
  19773. }
  19774. //else
  19775. //{
  19776. // if (indexChi > 0)
  19777. // {
  19778. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  19779. // tableOne.AppendChild(CenterRowClone);
  19780. // }
  19781. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  19782. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  19783. // indexChi++;
  19784. // SetIndex++;
  19785. //}
  19786. index++;
  19787. }
  19788. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  19789. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  19790. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  19791. jw.Code = 200;
  19792. jw.Msg = "";
  19793. return Ok(jw);
  19794. }
  19795. private string ParseBlackTime(string time)
  19796. {
  19797. // 匹配可能只有分钟的情况
  19798. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  19799. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  19800. if (match.Success)
  19801. {
  19802. string hours = match.Groups[1].Value;
  19803. string minutes = match.Groups[2].Value;
  19804. // 如果小时部分为空,则只显示分钟
  19805. if (string.IsNullOrEmpty(hours))
  19806. {
  19807. return $"{minutes}分钟";
  19808. }
  19809. // 如果分钟部分为空,则只显示小时
  19810. else if (string.IsNullOrEmpty(minutes))
  19811. {
  19812. return $"{hours}小时";
  19813. }
  19814. // 否则显示完整格式
  19815. else
  19816. {
  19817. return $"{hours}小时{minutes}分钟";
  19818. }
  19819. }
  19820. else
  19821. {
  19822. return "未知时长";
  19823. }
  19824. }
  19825. private string intToString(int numberVal)
  19826. {
  19827. string numberval = numberVal.ToString();
  19828. Dictionary<char, string> Number = new Dictionary<char, string>();
  19829. Number.Add('1', "一");
  19830. Number.Add('2', "二");
  19831. Number.Add('3', "三");
  19832. Number.Add('4', "四");
  19833. Number.Add('5', "五");
  19834. Number.Add('6', "六");
  19835. Number.Add('7', "七");
  19836. Number.Add('8', "八");
  19837. Number.Add('9', "九");
  19838. string stringNumberVal = string.Empty;
  19839. for (int i = 0; i < numberval.Length; i++)
  19840. {
  19841. if (i == 0)
  19842. {
  19843. stringNumberVal += Number[numberval[i]];
  19844. }
  19845. else if (i >= 1)
  19846. {
  19847. if (numberval[i] == '0')
  19848. {
  19849. stringNumberVal = "十";
  19850. }
  19851. else
  19852. {
  19853. stringNumberVal += "十" + Number[numberval[i]];
  19854. }
  19855. }
  19856. }
  19857. return stringNumberVal;
  19858. }
  19859. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  19860. {
  19861. //获取table中的某个单元格,从0开始
  19862. Cell lshCell = table.Rows[rows].Cells[cells];
  19863. //将单元格中段落移除
  19864. foreach (Paragraph item in lshCell.Paragraphs)
  19865. {
  19866. lshCell.Paragraphs.Remove(item);
  19867. }
  19868. if (val.Contains("\r\n"))
  19869. {
  19870. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  19871. foreach (var item in spArr)
  19872. {
  19873. //新建一个段落
  19874. Paragraph p = new Paragraph(doc);
  19875. var r = new Run(doc, item);
  19876. //设置字体
  19877. if (!string.IsNullOrEmpty(font))
  19878. {
  19879. r.Font.Name = font;
  19880. }
  19881. r.Font.Bold = bold;
  19882. //把设置的值赋给之前新建的段落
  19883. p.AppendChild(r);
  19884. //将此段落加到单元格内
  19885. lshCell.AppendChild(p);
  19886. }
  19887. }
  19888. else
  19889. {
  19890. //新建一个段落
  19891. Paragraph p = new Paragraph(doc);
  19892. var r = new Run(doc, val);
  19893. //设置字体
  19894. if (!string.IsNullOrEmpty(font))
  19895. {
  19896. r.Font.Name = font;
  19897. }
  19898. r.Font.Bold = bold;
  19899. //把设置的值赋给之前新建的段落
  19900. p.AppendChild(r);
  19901. //将此段落加到单元格内
  19902. lshCell.AppendChild(p);
  19903. }
  19904. }
  19905. //[HttpPost]
  19906. //public async Task<IActionResult> ServerHttp(string paramStr)
  19907. //{
  19908. // paramStr = paramStr.TrimEnd('\'');
  19909. // paramStr = paramStr.TrimStart('\'');
  19910. // JsonView jw = JsonView(false);
  19911. // JObject param = JObject.Parse(paramStr);
  19912. // if (!param.ContainsKey("url"))
  19913. // {
  19914. // jw.Msg = "url null";
  19915. // return Ok(jw);
  19916. // }
  19917. // string url = param["url"]!.ToString();
  19918. // var methon = "get";
  19919. // Dictionary<string, string> headValues = null;
  19920. // string bodyStr = string.Empty;
  19921. // if (param.ContainsKey("methon"))
  19922. // {
  19923. // methon = param["methon"]!.ToString().ToLower();
  19924. // }
  19925. // if (param.ContainsKey("header"))
  19926. // {
  19927. // var header = param["header"]!.ToString();
  19928. // JObject headerJobject = JObject.Parse(header);
  19929. // headValues = new Dictionary<string, string>();
  19930. // foreach (JProperty item in headerJobject.Properties())
  19931. // {
  19932. // var value = item.Value.ToString();
  19933. // var head = item.Path;
  19934. // headValues.Add(head, value);
  19935. // }
  19936. // }
  19937. // HttpClient client = new HttpClient();
  19938. // string responseString = string.Empty;
  19939. // StringContent content = null;
  19940. // if (headValues != null)
  19941. // {
  19942. // foreach (var item in headValues.Keys)
  19943. // {
  19944. // if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  19945. // {
  19946. // if (param.ContainsKey("body"))
  19947. // {
  19948. // bodyStr = param["body"]!.ToString();
  19949. // }
  19950. // content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  19951. // }
  19952. // else
  19953. // {
  19954. // client.DefaultRequestHeaders.Add(item, headValues[item]);
  19955. // }
  19956. // }
  19957. // }
  19958. // try
  19959. // {
  19960. // if (methon == "get")
  19961. // {
  19962. // responseString = await client.GetStringAsync(url);
  19963. // }
  19964. // else if (methon == "post")
  19965. // {
  19966. // var request = new HttpRequestMessage(HttpMethod.Post, url)
  19967. // {
  19968. // Content = content
  19969. // };
  19970. // var response = await client.SendAsync(request);
  19971. // try
  19972. // {
  19973. // Stream responseStream = await response.Content.ReadAsStreamAsync();
  19974. // using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  19975. // {
  19976. // using (StreamReader reader = new StreamReader(gzipStream))
  19977. // {
  19978. // responseString = await reader.ReadToEndAsync();
  19979. // }
  19980. // }
  19981. // }
  19982. // catch (Exception)
  19983. // {
  19984. // responseString = await response.Content.ReadAsStringAsync();
  19985. // }
  19986. // }
  19987. // else
  19988. // {
  19989. // responseString = "methon error";
  19990. // }
  19991. // jw = JsonView(true, "success", responseString);
  19992. // }
  19993. // catch (Exception ex)
  19994. // {
  19995. // jw.Msg = "error " + ex.Message;
  19996. // jw.Data = ex.StackTrace;
  19997. // }
  19998. // finally
  19999. // {
  20000. // client.Dispose();
  20001. // }
  20002. // return Ok(jw);
  20003. //}
  20004. #endregion
  20005. #region 团组接待意见调查
  20006. /// <summary>
  20007. /// 团组接待意见调查 - 信息管理
  20008. /// 基础数据(团组)
  20009. /// </summary>
  20010. /// <returns></returns>
  20011. [HttpGet]
  20012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20013. public async Task<IActionResult> OpinionaireInit()
  20014. {
  20015. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  20016. .Select(x => new
  20017. {
  20018. x.Id,
  20019. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  20020. })
  20021. .OrderByDescending(x => x.Id)
  20022. .ToListAsync();
  20023. return Ok(JsonView(groupData, groupData.Count));
  20024. }
  20025. /// <summary>
  20026. /// 团组接待意见调查 - 信息管理
  20027. /// 列表
  20028. /// </summary>
  20029. /// <param name="groupId"></param>
  20030. /// <returns></returns>
  20031. [HttpGet("{groupId}")]
  20032. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20033. public async Task<IActionResult> OpinionaireManageList(int groupId)
  20034. {
  20035. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  20036. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  20037. .Select(x => new
  20038. {
  20039. x.Id,
  20040. x.TourGuideName,
  20041. x.CityName,
  20042. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  20043. x.CreateTime
  20044. })
  20045. .OrderBy(x => x.Id)
  20046. .ToListAsync();
  20047. return Ok(JsonView(data));
  20048. }
  20049. /// <summary>
  20050. /// 团组接待意见调查 - 信息管理
  20051. /// 保存
  20052. /// </summary>
  20053. /// <param name="dto"></param>
  20054. /// <returns></returns>
  20055. [HttpPost]
  20056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20057. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  20058. {
  20059. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  20060. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  20061. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  20062. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  20063. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  20064. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  20065. _opinionaireRep.BeginTran();
  20066. if (addData != null && addData.Count > 0)
  20067. {
  20068. foreach (var item in addData)
  20069. {
  20070. item.CreateUserId = currUserInfo.UserId;
  20071. item.DiId = dto.DiId;
  20072. }
  20073. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  20074. }
  20075. if (updData != null && updData.Count > 0)
  20076. {
  20077. var upd = await _opinionaireRep._sqlSugar
  20078. .Updateable(updData)
  20079. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  20080. .WhereColumns(x => new { x.Id })
  20081. .ExecuteCommandAsync();
  20082. }
  20083. _opinionaireRep.CommitTran();
  20084. return Ok(JsonView("操作成功!"));
  20085. }
  20086. /// <summary>
  20087. /// 团组接待意见调查 - 信息管理
  20088. /// 删除
  20089. /// </summary>
  20090. /// <param name="id"></param>
  20091. /// <returns></returns>
  20092. [HttpDelete("{id}")]
  20093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20094. public async Task<IActionResult> OpinionaireManageDel(int id)
  20095. {
  20096. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  20097. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  20098. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  20099. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  20100. if (!del) return Ok(JsonView("操作失败!"));
  20101. return Ok(JsonView("操作成功!"));
  20102. }
  20103. /// <summary>
  20104. /// 团组接待意见调查 - 用户
  20105. /// 列表
  20106. /// </summary>
  20107. /// <param name="diId"></param>
  20108. /// <returns></returns>
  20109. [HttpGet("{diId}")]
  20110. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20111. public async Task<IActionResult> OpinionaireUserList(int diId)
  20112. {
  20113. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  20114. var sql = string.Format(@"
  20115. SELECT
  20116. o.Id,
  20117. o.DiId,
  20118. di.TeamName AS 'GroupName',
  20119. di.VisitPNumber AS 'PeopleNumber',
  20120. di.ClientName AS 'LeadGroup',
  20121. di.VisitCountry AS 'Travel',
  20122. di.VisitDays AS 'Days',
  20123. o.CityName,
  20124. o.TourGuideName,
  20125. o.Catering,
  20126. o.CateringReason,
  20127. o.Stay,
  20128. o.StayReason,
  20129. o.[Route],
  20130. o.RouteReason,
  20131. o.OfficialActivity,
  20132. o.OfficialActivityReason,
  20133. o.TourGuide,
  20134. o.TourGuideReason,
  20135. o.[Translate],
  20136. o.TranslateReason,
  20137. o.Trip,
  20138. o.TripReason,
  20139. o.ESFileName,
  20140. o.SignatureDate,
  20141. o.Remark
  20142. FROM
  20143. Grp_Opinionaire o
  20144. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  20145. WHERE
  20146. o.IsDel = 0
  20147. AND o.DiId = {0}
  20148. ORDER BY
  20149. o.Id ASC", diId);
  20150. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  20151. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  20152. return Ok(JsonView(data));
  20153. }
  20154. /// <summary>
  20155. /// 团组接待意见调查 - 用户
  20156. /// 保存
  20157. /// </summary>
  20158. /// <param name="dto"></param>
  20159. /// <returns></returns>
  20160. [HttpPost]
  20161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20162. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  20163. {
  20164. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  20165. foreach (var item in dto)
  20166. {
  20167. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  20168. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  20169. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  20170. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  20171. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  20172. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  20173. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  20174. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  20175. }
  20176. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  20177. if (!Directory.Exists(filePathBase))
  20178. {
  20179. Directory.CreateDirectory(filePathBase);
  20180. }
  20181. #region 上传文件
  20182. var filePaths = new List<string>();
  20183. foreach (var item in dto)
  20184. {
  20185. var file = item.File;
  20186. // 将文件保存到指定位置
  20187. var filePath = Path.Combine(filePathBase, file.FileName);
  20188. using (var stream = new FileStream(filePath, FileMode.Create))
  20189. {
  20190. await file.CopyToAsync(stream);
  20191. }
  20192. //验证文件是否上传成功
  20193. if (!System.IO.File.Exists(filePath))
  20194. {
  20195. foreach (var filePathStr in filePaths)
  20196. {
  20197. System.IO.File.Delete(filePathStr);
  20198. }
  20199. return Ok(JsonView(false, "文件上传失败!"));
  20200. }
  20201. item.ESFileName = file.FileName;
  20202. }
  20203. #endregion
  20204. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  20205. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  20206. .UpdateColumns(x => new
  20207. {
  20208. x.Catering,
  20209. x.CateringReason,
  20210. x.Stay,
  20211. x.StayReason,
  20212. x.Route,
  20213. x.RouteReason,
  20214. x.OfficialActivity,
  20215. x.OfficialActivityReason,
  20216. x.TourGuide,
  20217. x.TourGuideReason,
  20218. x.Translate,
  20219. x.TranslateReason,
  20220. x.Trip,
  20221. x.TripReason,
  20222. x.ESFileName,
  20223. x.SignatureDate,
  20224. x.Remark
  20225. })
  20226. .WhereColumns(x => new { x.Id })
  20227. .ExecuteCommandAsync();
  20228. if (upd < 1)
  20229. {
  20230. foreach (var filePathStr in filePaths)
  20231. {
  20232. System.IO.File.Delete(filePathStr);
  20233. }
  20234. return Ok(JsonView(false));
  20235. }
  20236. return Ok(JsonView(true));
  20237. }
  20238. #endregion
  20239. #region 团组餐厅相关信息
  20240. /// <summary>
  20241. /// 团组相关餐厅信息
  20242. /// 基础数据(团组)
  20243. /// </summary>
  20244. /// <returns></returns>
  20245. [HttpGet]
  20246. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20247. public async Task<IActionResult> RestaurantInit()
  20248. {
  20249. return Ok(await _restaurantRep.InitAsync());
  20250. }
  20251. /// <summary>
  20252. /// 团组相关餐厅信息
  20253. /// Item
  20254. /// </summary>
  20255. /// <param name="dto"></param>
  20256. /// <returns></returns>
  20257. [HttpPost]
  20258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20259. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  20260. {
  20261. int portType = dto.PortType,
  20262. groupId = dto.GroupId;
  20263. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  20264. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  20265. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  20266. }
  20267. /// <summary>
  20268. /// 团组相关餐厅信息
  20269. /// List
  20270. /// </summary>
  20271. /// <param name="dto"></param>
  20272. /// <returns></returns>
  20273. [HttpPost]
  20274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20275. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  20276. {
  20277. int portType = dto.PortType,
  20278. groupId = dto.GroupId;
  20279. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  20280. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  20281. var sql = string.Format(@" SELECT
  20282. ri.Id,
  20283. ri.GroupId,
  20284. ri.Date,
  20285. ri.StartTime,
  20286. ri.EndTime,
  20287. CASE WHEN ri.Type = 1 THEN '早餐'
  20288. WHEN ri.Type = 2 THEN '午餐'
  20289. WHEN ri.Type = 3 THEN '晚餐'
  20290. ELSE '其他'
  20291. END AS 'Type',
  20292. ri.Name,
  20293. ri.Address,
  20294. ri.Tel,
  20295. ri.Remark,
  20296. ri.CreateTime,
  20297. u.CnName AS CreateUserName
  20298. FROM
  20299. Grp_RestaurantInfo ri
  20300. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  20301. WHERE
  20302. ri.IsDel = 0
  20303. AND ri.GroupId = {0}
  20304. ORDER BY
  20305. ri.Date ASC
  20306. ", groupId);
  20307. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  20308. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  20309. return Ok(JsonView(infos));
  20310. }
  20311. /// <summary>
  20312. /// 团组相关餐厅信息
  20313. /// Info
  20314. /// </summary>
  20315. /// <param name="dto"></param>
  20316. /// <returns></returns>
  20317. [HttpPost]
  20318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20319. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  20320. {
  20321. int portType = dto.PortType,
  20322. id = dto.Id;
  20323. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  20324. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  20325. return Ok(await _restaurantRep.InfoAsync(portType, id));
  20326. }
  20327. /// <summary>
  20328. /// 团组相关餐厅信息
  20329. /// Op
  20330. /// </summary>
  20331. /// <param name="dto"></param>
  20332. /// <returns></returns>
  20333. [HttpPost]
  20334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20335. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  20336. {
  20337. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20338. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  20339. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  20340. return Ok(await _restaurantRep.OpAsync(dto));
  20341. }
  20342. /// <summary>
  20343. /// 团组相关餐厅信息
  20344. /// Del
  20345. /// </summary>
  20346. /// <param name="dto"></param>
  20347. /// <returns></returns>
  20348. [HttpPost]
  20349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20350. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  20351. {
  20352. int userId = dto.DeleteUserId;
  20353. var id = dto.Id;
  20354. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20355. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  20356. return Ok(await _restaurantRep.DelAsync(dto));
  20357. }
  20358. #endregion
  20359. // /// <summary>
  20360. // ///
  20361. // /// </summary>
  20362. // /// <param name="_dto"></param>
  20363. // /// <returns></returns>
  20364. // [HttpPost]
  20365. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20366. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  20367. // {
  20368. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  20369. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  20370. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  20371. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  20372. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  20373. // dic_psg.Add("客人", 974);
  20374. // dic_psg.Add("司机", 975);
  20375. // dic_psg.Add("导游", 976);
  20376. // dic_psg.Add("公司内部人员", 977);
  20377. // dic_psg.Add("司机/导游/公司内部人员", 978);
  20378. // foreach (var item in list_visa)
  20379. // {
  20380. // Grp_VisaInfo temp = new Grp_VisaInfo();
  20381. // temp.Id = item.Id;
  20382. // temp.DIId = item.DIId;
  20383. // temp.VisaClient = item.VisaClient;
  20384. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  20385. // temp.VisaCurrency = item.VisaCurrency;
  20386. // temp.IsThird = item.IsThird;
  20387. // if (dic_psg.ContainsKey(item.PassengerType))
  20388. // {
  20389. // temp.PassengerType = dic_psg[item.PassengerType];
  20390. // }
  20391. // else {
  20392. // temp.PassengerType = -1;
  20393. // }
  20394. // temp.VisaNumber = item.VisaNumber;
  20395. // temp.VisaFreeNumber = item.VisaFreeNumber;
  20396. // temp.CreateUserId = item.Operators;
  20397. // DateTime dt_ct;
  20398. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  20399. // if (b_ct)
  20400. // {
  20401. // temp.CreateTime = dt_ct;
  20402. // }
  20403. // else
  20404. // {
  20405. // temp.CreateTime = DateTime.Now;
  20406. // }
  20407. // temp.DeleteTime = "";
  20408. // temp.DeleteUserId = 0;
  20409. // temp.Remark = item.Remark;
  20410. // if (string.IsNullOrEmpty(temp.Remark)) {
  20411. // temp.Remark = "";
  20412. // }
  20413. // temp.IsDel = item.IsDel;
  20414. // temp.VisaDescription = item.VisaAttachment;
  20415. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  20416. //([Id]
  20417. // ,[DIId]
  20418. // ,[VisaClient]
  20419. // ,[VisaPrice]
  20420. // ,[VisaCurrency]
  20421. // ,[IsThird]
  20422. // ,[PassengerType]
  20423. // ,[VisaNumber]
  20424. // ,[VisaFreeNumber]
  20425. // ,[CreateUserId]
  20426. // ,[CreateTime]
  20427. // ,[DeleteTime]
  20428. // ,[DeleteUserId]
  20429. // ,[Remark]
  20430. // ,[IsDel]
  20431. // ,[visaDescription])
  20432. // VALUES
  20433. // ({0},{1},'{2}',{3},{4}
  20434. //,{5},{6},{7},{8},{9}
  20435. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  20436. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  20437. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  20438. //);
  20439. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  20440. // }
  20441. // return Ok(JsonView(true, "操作成功!"));
  20442. // }
  20443. /// <summary>
  20444. /// 123132123
  20445. /// </summary>
  20446. /// <param name="_dto"></param>
  20447. /// <returns></returns>
  20448. [HttpPost]
  20449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20450. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  20451. {
  20452. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  20453. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  20454. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  20455. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  20456. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  20457. dicDetail.Add(789, 1034);
  20458. dicDetail.Add(790, 1035);
  20459. dicDetail.Add(791, 1036);
  20460. dicDetail.Add(792, 1037);
  20461. dicDetail.Add(793, 1038);
  20462. dicDetail.Add(794, 1039);
  20463. dicDetail.Add(795, 1040);
  20464. dicDetail.Add(796, 1041);
  20465. dicDetail.Add(797, 1042);
  20466. dicDetail.Add(798, 1043);
  20467. dicDetail.Add(801, 1044);
  20468. dicDetail.Add(802, 1045);
  20469. dicDetail.Add(803, 1046);
  20470. Dictionary<int, int> dic = new Dictionary<int, int>();
  20471. dic.Add(806, 1027);
  20472. dic.Add(807, 1028);
  20473. dic.Add(808, 1029);
  20474. dic.Add(809, 1030);
  20475. dic.Add(810, 1031);
  20476. dic.Add(811, 1032);
  20477. dic.Add(812, 1033);
  20478. foreach (var item in list_visa)
  20479. {
  20480. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  20481. temp.Coefficient = item.coefficient;
  20482. DateTime dtCrt;
  20483. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  20484. if (b1)
  20485. {
  20486. temp.CreateTime = dtCrt;
  20487. }
  20488. else
  20489. {
  20490. temp.CreateTime = DateTime.Now;
  20491. }
  20492. temp.CreateUserId = item.Operators;
  20493. temp.DeleteTime = "";
  20494. temp.DeleteUserId = 0;
  20495. temp.DiId = int.Parse(item.DIID);
  20496. temp.FilePath = item.FilePath;
  20497. temp.IsDel = item.IsDel;
  20498. temp.Price = item.Price;
  20499. temp.PriceCount = 1;
  20500. temp.PriceCurrency = item.Currency;
  20501. int detailId = 0;
  20502. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  20503. {
  20504. detailId = dicDetail[item.PriceTypeDetail];
  20505. }
  20506. temp.PriceDetailType = detailId;
  20507. temp.PriceDt = DateTime.Now;
  20508. temp.PriceName = item.PriceName;
  20509. temp.PriceSum = item.Price;
  20510. int tid = 0;
  20511. if (dic.ContainsKey(item.PriceType))
  20512. {
  20513. tid = dic[item.PriceType];
  20514. }
  20515. temp.PriceType = tid;
  20516. temp.Remark = item.Remark;
  20517. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  20518. }
  20519. return Ok(JsonView(true, "操作成功!"));
  20520. }
  20521. [HttpPost]
  20522. public IActionResult TimeTest()
  20523. {
  20524. var jw = JsonView(false, "error");
  20525. _sqlSugar.BeginTran();
  20526. try
  20527. {
  20528. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  20529. .Select(x => new Crm_NewClientData
  20530. {
  20531. Id = x.Id,
  20532. Client = x.Client,
  20533. Contact = x.Contact,
  20534. Location = x.Location,
  20535. })
  20536. .ToList();
  20537. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  20538. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  20539. Stopwatch stopwatch = new Stopwatch();
  20540. // 开始计时
  20541. stopwatch.Start();
  20542. foreach (var item in clientList)
  20543. {
  20544. EncryptionProcessor.DecryptProperties(item);
  20545. }
  20546. stopwatch.Stop();
  20547. jw.Code = 200;
  20548. jw.Data = stopwatch.ElapsedMilliseconds;
  20549. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  20550. }
  20551. catch (Exception ex)
  20552. {
  20553. jw.Code = 400;
  20554. jw.Msg = ex.Message;
  20555. }
  20556. return Ok(jw);
  20557. }
  20558. }
  20559. }