GroupsController.cs 1.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707
  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 Org.BouncyCastle.Crypto;
  46. using Org.BouncyCastle.Utilities;
  47. using Quartz.Util;
  48. using SqlSugar.Extensions;
  49. using System.Collections;
  50. using System.Data;
  51. using System.Diagnostics;
  52. using System.Drawing.Printing;
  53. using System.Globalization;
  54. using System.IO;
  55. using System.IO.Compression;
  56. using System.Text.Json;
  57. using System.Web;
  58. using System.Xml.Linq;
  59. using TencentCloud.Ocr.V20181119.Models;
  60. using static OASystem.API.OAMethodLib.JWTHelper;
  61. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  62. using Bookmark = Aspose.Words.Bookmark;
  63. using Cell = Aspose.Words.Tables.Cell;
  64. using Table = Aspose.Words.Tables.Table;
  65. namespace OASystem.API.Controllers
  66. {
  67. /// <summary>
  68. /// 团组相关
  69. /// </summary>
  70. //[Authorize]
  71. [Route("api/[controller]/[action]")]
  72. public class GroupsController : ControllerBase
  73. {
  74. private readonly ILogger<GroupsController> _logger;
  75. private readonly GrpScheduleRepository _grpScheduleRep;
  76. private readonly IMapper _mapper;
  77. private readonly DelegationInfoRepository _groupRepository;
  78. private readonly TaskAssignmentRepository _taskAssignmentRep;
  79. private readonly AirTicketResRepository _airTicketResRep;
  80. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  81. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  82. private readonly DelegationEnDataRepository _delegationEnDataRep;
  83. private readonly DelegationVisaRepository _delegationVisaRep;
  84. private readonly VisaPriceRepository _visaPriceRep;
  85. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  86. private readonly HotelPriceRepository _hotelPriceRep;
  87. private readonly CustomersRepository _customersRep;
  88. private readonly MessageRepository _message;
  89. private readonly SqlSugarClient _sqlSugar;
  90. private readonly TourClientListRepository _tourClientListRep;
  91. private readonly TeamRateRepository _teamRateRep;
  92. #region 成本相关
  93. private readonly CheckBoxsRepository _checkBoxs;
  94. private readonly GroupCostRepository _GroupCostRepository;
  95. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  96. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  97. #endregion
  98. private readonly SetDataRepository _setDataRep;
  99. private string url;
  100. private string path;
  101. private readonly EnterExitCostRepository _enterExitCostRep;
  102. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  103. private readonly UsersRepository _usersRep;
  104. private readonly IJuHeApiService _juHeApi;
  105. private readonly InvertedListRepository _invertedListRep;
  106. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  107. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  108. private readonly ThreeCodeRepository _threeCodeRepository;
  109. private readonly HotelInquiryRepository _hotelInquiryRep;
  110. private readonly FeeAuditRepository _feeAuditRep;
  111. private readonly VisaCommissionRepository _visaCommissionRep;
  112. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  113. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  114. private readonly List<CurrencyInfo> _currencyInit;
  115. private readonly List<int> _portTypeData;
  116. private readonly TableOperationRecordRepository _tableorRep;
  117. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  118. private readonly RestaurantRepository _restaurantRep;
  119. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  120. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  121. /// <summary>
  122. /// 构造函数
  123. /// </summary>
  124. /// <param name="logger"></param>
  125. /// <param name="mapper"></param>
  126. /// <param name="hubContext"></param>
  127. /// <param name="sqlSugar"></param>
  128. /// <param name="grpScheduleRep"></param>
  129. /// <param name="groupRepository"></param>
  130. /// <param name="taskAssignmentRep"></param>
  131. /// <param name="airTicketResRep"></param>
  132. /// <param name="decreasePaymentsRep"></param>
  133. /// <param name="InvitationOfficialActivitiesRep"></param>
  134. /// <param name="delegationEnDataRep"></param>
  135. /// <param name="enterExitCostRep"></param>
  136. /// <param name="delegationVisaRep"></param>
  137. /// <param name="message"></param>
  138. /// <param name="visaPriceRep"></param>
  139. /// <param name="carTouristGuideGroundRep"></param>
  140. /// <param name="checkBoxs"></param>
  141. /// <param name="GroupCostRepository"></param>
  142. /// <param name="CostTypeHotelNumberRepository"></param>
  143. /// <param name="GroupCostParameterRepository"></param>
  144. /// <param name="hotelPriceRep"></param>
  145. /// <param name="customersRep"></param>
  146. /// <param name="setDataRep"></param>
  147. /// <param name="tourClientListRep"></param>
  148. /// <param name="teamRateRep"></param>
  149. /// <param name="usersRep"></param>
  150. /// <param name="juHeApi"></param>
  151. /// <param name="invertedListRep"></param>
  152. /// <param name="visaFeeInfoRep"></param>
  153. /// <param name="ticketBlackCodeRep"></param>
  154. /// <param name="hotelInquiryRep"></param>
  155. /// <param name="threeCodeRepository"></param>
  156. /// <param name="feeAuditRep"></param>
  157. /// <param name="visaCommissionRep"></param>
  158. /// <param name="ffrRep"></param>
  159. /// <param name="opinionaireRep"></param>
  160. /// <param name="tableorRep"></param>
  161. /// <param name="enterExitCostDraftRep"></param>
  162. /// <param name="restaurantRep"></param>
  163. /// <param name="enterExitCostQuoteRep"></param>
  164. /// <param name="grpOrderPreInfoRep"></param>
  165. public GroupsController(
  166. ILogger<GroupsController> logger,
  167. IMapper mapper,
  168. IHubContext<ChatHub, IChatClient> hubContext,
  169. SqlSugarClient sqlSugar,
  170. GrpScheduleRepository grpScheduleRep,
  171. DelegationInfoRepository groupRepository,
  172. TaskAssignmentRepository taskAssignmentRep,
  173. AirTicketResRepository airTicketResRep,
  174. DecreasePaymentsRepository decreasePaymentsRep,
  175. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  176. DelegationEnDataRepository delegationEnDataRep,
  177. EnterExitCostRepository enterExitCostRep,
  178. DelegationVisaRepository delegationVisaRep,
  179. MessageRepository message,
  180. VisaPriceRepository visaPriceRep,
  181. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  182. CheckBoxsRepository checkBoxs,
  183. GroupCostRepository GroupCostRepository,
  184. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  185. GroupCostParameterRepository GroupCostParameterRepository,
  186. HotelPriceRepository hotelPriceRep,
  187. CustomersRepository customersRep,
  188. SetDataRepository setDataRep,
  189. TourClientListRepository tourClientListRep,
  190. TeamRateRepository teamRateRep,
  191. UsersRepository usersRep,
  192. IJuHeApiService juHeApi,
  193. InvertedListRepository invertedListRep,
  194. VisaFeeInfoRepository visaFeeInfoRep,
  195. TicketBlackCodeRepository ticketBlackCodeRep,
  196. HotelInquiryRepository hotelInquiryRep,
  197. ThreeCodeRepository threeCodeRepository,
  198. FeeAuditRepository feeAuditRep,
  199. VisaCommissionRepository visaCommissionRep,
  200. ForeignReceivablesRepository ffrRep,
  201. OpinionaireRepository opinionaireRep,
  202. TableOperationRecordRepository tableorRep,
  203. EnterExitCostDraftRepository enterExitCostDraftRep,
  204. RestaurantRepository restaurantRep,
  205. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  206. GroupOrderPreInfoRepository grpOrderPreInfoRep
  207. )
  208. {
  209. _logger = logger;
  210. _mapper = mapper;
  211. _grpScheduleRep = grpScheduleRep;
  212. _groupRepository = groupRepository;
  213. _taskAssignmentRep = taskAssignmentRep;
  214. _airTicketResRep = airTicketResRep;
  215. _sqlSugar = sqlSugar;
  216. url = AppSettingsHelper.Get("ExcelBaseUrl");
  217. path = AppSettingsHelper.Get("ExcelBasePath");
  218. if (!System.IO.Directory.Exists(path))
  219. {
  220. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  221. }
  222. _decreasePaymentsRep = decreasePaymentsRep;
  223. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  224. _delegationEnDataRep = delegationEnDataRep;
  225. _enterExitCostRep = enterExitCostRep;
  226. _delegationVisaRep = delegationVisaRep;
  227. _message = message;
  228. _visaPriceRep = visaPriceRep;
  229. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  230. _checkBoxs = checkBoxs;
  231. _GroupCostRepository = GroupCostRepository;
  232. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  233. _GroupCostParameterRepository = GroupCostParameterRepository;
  234. _hotelPriceRep = hotelPriceRep;
  235. _customersRep = customersRep;
  236. _setDataRep = setDataRep;
  237. _tourClientListRep = tourClientListRep;
  238. _teamRateRep = teamRateRep;
  239. _hubContext = hubContext;
  240. _usersRep = usersRep;
  241. _juHeApi = juHeApi;
  242. _invertedListRep = invertedListRep;
  243. _visaFeeInfoRep = visaFeeInfoRep;
  244. _ticketBlackCodeRep = ticketBlackCodeRep;
  245. _hotelInquiryRep = hotelInquiryRep;
  246. _threeCodeRepository = threeCodeRepository;
  247. _feeAuditRep = feeAuditRep;
  248. _visaCommissionRep = visaCommissionRep;
  249. _ffrRep = ffrRep;
  250. _opinionaireRep = opinionaireRep;
  251. _currencyInit = new List<CurrencyInfo>()
  252. {
  253. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  254. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  255. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  256. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  257. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  258. };
  259. _portTypeData = new List<int>() { 2, 3 };
  260. _tableorRep = tableorRep;
  261. _enterExitCostDraftRep = enterExitCostDraftRep;
  262. _restaurantRep = restaurantRep;
  263. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  264. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  265. }
  266. #region 流程管控
  267. /// <summary>
  268. /// 获取团组流程管控信息
  269. /// </summary>
  270. /// <param name="_jsonDto">查询参数</param>
  271. /// <returns></returns>
  272. [HttpPost]
  273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  274. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  275. {
  276. if (string.IsNullOrEmpty(_jsonDto.Paras))
  277. {
  278. return Ok(JsonView(false, "参数为空"));
  279. }
  280. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  281. if (_ScheduleDto != null)
  282. {
  283. if (_ScheduleDto.SearchType == 2)//获取列表
  284. {
  285. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  286. return Ok(JsonView(_grpScheduleViewList));
  287. }
  288. else//获取对象
  289. {
  290. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  291. if (_grpScheduleView != null)
  292. {
  293. return Ok(JsonView(_grpScheduleView));
  294. }
  295. }
  296. }
  297. else
  298. {
  299. return Ok(JsonView(false, "参数反序列化失败"));
  300. }
  301. return Ok(JsonView(false, "暂无数据!"));
  302. }
  303. /// <summary>
  304. /// 修改团组流程管控详细表数据
  305. /// </summary>
  306. /// <param name="dto"></param>
  307. /// <returns></returns>
  308. [HttpPost]
  309. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  310. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  311. {
  312. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  313. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  314. .SetColumns(it => it.Duty == _detail.Duty)
  315. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  316. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  317. .SetColumns(it => it.JobContent == _detail.JobContent)
  318. .SetColumns(it => it.Remark == _detail.Remark)
  319. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  320. .Where(s => s.Id == dto.Id)
  321. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  322. .ExecuteCommandAsync();
  323. if (result > 0)
  324. {
  325. return Ok(JsonView(true, "保存成功!"));
  326. }
  327. return Ok(JsonView(false, "保存失败!"));
  328. }
  329. /// <summary>
  330. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  331. /// </summary>
  332. /// <param name="dto"></param>
  333. /// <returns></returns>
  334. [HttpPost]
  335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  336. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  337. {
  338. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  339. _detail.IsDel = 1;
  340. _detail.DeleteUserId = dto.Duty;
  341. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  342. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  343. .SetColumns(it => it.IsDel == _detail.IsDel)
  344. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  345. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  346. .Where(it => it.Id == dto.Id)
  347. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  348. //.WhereColumns(s => s.Id == dto.Id)
  349. .ExecuteCommandAsync();
  350. if (result > 0)
  351. {
  352. return Ok(JsonView(true, "删除成功!"));
  353. }
  354. return Ok(JsonView(false, "删除失败!"));
  355. }
  356. /// <summary>
  357. /// 增加团组流程管控详细表数据
  358. /// </summary>
  359. /// <param name="dto"></param>
  360. /// <returns></returns>
  361. [HttpPost]
  362. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  363. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  364. {
  365. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  366. if (DateTime.Now < _detail.ExpectBeginDt)
  367. {
  368. _detail.StepStatus = 0;
  369. }
  370. else
  371. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  372. _detail.StepStatus = 1;
  373. }
  374. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  375. if (result > 0)
  376. {
  377. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  378. return Ok(JsonView(true, "添加成功!", _result));
  379. }
  380. return Ok(JsonView(false, "添加失败!"));
  381. }
  382. #endregion
  383. #region 团组前期信息
  384. /// <summary>
  385. /// 团组前期信息 List
  386. /// </summary>
  387. /// <returns></returns>
  388. [HttpPost]
  389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  390. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  391. {
  392. var search = dto.Search;
  393. int[] nameTempIds = new int[] { 1, 12, 28 },
  394. countryTempIds = new int[] { 2, 13, 29 },
  395. daysTempIds = new int[] { 4, 15, 31 },
  396. ppNumTempIds = new int[] { 6 };
  397. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  398. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  399. .Where((opi, u) => opi.IsDel == 0)
  400. .OrderByDescending((opi, u) => opi.CreateTime)
  401. .Select((opi, u) => new GroupOrderPreInfoListView()
  402. {
  403. Id = opi.Id,
  404. Name = opi.Name,
  405. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains( x.FormTempId)).Select(x => x.Value),
  406. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  407. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  408. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  409. Operator = u.CnName,
  410. OperationTime = opi.CreateTime
  411. })
  412. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  413. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  414. .ToListAsync();
  415. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  416. int total = list.Count;
  417. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  418. var listPageData1 = listPageData
  419. .Skip((dto.PageIndex - 1) * dto.PageSize)
  420. .Take(dto.PageSize)
  421. .ToList();
  422. var infoIds = listPageData1.Select(x => x.Id).ToList();
  423. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  424. .Where(x => x.IsDel == 0 && x.STid == 109)
  425. .ToArrayAsync();
  426. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  427. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  428. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  429. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  430. .ToListAsync();
  431. foreach (var item in listPageData1)
  432. {
  433. var typeDatas1 = typeDatas.Select(x => new
  434. {
  435. Id = x.Id,
  436. Name = x.Name,
  437. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  438. }).ToArray();
  439. item.VersionDetails = typeDatas1;
  440. }
  441. return Ok(JsonView(listPageData1, listPageData1.Count));
  442. }
  443. /// <summary>
  444. /// 团组前期信息 Init
  445. /// </summary>
  446. /// <returns></returns>
  447. [HttpGet("{userId}")]
  448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  449. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  450. {
  451. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  452. }
  453. /// <summary>
  454. /// 国家数据源
  455. /// </summary>
  456. /// <returns></returns>
  457. [HttpGet]
  458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  459. public async Task<IActionResult> CountryInit()
  460. {
  461. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  462. return Ok(JsonView(countrys));
  463. }
  464. /// <summary>
  465. /// 城市数据源
  466. /// </summary>
  467. /// <returns></returns>
  468. [HttpGet("{countryLabel}")]
  469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  470. public async Task<IActionResult> CityByCountry(string countryLabel)
  471. {
  472. countryLabel = HttpUtility.UrlDecode(countryLabel);
  473. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  474. var citys = Array.Empty<string?>();
  475. if (countryList.Any())
  476. {
  477. var cityDatas = await _sqlSugar
  478. .Queryable<Grp_NationalTravelFee>()
  479. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  480. .ToArrayAsync();
  481. foreach (var item in cityDatas)
  482. {
  483. if (item.City.Contains("城市"))
  484. {
  485. item.City = item.Country + "-所有城市";
  486. }
  487. }
  488. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  489. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  490. }
  491. return Ok(JsonView(citys));
  492. }
  493. /// <summary>
  494. /// 团组前期信息 Info
  495. /// </summary>
  496. /// <param name="dto">Id</param>
  497. /// <returns></returns>
  498. [HttpGet("{Id}/{TempId}")]
  499. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  500. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  501. {
  502. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  503. }
  504. /// <summary>
  505. /// 团组前期信息 Save
  506. /// </summary>
  507. /// <param name="dto">Id</param>
  508. /// <returns></returns>
  509. [HttpPost]
  510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  511. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  512. {
  513. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  514. }
  515. /// <summary>
  516. /// 团组前期信息 Del
  517. /// </summary>
  518. /// <param name="dto">Id</param>
  519. /// <returns></returns>
  520. [HttpPost]
  521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  522. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  523. {
  524. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  525. }
  526. /// <summary>
  527. /// 团组前期信息 文件下载
  528. /// </summary>
  529. /// <param name="dto">Id</param>
  530. /// <returns></returns>
  531. [HttpGet("{Id}/{TempId}")]
  532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  533. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  534. {
  535. int id = dto.Id, tempId = dto.TempId;
  536. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  537. var data = view.Data as GrpOrderPreInfoView;
  538. #region Excel
  539. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  540. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  541. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  542. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  543. var fileNamePrefix = string.Empty;
  544. if (tempId == 1405)
  545. {
  546. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  547. fileNamePrefix = $"{data.Name}_无商邀版";
  548. }
  549. else if (tempId == 1406)
  550. {
  551. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  552. fileNamePrefix = $"{data.Name}_有商邀版";
  553. }
  554. else
  555. {
  556. //tempId == 1404 默认下载
  557. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  558. fileNamePrefix = $"{data.Name}_单接送机";
  559. }
  560. foreach (var item in data.Items)
  561. {
  562. var obj = item.NewValue;
  563. if (obj == null) item.OriginVal = "";
  564. else if (obj.Equals("有") || obj.Equals("无"))
  565. {
  566. item.OriginVal = obj.ToString();
  567. }
  568. else if (obj is object[] objArray)
  569. {
  570. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  571. item.OriginVal = string.Join("、", stringArray);
  572. }
  573. else if (obj is string[] stringArray)
  574. {
  575. item.OriginVal = string.Join("、", stringArray);
  576. }
  577. else if (obj.Equals("-"))
  578. {
  579. item.OriginVal = "";
  580. }
  581. }
  582. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  583. fileName = CommonFun.ValidFileName(fileName);
  584. //载入模板
  585. WorkbookDesigner designer = new WorkbookDesigner();
  586. designer.Workbook = new Workbook(tempPath);
  587. if (tempId == 1406)
  588. {
  589. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  590. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  591. for (int i = 1; i <= view2.Length; i++)
  592. {
  593. view2[i - 1].Index = i;
  594. }
  595. designer.SetDataSource("View1", view1);
  596. designer.SetDataSource("View2", view2);
  597. }
  598. else
  599. {
  600. designer.SetDataSource("View", data.Items);
  601. }
  602. designer.Process();
  603. if (!Directory.Exists(savePath))
  604. {
  605. Directory.CreateDirectory(savePath);
  606. }
  607. string serverPath = $"{savePath}{fileName}";
  608. designer.Workbook.Save(serverPath);
  609. string rst = $"{servicePath}{ftpPath}{fileName}";
  610. #endregion
  611. return Ok(JsonView(new { url = rst }));
  612. }
  613. #endregion
  614. #region 团组基本信息
  615. /// <summary>
  616. /// 接团信息列表
  617. /// </summary>
  618. /// <param name="dto">团组列表请求dto</param>
  619. /// <returns></returns>
  620. [HttpPost]
  621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  622. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  623. {
  624. var groupData = await _groupRepository.GetGroupList(dto);
  625. if (groupData.Code != 0)
  626. {
  627. return Ok(JsonView(false, groupData.Msg));
  628. }
  629. return Ok(JsonView(groupData.Data));
  630. }
  631. /// <summary>
  632. /// 分页查询团组列表
  633. /// </summary>
  634. /// <param name="dto"></param>
  635. /// <returns></returns>
  636. [HttpPost]
  637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  638. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  639. {
  640. var watch = new Stopwatch();
  641. watch.Start();
  642. RefAsync<int> total = 0;
  643. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  644. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  645. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  646. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  647. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  648. .Distinct()
  649. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  650. watch.Stop();
  651. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  652. }
  653. /// <summary>
  654. /// 接团信息列表 Page Init
  655. /// </summary>
  656. /// <returns></returns>
  657. [HttpPost]
  658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  659. public async Task<IActionResult> PostGroupPageListInit()
  660. {
  661. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  662. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  663. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  664. var _view = new
  665. {
  666. depData = depDatas,
  667. rankData = rankDatas
  668. };
  669. return Ok(JsonView(true, "查询成功!", _view));
  670. }
  671. /// <summary>
  672. /// 接团信息列表 Page
  673. /// </summary>
  674. /// <param name="dto">团组列表请求dto</param>
  675. /// <returns></returns>
  676. [HttpPost]
  677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  678. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  679. {
  680. #region 参数验证
  681. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  682. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  683. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  684. #region 页面操作权限验证
  685. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  686. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  687. #endregion
  688. #endregion
  689. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  690. {
  691. string sqlWhere = string.Empty;
  692. if (dto.IsSure == 0) //未完成
  693. {
  694. sqlWhere += string.Format(@" And IsSure = 0");
  695. }
  696. else if (dto.IsSure == 1) //已完成
  697. {
  698. sqlWhere += string.Format(@" And IsSure = 1");
  699. }
  700. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  701. {
  702. string tj = dto.SearchCriteria;
  703. 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}%')",
  704. tj, tj, tj, tj, tj);
  705. }
  706. if (int.TryParse(dto.Rank, out int rankId))
  707. {
  708. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  709. }
  710. string sqlWhere1 = string.Empty;
  711. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  712. {
  713. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  714. }
  715. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  716. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  717. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  718. JietuanOperator,IsSure,CreateTime,IsBid
  719. From (
  720. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  721. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  722. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  723. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  724. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  725. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  726. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  727. From Grp_DelegationInfo gdi
  728. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  729. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  730. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  731. Where gdi.IsDel = 0 {0}
  732. ) temp {1}", sqlWhere, sqlWhere1);
  733. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  734. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  735. var _view = new
  736. {
  737. PageFuncAuth = pageFunAuthView,
  738. Data = _DelegationList
  739. };
  740. return Ok(JsonView(true, "查询成功!", _view, total));
  741. }
  742. else
  743. {
  744. return Ok(JsonView(false, "查询失败"));
  745. }
  746. }
  747. /// <summary>
  748. /// 团组列表
  749. /// </summary>
  750. /// <returns></returns>
  751. [HttpPost]
  752. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  753. {
  754. #region 参数验证
  755. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  756. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  757. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  758. #region 页面操作权限验证
  759. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  760. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  761. #endregion
  762. #endregion
  763. if (dto.PortType != 1 && dto.PortType != 2)
  764. {
  765. return Ok(JsonView(false, "查询失败!"));
  766. }
  767. string orderbyStr = "order by gdi.CreateTime Desc";
  768. string sqlWhere = string.Empty;
  769. if (dto.IsSure == 0) //未完成
  770. {
  771. sqlWhere += string.Format(@" And IsSure = 0");
  772. }
  773. else if (dto.IsSure == 1) //已完成
  774. {
  775. sqlWhere += string.Format(@" And IsSure = 1");
  776. }
  777. //团组类型
  778. if (dto.TeamDid > 0)
  779. {
  780. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  781. }
  782. //团组名称
  783. if (!string.IsNullOrEmpty(dto.TeamName))
  784. {
  785. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  786. }
  787. //客户名称
  788. if (!string.IsNullOrEmpty(dto.ClientName))
  789. {
  790. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  791. }
  792. //客户单位
  793. if (!string.IsNullOrEmpty(dto.ClientUnit))
  794. {
  795. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  796. }
  797. //出访时间
  798. if (!string.IsNullOrEmpty(dto.visitDataTime))
  799. {
  800. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  801. orderbyStr = "order by gdi.VisitDate";
  802. }
  803. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  804. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  805. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  806. JietuanOperator,IsSure,CreateTime
  807. From (
  808. Select row_number() over({0}) as Row_Number,
  809. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  810. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  811. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  812. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  813. From Grp_DelegationInfo gdi
  814. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  815. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  816. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  817. Where gdi.IsDel = 0 {1}
  818. ) temp ", orderbyStr, sqlWhere);
  819. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  820. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  821. #region 处理所属部门
  822. /*
  823. * 1.sq 和 gyy 等显示 市场部
  824. * 2.王鸽和主管及张总还有管理员号统一国交部
  825. * 2-1. 4 管理员 ,21 张海麟
  826. */
  827. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  828. List<int> userIds1 = new List<int>() { 4, 21 };
  829. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  830. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  831. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  832. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  833. .ToList();
  834. foreach (var item in _DelegationList)
  835. {
  836. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  837. }
  838. #endregion
  839. var _view = new
  840. {
  841. PageFuncAuth = pageFunAuthView,
  842. Data = _DelegationList
  843. };
  844. return Ok(JsonView(true, "查询成功!", _view, total));
  845. }
  846. /// <summary>
  847. /// 接团信息详情
  848. /// </summary>
  849. /// <param name="dto">团组info请求dto</param>
  850. /// <returns></returns>
  851. [HttpPost]
  852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  853. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  854. {
  855. var groupData = await _groupRepository.GetGroupInfo(dto);
  856. if (groupData.Code != 0)
  857. {
  858. return Ok(JsonView(false, groupData.Msg));
  859. }
  860. return Ok(JsonView(groupData.Data));
  861. }
  862. /// <summary>
  863. /// 接团信息 编辑添加
  864. /// 基础信息数据源
  865. /// </summary>
  866. /// <param name="dto"></param>
  867. /// <returns></returns>
  868. [HttpPost]
  869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  870. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  871. {
  872. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  873. if (groupData.Code != 0)
  874. {
  875. return Ok(JsonView(false, groupData.Msg));
  876. }
  877. return Ok(JsonView(groupData.Data));
  878. }
  879. /// <summary>
  880. /// 接团信息 编辑添加
  881. /// 省份-城市 基础信息数据源
  882. /// </summary>
  883. /// <param name="dto"></param>
  884. /// <returns></returns>
  885. [HttpPost]
  886. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  887. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  888. {
  889. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  890. string search = dto.Search;
  891. var data = await _groupRepository.CityBasicSource();
  892. int total = data.Length;
  893. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  894. .Skip((pageIndex - 1) * pageSize)
  895. .Take(pageSize)
  896. .ToArray();
  897. return Ok(JsonView(data, total));
  898. }
  899. /// <summary>
  900. /// 接团信息 操作(增改)
  901. /// </summary>
  902. /// <param name="dto"></param>
  903. /// <returns></returns>
  904. [HttpPost]
  905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  906. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  907. {
  908. // 创建 Stopwatch 实例
  909. Stopwatch stopwatch = Stopwatch.StartNew();
  910. decimal ffrPrice = 0.00M;
  911. DateTime? visitDt = null;
  912. if (dto.Status == 2)
  913. {
  914. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  915. if (groupInfo != null)
  916. {
  917. ffrPrice = groupInfo.PaymentMoney;
  918. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  919. }
  920. }
  921. var groupData = await _groupRepository.GroupOperation(dto);
  922. if (groupData.Code != 0)
  923. {
  924. return Ok(JsonView(false, groupData.Msg));
  925. }
  926. int diId = 0;
  927. try
  928. {
  929. //添加时 默认加入团组汇率
  930. if (dto.Status == 1) //添加
  931. {
  932. diId = groupData.Data;
  933. //添加默认币种
  934. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  935. //默认分配权限
  936. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  937. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  938. var _managerIds = new List<int>() { 22, 32, 21 };
  939. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  940. if (userIds.Count > 0)
  941. {
  942. userIds.Add(208);
  943. //创建团组管控
  944. GroupStepForDelegation.CreateWorkStep(diId);
  945. //发送消息
  946. string groupName = dto.TeamName;
  947. string createGroupUser = string.Empty;
  948. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  949. if (userInfo != null) createGroupUser = userInfo.CnName;
  950. string title = $"系统通知";
  951. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  952. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  953. }
  954. //默认创建倒推表
  955. await _invertedListRep._Create(dto.UserId, diId);
  956. }
  957. else if (dto.Status == 2)
  958. {
  959. diId = dto.Id;
  960. }
  961. #region 签证人员团组时间通知
  962. #region 计算出访起止时间
  963. var startTime = new DateTime();
  964. var endTime = new DateTime();
  965. if (DateTime.TryParse(dto.VisitDate, out startTime))
  966. {
  967. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  968. }
  969. #endregion
  970. #endregion
  971. #region 团组操作默认添加/修改收款账单
  972. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  973. {
  974. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  975. .Where(x => x.IsDel == 0 &&
  976. x.Diid == diId &&
  977. x.Remark.Equals("预付款")
  978. )
  979. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  980. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  981. .FirstAsync();
  982. ffrInfo = new Fin_ForeignReceivables()
  983. {
  984. Diid = diId,
  985. PriceName = dto.ClientUnit,
  986. Price = dto.PaymentMoney,
  987. Count = 1,
  988. Unit = $"元",
  989. ItemSumPrice = dto.PaymentMoney,
  990. Rate = 1.0000M,
  991. Currency = 836,
  992. AddingWay = 0,
  993. CreateUserId = dto.UserId,
  994. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  995. Remark = $"预付款"
  996. };
  997. if (ffrInfo == null) //Add
  998. {
  999. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1000. }
  1001. else //修改
  1002. {
  1003. await _sqlSugar.Updateable(ffrInfo)
  1004. .UpdateColumns(x => new
  1005. {
  1006. x.PriceName,
  1007. x.Price,
  1008. x.ItemSumPrice,
  1009. x.CreateTime,
  1010. x.CreateUserId
  1011. })
  1012. .WhereColumns(x => x.Id)
  1013. .ExecuteCommandAsync();
  1014. }
  1015. }
  1016. #endregion
  1017. if (diId > 0)
  1018. {
  1019. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1020. }
  1021. // 停止计时
  1022. stopwatch.Stop();
  1023. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1024. }
  1025. catch (Exception ex)
  1026. {
  1027. // 停止计时
  1028. stopwatch.Stop();
  1029. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1030. Logs(ex.Message);
  1031. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1032. }
  1033. // 停止计时
  1034. stopwatch.Stop();
  1035. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1036. }
  1037. /// <summary>
  1038. /// 接团流程操作(增改)
  1039. /// 安卓端使用 建团时添加客户名单
  1040. /// </summary>
  1041. /// <param name="dto"></param>
  1042. /// <returns></returns>
  1043. [HttpPost]
  1044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1045. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1046. {
  1047. #region 参数验证
  1048. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1049. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1050. #region 页面操作权限验证
  1051. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1052. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1053. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1054. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1055. #endregion
  1056. #endregion
  1057. try
  1058. {
  1059. //_sqlSugar.BeginTran();
  1060. decimal ffrPrice = 0.00M;
  1061. DateTime? visitDt = null;
  1062. if (dto.Status == 2)
  1063. {
  1064. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1065. if (groupInfo != null)
  1066. {
  1067. ffrPrice = groupInfo.PaymentMoney;
  1068. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1069. }
  1070. }
  1071. var _dto = new GroupOperationDto();
  1072. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1073. var groupData = await _groupRepository.GroupOperation(_dto);
  1074. if (groupData.Code != 0)
  1075. {
  1076. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1077. }
  1078. int diId = 0;
  1079. //添加时 默认加入团组汇率
  1080. if (dto.Status == 1) //添加
  1081. {
  1082. diId = groupData.Data;
  1083. //添加默认币种
  1084. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1085. //默认分配权限
  1086. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1087. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1088. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1089. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1090. if (userIds.Count > 0)
  1091. {
  1092. userIds.Add(208);
  1093. //创建团组管控
  1094. GroupStepForDelegation.CreateWorkStep(diId);
  1095. //发送消息
  1096. string groupName = dto.TeamName;
  1097. string createGroupUser = string.Empty;
  1098. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1099. if (userInfo != null) createGroupUser = userInfo.CnName;
  1100. string title = $"系统通知";
  1101. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1102. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1103. }
  1104. #region 应用推送
  1105. try
  1106. {
  1107. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1108. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1109. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1110. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1111. {
  1112. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1113. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1114. }
  1115. }
  1116. catch (Exception ex)
  1117. {
  1118. }
  1119. #endregion
  1120. //默认创建倒推表
  1121. await _invertedListRep._Create(dto.UserId, diId);
  1122. }
  1123. if (dto.Status == 2)
  1124. {
  1125. diId = dto.Id;
  1126. if (diId == 0)
  1127. {
  1128. //_sqlSugar.RollbackTran();
  1129. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1130. }
  1131. }
  1132. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1133. if (viewData.Code != 0)
  1134. {
  1135. //_sqlSugar.RollbackTran();
  1136. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1137. }
  1138. #region 团组操作默认添加/修改收款账单
  1139. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1140. {
  1141. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1142. .Where(x => x.IsDel == 0 &&
  1143. x.Diid == diId &&
  1144. x.Remark.Equals("预付款")
  1145. )
  1146. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1147. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1148. .FirstAsync();
  1149. ffrInfo = new Fin_ForeignReceivables()
  1150. {
  1151. Diid = diId,
  1152. PriceName = dto.ClientUnit,
  1153. Price = dto.PaymentMoney,
  1154. Count = 1,
  1155. Unit = $"元",
  1156. ItemSumPrice = dto.PaymentMoney,
  1157. Rate = 1.0000M,
  1158. Currency = 836,
  1159. AddingWay = 0,
  1160. CreateUserId = dto.UserId,
  1161. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1162. Remark = $"预付款"
  1163. };
  1164. if (ffrInfo == null) //Add
  1165. {
  1166. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1167. }
  1168. else //修改
  1169. {
  1170. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1171. .UpdateColumns(x => new
  1172. {
  1173. x.PriceName,
  1174. x.Price,
  1175. x.ItemSumPrice,
  1176. x.CreateTime,
  1177. x.CreateUserId
  1178. })
  1179. .WhereColumns(x => x.Id)
  1180. .ExecuteCommandAsync();
  1181. }
  1182. }
  1183. #endregion
  1184. #region 签证人员团组时间通知
  1185. #region 计算出访起止时间
  1186. var startTime = new DateTime();
  1187. var endTime = new DateTime();
  1188. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1189. {
  1190. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1191. }
  1192. #endregion
  1193. if (diId > 0)
  1194. {
  1195. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1196. }
  1197. #endregion
  1198. //_sqlSugar.CommitTran();
  1199. return Ok(JsonView(true, "添加成功"));
  1200. }
  1201. catch (Exception ex)
  1202. {
  1203. _sqlSugar.RollbackTran();
  1204. return Ok(JsonView(false, ex.Message));
  1205. }
  1206. }
  1207. /// <summary>
  1208. /// 接团流程操作(增改)
  1209. /// 安卓端使用 建团时添加客户名单
  1210. /// </summary>
  1211. /// <param name="dto"></param>
  1212. /// <returns></returns>
  1213. [HttpPost]
  1214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1215. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1216. {
  1217. #region 参数验证
  1218. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1219. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1220. #region 页面操作权限验证
  1221. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1222. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1223. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1224. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1225. #endregion
  1226. #endregion
  1227. _sqlSugar.BeginTran();
  1228. decimal ffrPrice = 0.00M;
  1229. DateTime? visitDt = null;
  1230. if (dto.Status == 2)
  1231. {
  1232. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1233. if (groupInfo != null)
  1234. {
  1235. ffrPrice = groupInfo.PaymentMoney;
  1236. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1237. }
  1238. }
  1239. var _dto = new GroupOperationDto();
  1240. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1241. var groupData = await _groupRepository.GroupOperation(_dto);
  1242. if (groupData.Code != 0)
  1243. {
  1244. _sqlSugar.RollbackTran();
  1245. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1246. }
  1247. try
  1248. {
  1249. int diId = 0;
  1250. //添加时 默认加入团组汇率
  1251. if (dto.Status == 1) //添加
  1252. {
  1253. diId = groupData.Data;
  1254. //添加默认币种
  1255. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1256. //默认分配权限
  1257. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1258. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1259. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1260. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1261. if (userIds.Count > 0)
  1262. {
  1263. userIds.Add(208);
  1264. //创建团组管控
  1265. GroupStepForDelegation.CreateWorkStep(diId);
  1266. //发送消息
  1267. string groupName = dto.TeamName;
  1268. string createGroupUser = string.Empty;
  1269. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1270. if (userInfo != null) createGroupUser = userInfo.CnName;
  1271. string title = $"系统通知";
  1272. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1273. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1274. }
  1275. #region 应用推送
  1276. try
  1277. {
  1278. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1279. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1280. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1281. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1282. {
  1283. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1284. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1285. }
  1286. }
  1287. catch (Exception ex)
  1288. {
  1289. _sqlSugar.CommitTran();
  1290. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1291. }
  1292. #endregion
  1293. //默认创建倒推表
  1294. await _invertedListRep._Create(dto.UserId, diId);
  1295. }
  1296. else if (dto.Status == 2)
  1297. {
  1298. diId = dto.Id;
  1299. if (diId == 0)
  1300. {
  1301. _sqlSugar.RollbackTran();
  1302. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1303. }
  1304. }
  1305. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1306. if (viewData.Code != 0)
  1307. {
  1308. _sqlSugar.RollbackTran();
  1309. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1310. }
  1311. #region 团组操作默认添加/修改收款账单
  1312. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1313. {
  1314. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1315. .Where(x => x.IsDel == 0 &&
  1316. x.Diid == diId &&
  1317. x.Remark.Equals("预付款")
  1318. )
  1319. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1320. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1321. .FirstAsync();
  1322. ffrInfo = new Fin_ForeignReceivables()
  1323. {
  1324. Diid = diId,
  1325. PriceName = dto.ClientUnit,
  1326. Price = dto.PaymentMoney,
  1327. Count = 1,
  1328. Unit = $"元",
  1329. ItemSumPrice = dto.PaymentMoney,
  1330. Rate = 1.0000M,
  1331. Currency = 836,
  1332. AddingWay = 0,
  1333. CreateUserId = dto.UserId,
  1334. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1335. Remark = $"预付款"
  1336. };
  1337. if (ffrInfo == null) //Add
  1338. {
  1339. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1340. }
  1341. else //修改
  1342. {
  1343. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1344. .UpdateColumns(x => new
  1345. {
  1346. x.PriceName,
  1347. x.Price,
  1348. x.ItemSumPrice,
  1349. x.CreateTime,
  1350. x.CreateUserId
  1351. })
  1352. .WhereColumns(x => x.Id)
  1353. .ExecuteCommandAsync();
  1354. }
  1355. }
  1356. #endregion
  1357. #region 签证人员团组时间通知
  1358. #region 计算出访起止时间
  1359. var startTime = new DateTime();
  1360. var endTime = new DateTime();
  1361. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1362. {
  1363. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1364. }
  1365. #endregion
  1366. if (diId > 0)
  1367. {
  1368. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1369. }
  1370. #endregion
  1371. _sqlSugar.CommitTran();
  1372. return Ok(JsonView(true));
  1373. }
  1374. catch (Exception ex)
  1375. {
  1376. _sqlSugar.RollbackTran();
  1377. return Ok(JsonView(false, ex.Message));
  1378. }
  1379. }
  1380. /// <summary>
  1381. /// 接团信息 操作(删除)
  1382. /// </summary>
  1383. /// <param name="dto"></param>
  1384. /// <returns></returns>
  1385. [HttpPost]
  1386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1387. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1388. {
  1389. var diId = dto.Id;
  1390. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1391. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1392. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1393. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1394. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1395. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1396. #endregion
  1397. var groupData = await _groupRepository.GroupDel(dto);
  1398. if (groupData.Code != 0)
  1399. {
  1400. return Ok(JsonView(false, groupData.Msg));
  1401. }
  1402. return Ok(JsonView(true));
  1403. }
  1404. /// <summary>
  1405. /// 获取团组销售报价号
  1406. /// 团组添加时 使用
  1407. /// </summary>
  1408. /// <returns></returns>
  1409. [HttpPost]
  1410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1411. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1412. {
  1413. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1414. if (groupData.Code != 0)
  1415. {
  1416. return Ok(JsonView(false, groupData.Msg));
  1417. }
  1418. object salesQuoteNo = new
  1419. {
  1420. SalesQuoteNo = groupData.Data
  1421. };
  1422. return Ok(JsonView(salesQuoteNo));
  1423. }
  1424. /// <summary>
  1425. /// 设置确认出团
  1426. /// </summary>
  1427. /// <param name="dto"></param>
  1428. /// <returns></returns>
  1429. [HttpPost]
  1430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1431. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1432. {
  1433. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1434. if (groupData.Code != 0)
  1435. {
  1436. return Ok(JsonView(false, groupData.Msg));
  1437. }
  1438. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1439. #region OA消息推送
  1440. try
  1441. {
  1442. string groupName = groupInfo.TeamName;
  1443. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1444. string title = $"系统通知";
  1445. string content = $"团组[{groupName}]已确认出团!";
  1446. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1447. }
  1448. catch (Exception ex)
  1449. {
  1450. }
  1451. #endregion
  1452. #region 应用推送
  1453. try
  1454. {
  1455. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1456. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1457. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1458. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1459. {
  1460. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1461. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1462. }
  1463. }
  1464. catch (Exception ex)
  1465. {
  1466. }
  1467. #endregion
  1468. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1469. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1470. }
  1471. /// <summary>
  1472. /// 获取团组名称data And 签证国别Data
  1473. /// </summary>
  1474. /// <param name="dto"></param>
  1475. /// <returns></returns>
  1476. [HttpPost]
  1477. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1478. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1479. {
  1480. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1481. if (groupData.Code != 0)
  1482. {
  1483. return Ok(JsonView(false, groupData.Msg));
  1484. }
  1485. return Ok(JsonView(groupData.Data));
  1486. }
  1487. /// <summary>
  1488. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1489. /// </summary>
  1490. /// <returns></returns>
  1491. [HttpPost]
  1492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1493. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1494. {
  1495. try
  1496. {
  1497. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1498. if (groupData.Code != 0)
  1499. {
  1500. return Ok(JsonView(false, groupData.Msg));
  1501. }
  1502. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1503. }
  1504. catch (Exception ex)
  1505. {
  1506. return Ok(JsonView(false, "程序错误!"));
  1507. throw;
  1508. }
  1509. }
  1510. /// <summary>
  1511. /// 团组清单 Excel
  1512. /// </summary>
  1513. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1514. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1515. /// <returns></returns>
  1516. [HttpGet]
  1517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1518. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1519. {
  1520. DateTime _beginDt, _endDt;
  1521. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1522. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1523. if (!beginBool && !endBool)
  1524. {
  1525. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1526. }
  1527. string sql = string.Format(@"
  1528. SELECT
  1529. ROW_NUMBER,
  1530. Id,
  1531. SalesQuoteNo,
  1532. TourCode,
  1533. TeamTypeId,
  1534. TeamType,
  1535. TeamLevId,
  1536. TeamLev,
  1537. TeamName,
  1538. ClientName,
  1539. ClientUnit,
  1540. VisitDate,
  1541. VisitDays,
  1542. VisitPNumber,
  1543. JietuanOperatorId,
  1544. JietuanOperator,
  1545. IsSure,
  1546. CreateUserName,
  1547. IsBid
  1548. FROM
  1549. (
  1550. SELECT
  1551. ROW_NUMBER() OVER(
  1552. ORDER BY
  1553. gdi.CreateTime Desc
  1554. ) AS ROW_NUMBER,
  1555. gdi.Id,
  1556. SalesQuoteNo,
  1557. TourCode,
  1558. ssd.Id TeamTypeId,
  1559. ssd.Name TeamType,
  1560. ssd1.Id TeamLevId,
  1561. ssd1.Name TeamLev,
  1562. TeamName,
  1563. ClientName,
  1564. ClientUnit,
  1565. VisitDate,
  1566. VisitDays,
  1567. VisitPNumber,
  1568. JietuanOperator JietuanOperatorId,
  1569. su.CnName JietuanOperator,
  1570. IsSure,
  1571. gdi.CreateTime,
  1572. su1.CnName As CreateUserName,
  1573. gdi.IsBid
  1574. FROM
  1575. Grp_DelegationInfo gdi
  1576. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1577. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1578. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1579. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1580. WHERE
  1581. gdi.IsDel = 0
  1582. AND gdi.IsBid = 0
  1583. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1584. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1585. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1586. #region 处理所属部门
  1587. /*
  1588. * 1.sq 和 gyy 等显示 市场部
  1589. * 2.王鸽和主管及张总还有管理员号统一国交部
  1590. * 2-1. 4 管理员 ,21 张海麟
  1591. */
  1592. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1593. List<int> userIds1 = new List<int>() { 4, 21 };
  1594. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1595. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1596. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1597. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1598. .ToListAsync();
  1599. var droupIds = groupList.Select(it => it.Id).ToList();
  1600. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1601. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1602. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1603. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1604. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1605. {
  1606. DiId = tcl.DiId,
  1607. LastName = dc.LastName,
  1608. FirstName = dc.FirstName,
  1609. Sex = dc.Sex,
  1610. Birthday = dc.BirthDay,
  1611. Company = cc.CompanyFullName,
  1612. Job = dc.Job,
  1613. CreateTime = tcl.CreateTime,
  1614. })
  1615. .ToList();
  1616. foreach (var item in groupList)
  1617. {
  1618. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1619. string groupFirstName = "";
  1620. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1621. if (currDatas.Any())
  1622. {
  1623. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1624. }
  1625. item.GroupFirst = groupFirstName;
  1626. }
  1627. #endregion
  1628. #region Excel
  1629. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1630. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1631. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1632. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1633. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1634. //载入模板
  1635. WorkbookDesigner designer = new WorkbookDesigner();
  1636. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1637. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1638. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1639. dt.TableName = "GroupList";
  1640. designer.SetDataSource(dt);
  1641. designer.Process();
  1642. if (!Directory.Exists(savePath))
  1643. {
  1644. Directory.CreateDirectory(savePath);
  1645. }
  1646. string serverPath = $"{savePath}{fileName}";
  1647. designer.Workbook.Save(serverPath);
  1648. string rst = $"{servicePath}{ftpPath}{fileName}";
  1649. #endregion
  1650. return Ok(JsonView(true, "操作成功!", rst));
  1651. }
  1652. #endregion
  1653. #region 团组&签证
  1654. /// <summary>
  1655. /// 根据团组Id获取签证客户信息List
  1656. /// </summary>
  1657. /// <param name="dto">请求dto</param>
  1658. /// <returns></returns>
  1659. [HttpPost]
  1660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1661. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1662. {
  1663. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1664. if (groupData.Code != 0)
  1665. {
  1666. return Ok(JsonView(false, groupData.Msg));
  1667. }
  1668. return Ok(JsonView(groupData.Data));
  1669. }
  1670. /// <summary>
  1671. /// IOS获取团组签证拍照上传进度01(团组列表)
  1672. /// </summary>
  1673. /// <param name="dto">请求dto</param>
  1674. /// <returns></returns>
  1675. [HttpPost]
  1676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1677. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1678. {
  1679. if (dto == null)
  1680. {
  1681. return Ok(JsonView(false, "参数为空"));
  1682. }
  1683. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1684. return Ok(JsonView(visaList));
  1685. }
  1686. /// <summary>
  1687. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1688. /// </summary>
  1689. /// <returns></returns>
  1690. [HttpPost]
  1691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1692. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1693. {
  1694. if (dto == null)
  1695. {
  1696. return Ok(JsonView(false, "请求错误:"));
  1697. }
  1698. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1699. return Ok(JsonView(list));
  1700. }
  1701. /// <summary>
  1702. /// IOS获取团组签证拍照上传进度03(相册)
  1703. /// </summary>
  1704. /// <returns></returns>
  1705. [HttpPost]
  1706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1707. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1708. {
  1709. if (dto == null)
  1710. {
  1711. return Ok(JsonView(false, "请求错误:"));
  1712. }
  1713. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1714. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1715. list.ForEach(s => s.url = url);
  1716. return Ok(JsonView(list));
  1717. }
  1718. /// <summary>
  1719. /// IOS获取团组签证拍照上传进度04(图片上传)
  1720. /// </summary>
  1721. /// <param name="dto"></param>
  1722. /// <returns></returns>
  1723. [HttpPost]
  1724. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1725. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1726. {
  1727. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1728. //if (!string.IsNullOrEmpty(result))
  1729. //{
  1730. //}
  1731. //else {
  1732. // return Ok(JsonView(false, "上传失败"));
  1733. //}
  1734. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1735. int sucNum = 0;
  1736. try
  1737. {
  1738. foreach (var item in dto.base64DataList)
  1739. {
  1740. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1741. string result = DecodeBase64ToImage(item, imageName);
  1742. if (!string.IsNullOrEmpty(result))
  1743. {
  1744. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1745. pic.CreateUserId = dto.CreateUserId;
  1746. pic.PicName = imageName;
  1747. pic.PicPath = result;
  1748. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1749. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1750. if (insertResult > 0)
  1751. {
  1752. sucNum++;
  1753. }
  1754. }
  1755. }
  1756. }
  1757. catch (Exception ex)
  1758. {
  1759. return Ok(JsonView(false, ex.Message));
  1760. }
  1761. string msg = string.Format(@"成功上传{0}张", sucNum);
  1762. return Ok(JsonView(true, msg));
  1763. }
  1764. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  1765. {
  1766. string filename = "";//声明一个string类型的相对路径
  1767. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1768. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1769. try//会有异常抛出,try,catch一下
  1770. {
  1771. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1772. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1773. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1774. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1775. //文件名称
  1776. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1777. //上传的文件的路径
  1778. string filePath = "";
  1779. if (!Directory.Exists(fileDir))
  1780. {
  1781. Directory.CreateDirectory(fileDir);
  1782. }
  1783. //上传的文件的路径
  1784. filePath = fileDir + filename;
  1785. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1786. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1787. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1788. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1789. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1790. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1791. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1792. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1793. bitmap.Dispose();
  1794. }
  1795. catch (Exception e)
  1796. {
  1797. string massage = e.Message;
  1798. Logs("IOS图片上传Error:" + massage);
  1799. //filename = e.Message;
  1800. }
  1801. return filename;//返回相对路径
  1802. }
  1803. /// <summary>
  1804. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1805. /// </summary>
  1806. /// <param name="dto"></param>
  1807. /// <returns></returns>
  1808. [HttpPost]
  1809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1810. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1811. {
  1812. if (dto == null)
  1813. {
  1814. return Ok(JsonView(false, "请求错误:"));
  1815. }
  1816. string msg = "参数错误";
  1817. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1818. {
  1819. try
  1820. {
  1821. //_delegationVisaRep.BeginTran();
  1822. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1823. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1824. .Where(s => s.Id == dto.visaProgressCustomerId)
  1825. .ExecuteCommandAsync();
  1826. if (updCount > 0 && dto.publishCode == 1)
  1827. {
  1828. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1829. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1830. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1831. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1832. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1833. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1834. if (groupData == null)
  1835. {
  1836. _delegationVisaRep.RollbackTran();
  1837. }
  1838. string title = string.Format(@"[签证进度更新]");
  1839. string content = string.Format(@"测试文本");
  1840. bool rst = await _message.AddMsg(new MessageDto()
  1841. {
  1842. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1843. IssuerId = dto.publisher,
  1844. Title = title,
  1845. Content = content,
  1846. ReleaseTime = DateTime.Now,
  1847. UIdList = new List<int> {
  1848. 234
  1849. }
  1850. });
  1851. if (rst)
  1852. {
  1853. return Ok(JsonView(true, "发送通知成功"));
  1854. }
  1855. }
  1856. //_delegationVisaRep.CommitTran();
  1857. }
  1858. catch (Exception)
  1859. {
  1860. //_delegationVisaRep.RollbackTran();
  1861. }
  1862. }
  1863. return Ok(JsonView(true, msg));
  1864. }
  1865. #endregion
  1866. #region 团组任务分配
  1867. /// <summary>
  1868. /// 团组任务分配初始化
  1869. /// </summary>
  1870. /// <returns></returns>
  1871. [HttpPost]
  1872. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1873. public async Task<IActionResult> GetTaskAssignmen()
  1874. {
  1875. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1876. if (groupData.Code != 0)
  1877. {
  1878. return Ok(JsonView(false, groupData.Msg));
  1879. }
  1880. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1881. }
  1882. /// <summary>
  1883. /// 团组任务分配查询
  1884. /// </summary>
  1885. /// <param name="dto"></param>
  1886. /// <returns></returns>
  1887. [HttpPost]
  1888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1889. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1890. {
  1891. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1892. if (groupData.Code != 0)
  1893. {
  1894. return Ok(JsonView(false, groupData.Msg));
  1895. }
  1896. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1897. }
  1898. /// <summary>
  1899. /// 团组任务分配操作
  1900. /// </summary>
  1901. /// <param name="dto"></param>
  1902. /// <returns></returns>
  1903. [HttpPost]
  1904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1905. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1906. {
  1907. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1908. if (groupData.Code != 0)
  1909. {
  1910. return Ok(JsonView(false, groupData.Msg));
  1911. }
  1912. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1913. }
  1914. /// <summary>
  1915. /// 团组任务分配
  1916. /// 批量分配
  1917. /// 查询团组
  1918. /// </summary>
  1919. /// <param name="dto"></param>
  1920. /// <returns></returns>
  1921. [HttpPost]
  1922. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1923. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1924. {
  1925. //参数验证
  1926. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1927. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1928. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1929. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1930. }
  1931. /// <summary>
  1932. /// 团组任务分配
  1933. /// 批量分配
  1934. /// </summary>
  1935. /// <param name="dto"></param>
  1936. /// <returns></returns>
  1937. [HttpPost]
  1938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1939. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1940. {
  1941. //参数验证
  1942. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1943. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1944. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1945. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1946. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1947. }
  1948. #endregion
  1949. #region 团组费用审核
  1950. /// <summary>
  1951. /// 费用审核
  1952. /// 团组列表 Page
  1953. /// </summary>
  1954. /// <param name="_dto">团组列表请求dto</param>
  1955. /// <returns></returns>
  1956. [HttpPost]
  1957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1958. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1959. {
  1960. #region 参数验证
  1961. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1962. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1963. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1964. #region 页面操作权限验证
  1965. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1966. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1967. #endregion
  1968. #endregion
  1969. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1970. {
  1971. string sqlWhere = string.Empty;
  1972. if (_dto.IsSure == 0) //未完成
  1973. {
  1974. sqlWhere += string.Format(@" And IsSure = 0");
  1975. }
  1976. else if (_dto.IsSure == 1) //已完成
  1977. {
  1978. sqlWhere += string.Format(@" And IsSure = 1");
  1979. }
  1980. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1981. {
  1982. string tj = _dto.SearchCriteria;
  1983. 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}%')",
  1984. tj, tj, tj, tj, tj);
  1985. }
  1986. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1987. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1988. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1989. From (
  1990. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1991. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1992. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1993. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1994. From Grp_DelegationInfo gdi
  1995. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1996. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1997. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1998. Where gdi.IsDel = 0 {0}
  1999. ) temp ", sqlWhere);
  2000. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2001. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2002. var _view = new
  2003. {
  2004. PageFuncAuth = pageFunAuthView,
  2005. Data = _DelegationList
  2006. };
  2007. return Ok(JsonView(true, "查询成功!", _view, total));
  2008. }
  2009. else
  2010. {
  2011. return Ok(JsonView(false, "查询失败"));
  2012. }
  2013. }
  2014. /// <summary>
  2015. /// 获取团组费用审核
  2016. /// </summary>
  2017. /// <param name="_dto"></param>
  2018. /// <returns></returns>
  2019. [HttpPost]
  2020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2021. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2022. {
  2023. try
  2024. {
  2025. #region 参数验证
  2026. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2027. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2028. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2029. #region 页面操作权限验证
  2030. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2031. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2032. #endregion
  2033. #endregion
  2034. var _view = new Grp_CreditCardPaymentView();
  2035. var clientNameList = getSimplClientList(_dto.DiId);
  2036. #region 费用清单
  2037. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2038. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2039. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2040. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2041. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2042. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2043. /*
  2044. * 76://酒店预订
  2045. */
  2046. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2047. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2048. /*
  2049. * 79://车/导游地接
  2050. */
  2051. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2052. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2053. /*
  2054. * 80: //签证
  2055. */
  2056. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2057. /*
  2058. *81: //邀请/公务活动
  2059. */
  2060. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2061. /*
  2062. * 82: //团组客户保险
  2063. */
  2064. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2065. /*
  2066. * Lable = 85 机票预订
  2067. */
  2068. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2069. /*
  2070. * 85 机票预定
  2071. */
  2072. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2073. /*
  2074. * 98 其他款项
  2075. */
  2076. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2077. /*
  2078. * 285:收款退还
  2079. */
  2080. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2081. /*
  2082. * 1015: //超支费用
  2083. */
  2084. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2085. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2086. /*
  2087. * 币种信息
  2088. */
  2089. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2090. /*
  2091. * 车/导游地接 费用类型
  2092. */
  2093. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2094. /*
  2095. * 车/导游地接 费用类型
  2096. */
  2097. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2098. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2099. /*
  2100. * 用户信息
  2101. */
  2102. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2103. /*
  2104. * 费用模块
  2105. */
  2106. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2107. string priceModule = string.Empty;
  2108. if (sdPriceName != null)
  2109. {
  2110. priceModule = sdPriceName.Name;
  2111. }
  2112. /*
  2113. * 成本信息
  2114. */
  2115. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2116. decimal _groupRate = 0.0000M;
  2117. string _groupCurrencyCode = "-";
  2118. if (groupCost != null)
  2119. {
  2120. _groupRate = groupCost.Rate;
  2121. if (int.TryParse(groupCost.Currency, out int _currency))
  2122. {
  2123. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2124. }
  2125. else _groupCurrencyCode = groupCost.Currency;
  2126. }
  2127. string costContentSql = $"Select * From Grp_GroupCost";
  2128. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2129. //处理日期为空的天数
  2130. for (int i = 0; i < groupCostDetails.Count; i++)
  2131. if (i != 0)
  2132. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2133. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2134. /*
  2135. * 处理详情数据
  2136. */
  2137. foreach (var entity in entityList)
  2138. {
  2139. var _detail = new Grp_CreditCardPaymentDetailView();
  2140. _detail.Id = entity.Id;
  2141. _detail.PriceName = priceModule;
  2142. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2143. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2144. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2145. //处理金额
  2146. if (entity.CTable == 1015)
  2147. {
  2148. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2149. if (czInfo != null)
  2150. {
  2151. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2152. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2153. }
  2154. }
  2155. /*
  2156. * 应付款金额
  2157. */
  2158. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2159. string PaymentCurrency_WaitPay = "Unknown";
  2160. string hotelCurrncyCode = "Unknown";
  2161. string hotelCurrncyName = "Unknown";
  2162. if (sdPaymentCurrency_WaitPay != null)
  2163. {
  2164. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2165. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2166. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2167. if (hotelCurrncyCode.Equals("CNY"))
  2168. {
  2169. entity.DayRate = 1.0000M;
  2170. }
  2171. }
  2172. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2173. /*
  2174. * 此次付款金额
  2175. */
  2176. decimal CurrPayStr = 0.00M,
  2177. OriginalCurrPay = 0.00M;
  2178. if (entity.PayPercentage == 0)
  2179. {
  2180. if (entity.PayThenMoney != 0)
  2181. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2182. }
  2183. else
  2184. {
  2185. if (entity.PayMoney != 0)
  2186. {
  2187. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2188. }
  2189. }
  2190. //if (_dto.Label == 79)
  2191. //{
  2192. // string original = string.Empty;
  2193. // if (hotelCurrncyCode.Equals("CNY"))
  2194. // {
  2195. // OriginalCurrPay = CurrPayStr;
  2196. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2197. // }
  2198. // else
  2199. // {
  2200. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2201. // //760 EUR(7600.00 CNY)
  2202. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2203. // }
  2204. //}
  2205. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2206. string original = string.Empty;
  2207. if (hotelCurrncyCode.Equals("CNY"))
  2208. {
  2209. OriginalCurrPay = CurrPayStr;
  2210. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2211. }
  2212. else
  2213. {
  2214. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2215. //760 EUR(7600.00 CNY)
  2216. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2217. }
  2218. /*
  2219. * 剩余尾款
  2220. */
  2221. decimal BalanceStr = 0;
  2222. if (CurrPayStr != 0)
  2223. {
  2224. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2225. BalanceStr = 0;
  2226. else
  2227. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2228. }
  2229. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2230. /*
  2231. * Bus名称
  2232. */
  2233. _detail.BusName = "待增加";
  2234. /*
  2235. *费用所属
  2236. */
  2237. switch (entity.CTable)
  2238. {
  2239. case 76://酒店预订
  2240. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2241. if (hotelReservations != null)
  2242. {
  2243. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2244. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2245. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2246. string roomFeeStr = "", roomFeestr1 = "";
  2247. //是否比较房型价格
  2248. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2249. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2250. roomFeeStr += $"<br/>";
  2251. var roomTotal = 0.00M;
  2252. if (hotelReservations.SingleRoomPrice > 0)
  2253. {
  2254. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  2255. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2256. //__isSingle = true;
  2257. roomTotal += fee;
  2258. }
  2259. if (hotelReservations.DoubleRoomPrice > 0)
  2260. {
  2261. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  2262. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2263. // __isDouble = true;
  2264. roomTotal += fee;
  2265. }
  2266. if (hotelReservations.SuiteRoomPrice > 0)
  2267. {
  2268. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2269. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2270. //__isSuite = true;
  2271. roomTotal += fee;
  2272. }
  2273. if (hotelReservations.OtherRoomPrice > 0)
  2274. {
  2275. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2276. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2277. //__isOther = true;
  2278. roomTotal += fee;
  2279. }
  2280. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2281. else roomFeeStr += " 0.00 * 0";
  2282. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2283. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2284. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2285. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2286. /*
  2287. * 费用类型
  2288. * 1:房费
  2289. * 2:早餐
  2290. * 3:地税
  2291. * 4:城市税
  2292. * </summary>
  2293. */
  2294. //地税
  2295. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2296. if (governmentRentData != null)
  2297. {
  2298. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2299. governmentRentFee = governmentRentData.Price;
  2300. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2301. if (governmentRentCurrData != null)
  2302. {
  2303. governmentRentCode = governmentRentCurrData.Name;
  2304. governmentRentName = $"({governmentRentCurrData.Remark})";
  2305. }
  2306. }
  2307. //城市税
  2308. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2309. if (cityTaxData != null)
  2310. {
  2311. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2312. cityTaxFee = cityTaxData.Price;
  2313. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2314. if (cityTaxCurrData != null)
  2315. {
  2316. cityTaxCode = cityTaxCurrData.Name;
  2317. cityTaxName = $"({cityTaxCurrData.Remark})";
  2318. }
  2319. }
  2320. //酒店早餐
  2321. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2322. if (breakfastData != null)
  2323. {
  2324. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2325. breakfastFee = breakfastData.Price;
  2326. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2327. if (breakfastCurrData != null)
  2328. {
  2329. breakfastCode = breakfastCurrData.Name;
  2330. breakfastName = $"({breakfastCurrData.Remark})";
  2331. }
  2332. }
  2333. //房间费用
  2334. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2335. if (roomData != null)
  2336. {
  2337. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2338. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2339. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2340. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2341. roomFee = roomData.Price;
  2342. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2343. if (roomCurrData != null)
  2344. {
  2345. roomCode = roomCurrData.Name;
  2346. roomName = $"({roomCurrData.Remark})";
  2347. }
  2348. }
  2349. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2350. string hotelCostStr = "";
  2351. decimal hotelCsotTotal = 0.00M;
  2352. if (groupCost != null)
  2353. {
  2354. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2355. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2356. }
  2357. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2358. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2359. string hotelCost_day = "";
  2360. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2361. foreach (var item in hotelCostDetails1)
  2362. {
  2363. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2364. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2365. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2366. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2367. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2368. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2369. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2370. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2371. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2372. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2373. hotelCost_day += @$"<br/>";
  2374. }
  2375. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2376. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2377. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2378. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2379. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2380. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2381. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2382. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2383. $"房间说明: {hotelReservations.Remark} <br/>" +
  2384. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2385. $"{hotelBreakfastStr}" +
  2386. $"{hotelGovernmentRentStr}" +
  2387. $"{hotelCityTaxStr}";
  2388. _detail.PriceNameContent = hotelReservations.HotelName;
  2389. }
  2390. break;
  2391. case 79://车/导游地接
  2392. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2393. if (touristGuideGroundReservations != null)
  2394. {
  2395. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2396. {
  2397. _detail.BusName = touristGuideGroundReservations.BusName;
  2398. }
  2399. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2400. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2401. //if (isInt)
  2402. //{
  2403. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2404. // if (cityInfo != null)
  2405. // {
  2406. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2407. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2408. // if (carFeeItem != null)
  2409. // {
  2410. // nameContent += $@"({carFeeItem.Name})";
  2411. // }
  2412. // _detail.PriceNameContent = nameContent;
  2413. // }
  2414. //}
  2415. //else
  2416. //{
  2417. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2418. //}
  2419. var touristGuideGroundReservationsContents =
  2420. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2421. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2422. foreach (var item in touristGuideGroundReservationsContents)
  2423. {
  2424. string typeName = "Unknown";
  2425. string carCurrencyCode = "Unknown";
  2426. string carCurrencyName = "Unknown";
  2427. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2428. if (carTypeData != null) typeName = carTypeData.Name;
  2429. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2430. if (currencyData != null)
  2431. {
  2432. carCurrencyCode = currencyData.Name;
  2433. carCurrencyName = currencyData.Remark;
  2434. }
  2435. //op、成本 币种是否一致
  2436. bool IsCurrencyAgreement = false;
  2437. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2438. string opCostStr = string.Empty;
  2439. decimal opCostTypePrice = 0.00M;
  2440. #region 处理成本各项费用
  2441. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2442. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2443. if (opCost.Count > 0)
  2444. {
  2445. switch (item.SId)
  2446. {
  2447. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2448. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2449. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2450. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2451. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2452. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2453. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2454. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2455. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2456. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2457. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2458. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2459. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2460. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2461. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2462. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2463. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2464. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2465. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2466. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2467. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2468. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2469. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2470. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2471. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2472. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2473. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2474. }
  2475. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2476. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2477. }
  2478. #endregion
  2479. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2480. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2481. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2482. $"{opTypeStr} {opCostStr}<br/>" +
  2483. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2484. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2485. }
  2486. _detail.PriceMsgContent = priceMsg;
  2487. }
  2488. break;
  2489. case 80: //签证
  2490. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2491. if (visaInfo != null)
  2492. {
  2493. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2494. _detail.PriceNameContent = visaInfo.VisaDescription;
  2495. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2496. }
  2497. break;
  2498. case 81: //邀请/公务活动
  2499. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2500. if (_ioa != null)
  2501. {
  2502. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2503. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2504. sendCurrName = "Unknown", //快递费用币种 Name
  2505. sendCurrCode = "Unknown", //快递费用币种 Code
  2506. eventsCurrName = "Unknown", //公务活动费币种 Name
  2507. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2508. translateCurrName = "Unknown", //公务翻译费 Name
  2509. translateCurrCode = "Unknown"; //公务翻译费 Code
  2510. #region 处理费用币种
  2511. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2512. if (inviteCurrData != null)
  2513. {
  2514. inviteCurrName = inviteCurrData.Remark;
  2515. inviteCurrCode = inviteCurrData.Name;
  2516. }
  2517. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2518. if (sendCurrData != null)
  2519. {
  2520. sendCurrName = sendCurrData.Remark;
  2521. sendCurrCode = sendCurrData.Name;
  2522. }
  2523. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2524. if (eventsCurrData != null)
  2525. {
  2526. eventsCurrName = eventsCurrData.Remark;
  2527. eventsCurrCode = eventsCurrData.Name;
  2528. }
  2529. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2530. if (translateCurrData != null)
  2531. {
  2532. translateCurrName = translateCurrData.Remark;
  2533. translateCurrCode = translateCurrData.Name;
  2534. }
  2535. #endregion
  2536. _detail.PriceNameContent = _ioa.InviterArea;
  2537. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2538. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2539. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2540. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2541. $@"备注:" + _ioa.Remark + "<br/>";
  2542. }
  2543. break;
  2544. case 82: //团组客户保险
  2545. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2546. if (customers != null)
  2547. {
  2548. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2549. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2550. }
  2551. break;
  2552. case 85: //机票预订
  2553. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2554. if (jpRes != null)
  2555. {
  2556. string FlightsDescription = jpRes.FlightsDescription;
  2557. string PriceDescription = jpRes.PriceDescription;
  2558. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2559. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2560. }
  2561. break;
  2562. case 98://其他款项
  2563. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2564. if (gdpRes != null)
  2565. {
  2566. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2567. _detail.PriceNameContent = gdpRes.PriceName;
  2568. }
  2569. break;
  2570. case 285://收款退还
  2571. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2572. if (refundAndOtherMoney != null)
  2573. {
  2574. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2575. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2576. }
  2577. break;
  2578. case 751://酒店早餐
  2579. break;
  2580. case 1015://超支费用
  2581. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2582. if (groupExtraCost != null)
  2583. {
  2584. _detail.PriceNameContent = groupExtraCost.PriceName;
  2585. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2586. }
  2587. break;
  2588. default:
  2589. break;
  2590. }
  2591. /*
  2592. * 申请人
  2593. */
  2594. string operatorName = " - ";
  2595. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2596. if (_opUser != null)
  2597. {
  2598. operatorName = _opUser.CnName;
  2599. }
  2600. _detail.OperatorName = operatorName;
  2601. /*
  2602. * 审核人
  2603. */
  2604. string auditOperatorName = "Unknown";
  2605. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2606. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2607. else
  2608. {
  2609. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2610. if (_adUser != null)
  2611. {
  2612. auditOperatorName = _adUser.CnName;
  2613. }
  2614. }
  2615. _detail.AuditOperatorName = auditOperatorName;
  2616. /*
  2617. * 超预算比例
  2618. */
  2619. string overBudgetStr = "";
  2620. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2621. else if (entity.ExceedBudget == 0)
  2622. {
  2623. if (entity.CTable == 76 || entity.CTable == 79)
  2624. {
  2625. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2626. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2627. }
  2628. else
  2629. {
  2630. overBudgetStr = "未超预算";
  2631. }
  2632. }
  2633. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2634. _detail.OverBudget = overBudgetStr;
  2635. decimal auditFee = 0.00M; //已审核金额 人名币
  2636. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2637. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2638. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2639. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2640. {
  2641. auditedFeeOriginal = entity.PayMoney;
  2642. auditFee = CurrPayStr;
  2643. }
  2644. else if (entity.IsAuditGM == 0)
  2645. {
  2646. unAuditFeeCNY = CurrPayStr;
  2647. unAuditFeeOriginal = OriginalCurrPay;
  2648. OriginalCurrPay = 0.00M;
  2649. }
  2650. /*
  2651. * 费用总计
  2652. */
  2653. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2654. {
  2655. CurrencyId = entity.PaymentCurrency,
  2656. CurrencyName = PaymentCurrency_WaitPay,
  2657. AmountPayable = entity.PayMoney,
  2658. ThisPayment = OriginalCurrPay,
  2659. BalancePayment = BalanceStr,
  2660. AuditedFunds = auditFee,
  2661. AuditedFundsOriginal = auditedFeeOriginal,
  2662. UnAuditFundsCNY = unAuditFeeCNY,
  2663. UnAuditFundsOriginal = unAuditFeeOriginal
  2664. });
  2665. _detail.IsAuditGM = entity.IsAuditGM;
  2666. detailList.Add(_detail);
  2667. }
  2668. #endregion
  2669. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2670. /*
  2671. * 下方描述处理
  2672. */
  2673. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2674. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2675. if (ccpCurrencyPrice != null)
  2676. {
  2677. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2678. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2679. }
  2680. else
  2681. {
  2682. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2683. }
  2684. string amountPayableStr = string.Format(@"应付款总金额: ");
  2685. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2686. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2687. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2688. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2689. foreach (var item in nonDuplicat)
  2690. {
  2691. var currencyName = item.CurrencyName;
  2692. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2693. if (strs.Count > 0)
  2694. {
  2695. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2696. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2697. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2698. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2699. //单独处理此次付款金额
  2700. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2701. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2702. //单独处理已审核费用
  2703. //if (item.CurrencyId == 836) //人民币
  2704. //{
  2705. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2706. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2707. //}
  2708. //else
  2709. //{
  2710. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2711. //}
  2712. if (currencyName.Equals("CNY"))
  2713. {
  2714. //已审核费用
  2715. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2716. //未审核费用
  2717. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2718. }
  2719. else
  2720. {
  2721. //已审核费用
  2722. 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"));
  2723. //未审核费用
  2724. 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"));
  2725. }
  2726. }
  2727. }
  2728. _view.TotalStr1 = amountPayableStr[..^1];
  2729. _view.TotalStr2 = thisPaymentStr[..^1];
  2730. _view.TotalStr3 = balancePaymentStr[..^1];
  2731. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  2732. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2733. var _view1 = new
  2734. {
  2735. PageFuncAuth = pageFunAuthView,
  2736. Data = _view
  2737. };
  2738. return Ok(JsonView(_view1));
  2739. }
  2740. catch (Exception ex)
  2741. {
  2742. return Ok(JsonView(false, ex.Message));
  2743. }
  2744. }
  2745. /// <summary>
  2746. /// 费用审核
  2747. /// 修改团组费用审核状态
  2748. /// </summary>
  2749. /// <param name="_dto">参数Json字符串</param>
  2750. /// <returns></returns>
  2751. [HttpPost]
  2752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2753. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2754. {
  2755. #region 参数验证
  2756. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2757. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2758. #endregion
  2759. #region 页面操作权限验证
  2760. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2761. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2762. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2763. #endregion
  2764. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2765. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2766. DateTime dtNow = DateTime.Now;
  2767. _groupRepository.BeginTran();
  2768. int rst = 0;
  2769. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2770. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2771. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2772. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2773. List<dynamic> msgDatas = new List<dynamic>();
  2774. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2775. foreach (var item in idList)
  2776. {
  2777. int CreditId = int.Parse(item);
  2778. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2779. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2780. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2781. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2782. .Where(s => s.Id == CreditId)
  2783. .ExecuteCommandAsync();
  2784. if (result < 1)
  2785. {
  2786. rst = -1;
  2787. _groupRepository.RollbackTran();
  2788. return Ok(JsonView(false, "操作失败并回滚!"));
  2789. }
  2790. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2791. if (creditData != null)
  2792. {
  2793. #region 应用通知配置
  2794. try
  2795. {
  2796. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2797. }
  2798. catch (Exception ex)
  2799. {
  2800. }
  2801. #endregion
  2802. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2803. string groupNameStr = string.Empty;
  2804. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2805. if (groupData != null) groupNameStr = groupData.TeamName;
  2806. string creditTypeStr = string.Empty;
  2807. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2808. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2809. string creditCurrency = string.Empty;
  2810. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2811. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2812. if (creditCurrency.Equals("CNY"))
  2813. {
  2814. creditData.DayRate = 1.0000M;
  2815. }
  2816. if (creditData.PayPercentage == 0.00M)
  2817. {
  2818. creditData.PayPercentage = 100M;
  2819. }
  2820. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2821. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2822. string msgContent = "";
  2823. if (creditCurrency.Equals("CNY"))
  2824. {
  2825. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2826. }
  2827. else
  2828. {
  2829. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2830. }
  2831. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2832. }
  2833. }
  2834. if (rst == 0)
  2835. {
  2836. _groupRepository.CommitTran();
  2837. foreach (var item in msgDatas)
  2838. {
  2839. //发送消息
  2840. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2841. }
  2842. #region 应用推送
  2843. try
  2844. {
  2845. foreach (var ccpId in dic_ccp_user.Keys)
  2846. {
  2847. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2848. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2849. }
  2850. }
  2851. catch (Exception)
  2852. {
  2853. }
  2854. #endregion
  2855. return Ok(JsonView(true, "操作成功!"));
  2856. }
  2857. return Ok(JsonView(false, "操作失败!"));
  2858. }
  2859. #endregion
  2860. #region 机票费用录入
  2861. /// <summary>
  2862. /// 机票录入当前登录人可操作团组
  2863. /// </summary>
  2864. /// <param name="dto"></param>
  2865. /// <returns></returns>
  2866. [HttpPost]
  2867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2868. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2869. {
  2870. try
  2871. {
  2872. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2873. if (groupData.Code != 0)
  2874. {
  2875. return Ok(JsonView(false, groupData.Msg));
  2876. }
  2877. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2878. }
  2879. catch (Exception ex)
  2880. {
  2881. return Ok(JsonView(false, "程序错误!"));
  2882. throw;
  2883. }
  2884. }
  2885. /// <summary>
  2886. /// 机票费用录入列表
  2887. /// </summary>
  2888. /// <param name="dto"></param>
  2889. /// <returns></returns>
  2890. [HttpPost]
  2891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2892. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2893. {
  2894. try
  2895. {
  2896. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2897. if (groupData.Code != 0)
  2898. {
  2899. return Ok(JsonView(false, groupData.Msg));
  2900. }
  2901. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2902. }
  2903. catch (Exception ex)
  2904. {
  2905. return Ok(JsonView(false, ex.Message));
  2906. throw;
  2907. }
  2908. }
  2909. /// <summary>
  2910. /// 根据id查询费用录入信息
  2911. /// </summary>
  2912. /// <param name="dto"></param>
  2913. /// <returns></returns>
  2914. [HttpPost]
  2915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2916. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2917. {
  2918. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2919. if (groupData.Code != 0)
  2920. {
  2921. return Ok(JsonView(false, groupData.Msg));
  2922. }
  2923. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2924. }
  2925. /// <summary>
  2926. /// 机票费用录入操作(Status:1.新增,2.修改)
  2927. /// </summary>
  2928. /// <param name="dto"></param>
  2929. /// <returns></returns>
  2930. [HttpPost]
  2931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2932. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2933. {
  2934. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2935. if (groupData.Code != 0)
  2936. {
  2937. return Ok(JsonView(false, groupData.Msg));
  2938. }
  2939. #region 应用推送
  2940. try
  2941. {
  2942. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2943. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2944. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2945. //2024-10-21 新增LZ UID
  2946. var userIds = new List<int>() { 21 };
  2947. string title = $"系统通知";
  2948. string content = "";
  2949. var diId = dto.AirTicketResOpData.DiId;
  2950. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2951. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2952. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2953. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2954. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2955. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2956. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2957. }
  2958. catch (Exception ex)
  2959. {
  2960. }
  2961. #endregion
  2962. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2963. }
  2964. /// <summary>
  2965. /// 根据舱位类型查询接团客户名单信息
  2966. /// </summary>
  2967. /// <param name="dto"></param>
  2968. /// <returns></returns>
  2969. [HttpPost]
  2970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2971. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2972. {
  2973. try
  2974. {
  2975. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2976. if (crm_Groups.Count != 0)
  2977. {
  2978. List<dynamic> Customer = new List<dynamic>();
  2979. foreach (var item in crm_Groups)
  2980. {
  2981. var data = new
  2982. {
  2983. Id = item.Id,
  2984. Pinyin = item.Pinyin,
  2985. Name = item.LastName + item.FirstName
  2986. };
  2987. Customer.Add(data);
  2988. }
  2989. return Ok(JsonView(true, "查询成功!", Customer));
  2990. }
  2991. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2992. }
  2993. catch (Exception ex)
  2994. {
  2995. return Ok(JsonView(false, "程序错误!"));
  2996. throw;
  2997. }
  2998. }
  2999. /// <summary>
  3000. /// 根据团号获取客户信息
  3001. /// </summary>
  3002. /// <param name="dto"></param>
  3003. /// <returns></returns>
  3004. [HttpPost]
  3005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3006. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  3007. {
  3008. var jw = JsonView(false);
  3009. if (dto.DIID < 1)
  3010. {
  3011. jw.Msg += "请输入正确的diid";
  3012. return Ok(jw);
  3013. }
  3014. var arr = getSimplClientList(dto.DIID);
  3015. jw = JsonView(true, "获取成功!", arr);
  3016. return Ok(jw);
  3017. }
  3018. private List<SimplClientInfo> getSimplClientList(int diId)
  3019. {
  3020. 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);
  3021. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  3022. foreach (var item in arr)
  3023. {
  3024. EncryptionProcessor.DecryptProperties(item);
  3025. }
  3026. return arr;
  3027. }
  3028. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  3029. {
  3030. string result = origin;
  3031. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3032. {
  3033. string[] temparr = origin.Split(',');
  3034. string fistrStr = temparr[0];
  3035. int count = temparr.Count();
  3036. int tempId;
  3037. bool success = int.TryParse(fistrStr, out tempId);
  3038. if (success)
  3039. {
  3040. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3041. if (tempInfo != null)
  3042. {
  3043. if (count > 1)
  3044. {
  3045. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  3046. }
  3047. else
  3048. {
  3049. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  3050. }
  3051. }
  3052. }
  3053. }
  3054. return result;
  3055. }
  3056. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  3057. {
  3058. string result = origin;
  3059. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3060. {
  3061. string[] temparr = origin.Split(',');
  3062. result = "";
  3063. foreach (var item in temparr)
  3064. {
  3065. int tempId;
  3066. bool success = int.TryParse(item, out tempId);
  3067. if (success)
  3068. {
  3069. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3070. if (tempInfo != null)
  3071. {
  3072. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  3073. }
  3074. }
  3075. }
  3076. }
  3077. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  3078. return result;
  3079. }
  3080. /// <summary>
  3081. /// 机票费用录入,删除
  3082. /// </summary>
  3083. /// <param name="dto"></param>
  3084. /// <returns></returns>
  3085. [HttpPost]
  3086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3087. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  3088. {
  3089. try
  3090. {
  3091. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3092. if (res)
  3093. {
  3094. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  3095. {
  3096. IsDel = 1,
  3097. DeleteUserId = dto.DeleteUserId,
  3098. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3099. }).ExecuteCommandAsync();
  3100. return Ok(JsonView(true, "删除成功!"));
  3101. }
  3102. return Ok(JsonView(false, "删除失败!"));
  3103. }
  3104. catch (Exception ex)
  3105. {
  3106. return Ok(JsonView(false, "程序错误!"));
  3107. throw;
  3108. }
  3109. }
  3110. /// <summary>
  3111. /// 导出机票录入报表
  3112. /// </summary>
  3113. /// <param name="dto"></param>
  3114. /// <returns></returns>
  3115. [HttpPost]
  3116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3117. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  3118. {
  3119. try
  3120. {
  3121. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  3122. if (groupData.Code != 0)
  3123. {
  3124. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3125. }
  3126. else
  3127. {
  3128. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  3129. if (AirTicketReservations.Count != 0)
  3130. {
  3131. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  3132. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  3133. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  3134. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  3135. WorkbookDesigner designer = new WorkbookDesigner();
  3136. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  3137. decimal countCost = 0;
  3138. foreach (var item in AirTicketReservations)
  3139. {
  3140. #region 处理客人姓名
  3141. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  3142. item.ClientName = clientNames;
  3143. #endregion
  3144. if (item.BankType == "其他")
  3145. {
  3146. item.BankNo = "--";
  3147. }
  3148. else
  3149. {
  3150. if (!string.IsNullOrEmpty(item.BankType))
  3151. {
  3152. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  3153. }
  3154. }
  3155. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  3156. item.Price = System.Decimal.Round(item.Price, 2);
  3157. countCost += Convert.ToDecimal(item.Price);
  3158. }
  3159. designer.SetDataSource("Export", AirTicketReservations);
  3160. designer.SetDataSource("ExportDiCode", diCode);
  3161. designer.SetDataSource("ExportDiName", diName);
  3162. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  3163. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  3164. designer.Process();
  3165. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  3166. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3167. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3168. return Ok(JsonView(true, "成功", url = rst));
  3169. }
  3170. else
  3171. {
  3172. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  3173. }
  3174. }
  3175. }
  3176. catch (Exception ex)
  3177. {
  3178. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  3179. throw;
  3180. }
  3181. }
  3182. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3183. /// <summary>
  3184. /// 行程单导出
  3185. /// </summary>
  3186. /// <param name="dto"></param>
  3187. /// <returns></returns>
  3188. [HttpPost]
  3189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3190. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  3191. {
  3192. try
  3193. {
  3194. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  3195. if (groupData.Code != 0)
  3196. {
  3197. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3198. }
  3199. else
  3200. {
  3201. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3202. if (dto.Language == "CN")
  3203. {
  3204. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3205. DocumentBuilder builder = new DocumentBuilder(doc);
  3206. int tableIndex = 0;//表格索引
  3207. //得到文档中的第一个表格
  3208. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3209. foreach (var item in _AirTicketReservations)
  3210. {
  3211. #region 处理固定数据
  3212. string[] FlightsCode = item.FlightsCode.Split('/');
  3213. if (FlightsCode.Length != 0)
  3214. {
  3215. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3216. if (_AirCompany != null)
  3217. {
  3218. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3219. }
  3220. else
  3221. {
  3222. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3223. }
  3224. }
  3225. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3226. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3227. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3228. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3229. string name = "";
  3230. foreach (string clientName in nameArray)
  3231. {
  3232. if (!name.Contains(clientName))
  3233. {
  3234. name += clientName + ",";
  3235. }
  3236. }
  3237. if (!string.IsNullOrWhiteSpace(name))
  3238. {
  3239. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3240. }
  3241. else
  3242. {
  3243. table.Range.Bookmarks["ClientName"].Text = "--";
  3244. }
  3245. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3246. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3247. table.Range.Bookmarks["JointTicket"].Text = "--";
  3248. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3249. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3250. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3251. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3252. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3253. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3254. #endregion
  3255. #region 循环数据处理
  3256. List<AirInfo> airs = new List<AirInfo>();
  3257. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3258. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3259. for (int i = 0; i < FlightsCode.Length; i++)
  3260. {
  3261. AirInfo air = new AirInfo();
  3262. string[] tempstr = DayArray[i]
  3263. .Replace("\r\n", string.Empty)
  3264. .Replace("\\r\\n", string.Empty)
  3265. .TrimStart().TrimEnd()
  3266. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3267. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3268. string starCity = "";
  3269. if (star_Three != null)
  3270. {
  3271. starCity = star_Three.AirPort;
  3272. }
  3273. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3274. string EndCity = "";
  3275. if (End_Three != null)
  3276. {
  3277. EndCity = End_Three.AirPort;
  3278. }
  3279. air.Destination = starCity + "/" + EndCity;
  3280. air.Flight = FlightsCode[i];
  3281. air.SeatingClass = item.CTypeName;
  3282. string dateTime = tempstr[2];
  3283. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3284. air.FlightDate = DateTemp;
  3285. air.DepartureTime = tempstr[5];
  3286. air.LandingTime = tempstr[6];
  3287. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3288. air.TicketStatus = "--";
  3289. air.Luggage = "--";
  3290. air.DepartureTerminal = "--";
  3291. air.LandingTerminal = "--";
  3292. airs.Add(air);
  3293. }
  3294. int row = 13;
  3295. for (int i = 0; i < airs.Count; i++)
  3296. {
  3297. if (airs.Count > 2)
  3298. {
  3299. for (int j = 0; j < airs.Count - 2; j++)
  3300. {
  3301. var CopyRow = table.Rows[12].Clone(true);
  3302. table.Rows.Add(CopyRow);
  3303. }
  3304. }
  3305. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3306. int index = 0;
  3307. foreach (PropertyInfo property in properties)
  3308. {
  3309. string value = property.GetValue(airs[i]).ToString();
  3310. Cell ishcel0 = table.Rows[row].Cells[index];
  3311. Paragraph p = new Paragraph(doc);
  3312. string s = value;
  3313. p.AppendChild(new Run(doc, s));
  3314. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3315. ishcel0.AppendChild(p);
  3316. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3317. index++;
  3318. }
  3319. row++;
  3320. }
  3321. #endregion
  3322. Paragraph lastParagraph = new Paragraph(doc);
  3323. //第一个表格末尾加段落
  3324. table.ParentNode.InsertAfter(lastParagraph, table);
  3325. //复制第一个表格
  3326. Table cloneTable = (Table)table.Clone(true);
  3327. //在文档末尾段落后面加入复制的表格
  3328. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3329. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3330. {
  3331. int rownewsIndex = 13;
  3332. for (int i = 0; i < 2; i++)
  3333. {
  3334. var CopyRow = table.Rows[12].Clone(true);
  3335. table.Rows.RemoveAt(13);
  3336. table.Rows.Add(CopyRow);
  3337. rownewsIndex++;
  3338. }
  3339. }
  3340. else
  3341. {
  3342. table.Rows.RemoveAt(12);
  3343. }
  3344. cloneTable.Rows.RemoveAt(12);
  3345. }
  3346. if (_AirTicketReservations.Count != 0)
  3347. {
  3348. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3349. if (FlightsCode.Length != 0)
  3350. {
  3351. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3352. if (_AirCompany != null)
  3353. {
  3354. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3355. }
  3356. else
  3357. {
  3358. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3359. }
  3360. }
  3361. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3362. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3363. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3364. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3365. string name = "";
  3366. foreach (string clientName in nameArray)
  3367. {
  3368. if (!name.Contains(clientName))
  3369. {
  3370. name += clientName + ",";
  3371. }
  3372. }
  3373. if (!string.IsNullOrWhiteSpace(name))
  3374. {
  3375. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3376. }
  3377. else
  3378. {
  3379. table.Range.Bookmarks["ClientName"].Text = "--";
  3380. }
  3381. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3382. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3383. table.Range.Bookmarks["JointTicket"].Text = "--";
  3384. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3385. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3386. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3387. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3388. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3389. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3390. }
  3391. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3392. //保存合并后的文档
  3393. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3394. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3395. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3396. return Ok(JsonView(true, "成功!", rst));
  3397. }
  3398. else
  3399. {
  3400. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3401. DocumentBuilder builder = new DocumentBuilder(doc);
  3402. int tableIndex = 0;//表格索引
  3403. //得到文档中的第一个表格
  3404. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3405. List<string> texts = new List<string>();
  3406. foreach (var item in _AirTicketReservations)
  3407. {
  3408. string[] FlightsCode = item.FlightsCode.Split('/');
  3409. if (FlightsCode.Length != 0)
  3410. {
  3411. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3412. if (_AirCompany != null)
  3413. {
  3414. if (!transDic.ContainsKey(_AirCompany.CnName))
  3415. {
  3416. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3417. }
  3418. }
  3419. else
  3420. {
  3421. if (!transDic.ContainsKey("--"))
  3422. {
  3423. transDic.Add("--", "--");
  3424. }
  3425. }
  3426. }
  3427. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3428. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3429. string name = "";
  3430. foreach (string clientName in nameArray)
  3431. {
  3432. name += clientName + ",";
  3433. }
  3434. if (!texts.Contains(name))
  3435. {
  3436. texts.Add(name);
  3437. }
  3438. List<AirInfo> airs = new List<AirInfo>();
  3439. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3440. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3441. for (int i = 0; i < FlightsCode.Length; i++)
  3442. {
  3443. AirInfo air = new AirInfo();
  3444. string[] tempstr = DayArray[i]
  3445. .Replace("\r\n", string.Empty)
  3446. .Replace("\\r\\n", string.Empty)
  3447. .TrimStart().TrimEnd()
  3448. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3449. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3450. if (star_Three != null)
  3451. {
  3452. if (!transDic.ContainsKey(star_Three.AirPort))
  3453. {
  3454. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3455. }
  3456. }
  3457. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3458. if (End_Three != null)
  3459. {
  3460. if (!transDic.ContainsKey(End_Three.AirPort))
  3461. {
  3462. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3463. }
  3464. }
  3465. if (!texts.Contains(item.CTypeName))
  3466. {
  3467. texts.Add(item.CTypeName);
  3468. }
  3469. }
  3470. }
  3471. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  3472. if (transData.Count > 0)
  3473. {
  3474. foreach (TranslateResult item in transData)
  3475. {
  3476. if (!transDic.ContainsKey(item.Query))
  3477. {
  3478. transDic.Add(item.Query, item.Translation);
  3479. }
  3480. }
  3481. }
  3482. foreach (var item in _AirTicketReservations)
  3483. {
  3484. #region 处理固定数据
  3485. string[] FlightsCode = item.FlightsCode.Split('/');
  3486. if (FlightsCode.Length != 0)
  3487. {
  3488. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3489. if (_AirCompany != null)
  3490. {
  3491. string str = "--";
  3492. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3493. if (!string.IsNullOrEmpty(translateResult))
  3494. {
  3495. str = translateResult;
  3496. str = _airTicketResRep.Processing(str);
  3497. }
  3498. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3499. }
  3500. else
  3501. {
  3502. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3503. }
  3504. }
  3505. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3506. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3507. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3508. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3509. string names = "";
  3510. foreach (string clientName in nameArray)
  3511. {
  3512. names += clientName + ",";
  3513. }
  3514. if (!string.IsNullOrWhiteSpace(names))
  3515. {
  3516. string str = "--";
  3517. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3518. if (!string.IsNullOrEmpty(translateResult))
  3519. {
  3520. str = translateResult;
  3521. str = _airTicketResRep.Processing(str);
  3522. }
  3523. table.Range.Bookmarks["ClientName"].Text = str;
  3524. }
  3525. else
  3526. {
  3527. table.Range.Bookmarks["ClientName"].Text = "--";
  3528. }
  3529. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3530. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3531. table.Range.Bookmarks["JointTicket"].Text = "--";
  3532. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3533. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3534. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3535. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3536. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3537. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3538. #endregion
  3539. #region 循环数据处理
  3540. List<AirInfo> airs = new List<AirInfo>();
  3541. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3542. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3543. for (int i = 0; i < FlightsCode.Length; i++)
  3544. {
  3545. AirInfo air = new AirInfo();
  3546. string[] tempstr = DayArray[i]
  3547. .Replace("\r\n", string.Empty)
  3548. .Replace("\\r\\n", string.Empty)
  3549. .TrimStart().TrimEnd()
  3550. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3551. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3552. string starCity = "";
  3553. if (star_Three != null)
  3554. {
  3555. string str2 = "--";
  3556. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3557. if (!string.IsNullOrEmpty(translateResult2))
  3558. {
  3559. str2 = translateResult2;
  3560. str2 = _airTicketResRep.Processing(str2);
  3561. }
  3562. starCity = str2;
  3563. }
  3564. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3565. string EndCity = "";
  3566. if (End_Three != null)
  3567. {
  3568. string str1 = "--";
  3569. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3570. if (!string.IsNullOrEmpty(translateResult1))
  3571. {
  3572. str1 = translateResult1;
  3573. str1 = _airTicketResRep.Processing(str1);
  3574. }
  3575. EndCity = str1;
  3576. }
  3577. air.Destination = starCity + "/" + EndCity;
  3578. air.Flight = FlightsCode[i];
  3579. string str = "--";
  3580. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3581. if (!string.IsNullOrEmpty(translateResult))
  3582. {
  3583. str = translateResult;
  3584. str = _airTicketResRep.Processing(str);
  3585. }
  3586. air.SeatingClass = str;
  3587. string dateTime = tempstr[2];
  3588. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3589. air.FlightDate = DateTemp;
  3590. air.DepartureTime = tempstr[5];
  3591. air.LandingTime = tempstr[6];
  3592. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3593. air.TicketStatus = "--";
  3594. air.Luggage = "--";
  3595. air.DepartureTerminal = "--";
  3596. air.LandingTerminal = "--";
  3597. airs.Add(air);
  3598. }
  3599. int row = 13;
  3600. for (int i = 0; i < airs.Count; i++)
  3601. {
  3602. if (airs.Count > 2)
  3603. {
  3604. for (int j = 0; j < airs.Count - 2; j++)
  3605. {
  3606. var CopyRow = table.Rows[12].Clone(true);
  3607. table.Rows.Add(CopyRow);
  3608. }
  3609. }
  3610. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3611. int index = 0;
  3612. foreach (PropertyInfo property in properties)
  3613. {
  3614. string value = property.GetValue(airs[i]).ToString();
  3615. Cell ishcel0 = table.Rows[row].Cells[index];
  3616. Paragraph p = new Paragraph(doc);
  3617. string s = value;
  3618. p.AppendChild(new Run(doc, s));
  3619. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3620. ishcel0.AppendChild(p);
  3621. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3622. //ishcel0.CellFormat.VerticalAlignment=
  3623. index++;
  3624. }
  3625. row++;
  3626. }
  3627. #endregion
  3628. Paragraph lastParagraph = new Paragraph(doc);
  3629. //第一个表格末尾加段落
  3630. table.ParentNode.InsertAfter(lastParagraph, table);
  3631. //复制第一个表格
  3632. Table cloneTable = (Table)table.Clone(true);
  3633. //在文档末尾段落后面加入复制的表格
  3634. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3635. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3636. {
  3637. int rownewsIndex = 13;
  3638. for (int i = 0; i < 2; i++)
  3639. {
  3640. var CopyRow = table.Rows[12].Clone(true);
  3641. table.Rows.RemoveAt(13);
  3642. table.Rows.Add(CopyRow);
  3643. rownewsIndex++;
  3644. }
  3645. }
  3646. else
  3647. {
  3648. table.Rows.RemoveAt(12);
  3649. }
  3650. cloneTable.Rows.RemoveAt(12);
  3651. }
  3652. if (_AirTicketReservations.Count != 0)
  3653. {
  3654. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3655. if (FlightsCode.Length != 0)
  3656. {
  3657. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3658. if (_AirCompany != null)
  3659. {
  3660. string str = "--";
  3661. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3662. if (!string.IsNullOrEmpty(translateResult))
  3663. {
  3664. str = translateResult;
  3665. str = _airTicketResRep.Processing(str);
  3666. }
  3667. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3668. }
  3669. else
  3670. {
  3671. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3672. }
  3673. }
  3674. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3675. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3676. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3677. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3678. string names = "";
  3679. foreach (string clientName in nameArray)
  3680. {
  3681. names += clientName + ",";
  3682. }
  3683. if (!string.IsNullOrWhiteSpace(names))
  3684. {
  3685. string str = "--";
  3686. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3687. if (!string.IsNullOrEmpty(translateResult))
  3688. {
  3689. str = translateResult;
  3690. str = _airTicketResRep.Processing(str);
  3691. }
  3692. table.Range.Bookmarks["ClientName"].Text = str;
  3693. }
  3694. else
  3695. {
  3696. table.Range.Bookmarks["ClientName"].Text = "--";
  3697. }
  3698. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3699. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3700. table.Range.Bookmarks["JointTicket"].Text = "--";
  3701. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3702. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3703. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3704. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3705. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3706. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3707. }
  3708. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3709. //保存合并后的文档
  3710. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3711. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3712. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3713. return Ok(JsonView(true, "成功!", rst));
  3714. }
  3715. }
  3716. }
  3717. catch (Exception ex)
  3718. {
  3719. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3720. throw;
  3721. }
  3722. }
  3723. #endregion
  3724. #region 团组增减款项 --> 其他款项
  3725. /// <summary>
  3726. /// 团组增减款项下拉框绑定
  3727. /// </summary>
  3728. /// <param name="dto"></param>
  3729. /// <returns></returns>
  3730. [HttpPost]
  3731. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3732. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3733. {
  3734. #region 参数验证
  3735. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3736. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3737. #endregion
  3738. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3739. }
  3740. /// <summary>
  3741. /// 根据团组Id查询团组增减款项
  3742. /// </summary>
  3743. /// <param name="dto"></param>
  3744. /// <returns></returns>
  3745. [HttpPost]
  3746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3747. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3748. {
  3749. #region 参数验证
  3750. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3751. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3752. #endregion
  3753. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3754. }
  3755. /// <summary>
  3756. /// 团组增减款项操作(Status:1.新增,2.修改)
  3757. /// </summary>
  3758. /// <param name="dto"></param>
  3759. /// <returns></returns>
  3760. [HttpPost]
  3761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3762. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3763. {
  3764. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3765. if (groupData.Code != 200)
  3766. {
  3767. return Ok(JsonView(false, groupData.Msg));
  3768. }
  3769. #region 应用推送
  3770. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3771. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3772. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3773. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  3774. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  3775. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  3776. //自动审核
  3777. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3778. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3779. //2024-10-21 新增LZ UID
  3780. var userIds = new List<int>() { 21 };
  3781. string title = $"系统通知";
  3782. string content = "";
  3783. var diId = dto.DiId;
  3784. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3785. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3786. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3787. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3788. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3789. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3790. #endregion
  3791. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3792. }
  3793. /// <summary>
  3794. /// 团组增减款项操作 删除
  3795. /// </summary>
  3796. /// <param name="dto"></param>
  3797. /// <returns></returns>
  3798. [HttpPost]
  3799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3800. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3801. {
  3802. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3803. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3804. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3805. if (res.Code == 0)
  3806. {
  3807. return Ok(JsonView(true, "删除成功!"));
  3808. }
  3809. return Ok(JsonView(false, "删除失败!"));
  3810. }
  3811. /// <summary>
  3812. /// 根据团组增减款项Id查询
  3813. /// </summary>
  3814. /// <param name="dto"></param>
  3815. /// <returns></returns>
  3816. [HttpPost]
  3817. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3818. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3819. {
  3820. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3821. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3822. }
  3823. /// <summary>
  3824. /// 查询供应商名称
  3825. /// </summary>
  3826. /// <param name="dto"></param>
  3827. /// <returns></returns>
  3828. [HttpPost]
  3829. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3830. {
  3831. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3832. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3833. ?? new List<Grp_DecreasePayments>();
  3834. dbResult = dbResult.Distinct(new
  3835. ProductComparer()).ToList();
  3836. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3837. {
  3838. x.Id,
  3839. x.SupplierAddress,
  3840. x.SupplierArea,
  3841. x.SupplierContact,
  3842. x.SupplierContactNumber,
  3843. x.SupplierEmail,
  3844. x.SupplierName,
  3845. x.SupplierSocialAccount,
  3846. x.SupplierTypeId,
  3847. }).ToList());
  3848. return Ok(jw);
  3849. }
  3850. /// <summary>
  3851. /// 团组增减款项 OTA匹配
  3852. /// </summary>
  3853. /// <param name="file"></param>
  3854. /// <returns></returns>
  3855. [HttpPost]
  3856. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3857. {
  3858. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3859. string fileName = file.FileName;
  3860. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3861. {
  3862. return Ok(JsonView(false, "请上传Excel文件!"));
  3863. }
  3864. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3865. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3866. if (!Directory.Exists(path))
  3867. {
  3868. Directory.CreateDirectory(path);
  3869. }
  3870. var filePath = @$"{path}/{fileName}";
  3871. //保存文件
  3872. using (FileStream fs = System.IO.File.Create(filePath))
  3873. {
  3874. file.CopyTo(fs);
  3875. fs.Flush();
  3876. }
  3877. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3878. //读取ExcelFile
  3879. DataTable dt = ConvertExcelToDataTable(filePath);
  3880. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3881. dt.TableName = "TB";
  3882. //修改table列名
  3883. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3884. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3885. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3886. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3887. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3888. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3889. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3890. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3891. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3892. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3893. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3894. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3895. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3896. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3897. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3898. var otaOrderNos = new List<string>();
  3899. foreach (DataRow item in dt.Rows)
  3900. {
  3901. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3902. }
  3903. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3904. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3905. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3906. .Select((dp, di) => new
  3907. {
  3908. dp.PriceName,
  3909. dp.OTAOrderNo,
  3910. dp.FeeTotal,
  3911. di.TeamName,
  3912. })
  3913. .ToListAsync();
  3914. foreach (DataRow item in dt.Rows)
  3915. {
  3916. var otaOrderNo = item["OTAOrderNo"].ToString();
  3917. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3918. if (oaData == null) continue;
  3919. item["GroupName"] = oaData.TeamName;
  3920. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3921. }
  3922. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3923. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3924. List<DataTable> datas = new List<DataTable>();
  3925. datas.Add(dt);
  3926. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3927. return Ok(JsonView(true, "操作成功", new { url = url }));
  3928. }
  3929. #region
  3930. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3931. {
  3932. // 创建Workbook对象
  3933. Workbook workbook = new Workbook(excelFilePath);
  3934. // 获取第一个工作表
  3935. Worksheet worksheet = workbook.Worksheets[0];
  3936. // 将工作表转换为DataTable
  3937. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3938. return dataTable;
  3939. }
  3940. #endregion
  3941. #endregion
  3942. #region 文件上传、删除
  3943. /// <summary>
  3944. /// region 文件上传 可以带参数
  3945. /// </summary>
  3946. /// <param name="file"></param>
  3947. /// <returns></returns>
  3948. [HttpPost]
  3949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3950. public async Task<IActionResult> UploadProject(IFormFile file)
  3951. {
  3952. //var TypeName = Request.Headers["TypeName"].ToString();
  3953. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3954. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3955. ////文件名称
  3956. //string projectFileName = file.FileName;
  3957. ////上传的文件的路径
  3958. //string filePath = $"{fileDir}/{projectFileName}";
  3959. //if (TypeName == "A")//A代表团组增减款项
  3960. //{
  3961. // filePath = fileDir + $@"\团组增减款项相关文件";
  3962. // if (!Directory.Exists(filePath))
  3963. // {
  3964. // Directory.CreateDirectory(filePath);
  3965. // }
  3966. // //上传的文件的路径
  3967. // filePath += $@"\{projectFileName}";
  3968. //}
  3969. //else if (TypeName == "B")//B代表商邀相关文件
  3970. //{
  3971. // //上传的文件的路径
  3972. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3973. // if (!Directory.Exists(filePath))
  3974. // {
  3975. // Directory.CreateDirectory(filePath);
  3976. // }
  3977. // //上传的文件的路径
  3978. // filePath = $@"\{projectFileName}";
  3979. //}
  3980. //try
  3981. //{
  3982. // using (FileStream fs = System.IO.File.Create(filePath))
  3983. // {
  3984. // file.CopyTo(fs);
  3985. // fs.Flush();
  3986. // }
  3987. //}
  3988. //catch (Exception ex)
  3989. //{
  3990. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3991. //}
  3992. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3993. try
  3994. {
  3995. var TypeName = Request.Headers["TypeName"].ToString();
  3996. if (file != null)
  3997. {
  3998. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3999. //文件名称
  4000. string projectFileName = file.FileName;
  4001. //上传的文件的路径
  4002. string filePath = $"{fileDir}/{projectFileName}";
  4003. if (TypeName == "A")//A代表团组增减款项
  4004. {
  4005. if (!Directory.Exists(fileDir))
  4006. {
  4007. Directory.CreateDirectory(fileDir);
  4008. }
  4009. //上传的文件的路径
  4010. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4011. }
  4012. else if (TypeName == "B")//B代表商邀相关文件
  4013. {
  4014. if (!Directory.Exists(fileDir))
  4015. {
  4016. Directory.CreateDirectory(fileDir);
  4017. }
  4018. //上传的文件的路径
  4019. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4020. }
  4021. using (FileStream fs = System.IO.File.Create(filePath))
  4022. {
  4023. file.CopyTo(fs);
  4024. fs.Flush();
  4025. }
  4026. return Ok(JsonView(true, "上传成功!", projectFileName));
  4027. }
  4028. else
  4029. {
  4030. return Ok(JsonView(false, "上传失败!"));
  4031. }
  4032. }
  4033. catch (Exception ex)
  4034. {
  4035. return Ok(JsonView(false, "程序错误!"));
  4036. }
  4037. }
  4038. /// <summary>
  4039. /// 删除指定文件
  4040. /// </summary>
  4041. /// <param name="dto"></param>
  4042. /// <returns></returns>
  4043. [HttpPost]
  4044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4045. public async Task<IActionResult> DelFile(DelFileDto dto)
  4046. {
  4047. try
  4048. {
  4049. var TypeName = Request.Headers["TypeName"].ToString();
  4050. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4051. string filePath = "";
  4052. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4053. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4054. int id = 0;
  4055. if (TypeName == "A")
  4056. {
  4057. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  4058. // 删除该文件
  4059. System.IO.File.Delete(filePath);
  4060. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  4061. .Where(a => a.Id == dto.Id)
  4062. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  4063. .ExecuteCommandAsync();
  4064. }
  4065. else if (TypeName == "B")
  4066. {
  4067. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  4068. // 删除该文件
  4069. System.IO.File.Delete(filePath);
  4070. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  4071. if (info != null)
  4072. {
  4073. string[] files = new string[] { };
  4074. if (!string.IsNullOrEmpty(info.Attachment))
  4075. {
  4076. try
  4077. {
  4078. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  4079. }
  4080. catch (Exception)
  4081. {
  4082. files = new List<string>() { info.Attachment }.ToArray();
  4083. }
  4084. }
  4085. if (files.Length > 0)
  4086. {
  4087. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  4088. string filePath2 = string.Empty;
  4089. if (files1.Length > 0)
  4090. {
  4091. filePath2 = JsonConvert.SerializeObject(files1);
  4092. }
  4093. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4094. .Where(a => a.Id == dto.Id)
  4095. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  4096. .ExecuteCommandAsync();
  4097. }
  4098. }
  4099. }
  4100. if (id != 0)
  4101. {
  4102. return Ok(JsonView(true, "成功!"));
  4103. }
  4104. else
  4105. {
  4106. return Ok(JsonView(false, "失败!"));
  4107. }
  4108. }
  4109. catch (Exception ex)
  4110. {
  4111. return Ok(JsonView(false, "程序错误!"));
  4112. throw;
  4113. }
  4114. }
  4115. /// <summary>
  4116. /// 文件上传多个文件 可以带参数
  4117. /// </summary>
  4118. /// <param name="files"></param>
  4119. /// <returns></returns>
  4120. [HttpPost]
  4121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4122. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  4123. {
  4124. try
  4125. {
  4126. var TypeName = Request.Headers["TypeName"].ToString();
  4127. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4128. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  4129. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4130. var filePahts = new List<string>();
  4131. foreach (var file in files)
  4132. {
  4133. //文件名称
  4134. string projectFileName = file.FileName;
  4135. //上传的文件的路径
  4136. string filePath = $"{fileDir}/{projectFileName}";
  4137. if (TypeName == "A")//A代表团组增减款项
  4138. {
  4139. if (!Directory.Exists(fileDir))
  4140. {
  4141. Directory.CreateDirectory(fileDir);
  4142. }
  4143. //上传的文件的路径
  4144. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4145. }
  4146. else if (TypeName == "B")//B代表商邀相关文件
  4147. {
  4148. if (!Directory.Exists(fileDir))
  4149. {
  4150. Directory.CreateDirectory(fileDir);
  4151. }
  4152. //上传的文件的路径
  4153. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4154. }
  4155. using (FileStream fs = System.IO.File.Create(filePath))
  4156. {
  4157. file.CopyTo(fs);
  4158. fs.Flush();
  4159. }
  4160. filePahts.Add(projectFileName);
  4161. }
  4162. return Ok(JsonView(true, "上传成功!", filePahts));
  4163. }
  4164. catch (Exception ex)
  4165. {
  4166. return Ok(JsonView(false, "程序错误!"));
  4167. }
  4168. }
  4169. #endregion
  4170. #region 商邀费用录入
  4171. /// <summary>
  4172. /// 根据团组Id查询商邀费用列表
  4173. /// </summary>
  4174. /// <param name="dto"></param>
  4175. /// <returns></returns>
  4176. [HttpPost]
  4177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4178. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  4179. {
  4180. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  4181. if (groupData.Code != 0)
  4182. {
  4183. return Ok(JsonView(false, groupData.Msg));
  4184. }
  4185. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4186. }
  4187. /// <summary>
  4188. /// 商邀费用列表
  4189. /// 下载文件
  4190. /// </summary>
  4191. /// <param name="id"></param>
  4192. /// <returns></returns>
  4193. [HttpGet("{id}")]
  4194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4195. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  4196. {
  4197. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4198. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4199. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4200. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4201. var filePaths = new List<string>();
  4202. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4203. try
  4204. {
  4205. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4206. }
  4207. catch (Exception ex)
  4208. {
  4209. filePaths.Add(info.Attachment);
  4210. }
  4211. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4212. for (int i = 0; i < filePaths.Count; i++)
  4213. {
  4214. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4215. }
  4216. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4217. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4218. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4219. {
  4220. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4221. {
  4222. foreach (string filePath in filePaths)
  4223. {
  4224. if (System.IO.File.Exists(filePath))
  4225. {
  4226. // 获取文件名
  4227. string fileName = Path.GetFileName(filePath);
  4228. // 将文件添加到ZIP归档中
  4229. zipArchive.CreateEntryFromFile(filePath, fileName);
  4230. }
  4231. }
  4232. }
  4233. }
  4234. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4235. }
  4236. /// <summary>
  4237. /// 商邀费用 Info Page 基础数据源
  4238. /// </summary>
  4239. /// <returns></returns>
  4240. [HttpPost]
  4241. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4242. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4243. {
  4244. try
  4245. {
  4246. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4247. if (groupData.Code != 0)
  4248. {
  4249. return Ok(JsonView(false, groupData.Msg));
  4250. }
  4251. return Ok(JsonView(true, "操作成功", groupData.Data));
  4252. }
  4253. catch (Exception ex)
  4254. {
  4255. return Ok(JsonView(false, ex.Message));
  4256. throw;
  4257. }
  4258. }
  4259. /// <summary>
  4260. /// 根据商邀费用ID查询C表和商邀费用数据
  4261. /// </summary>
  4262. /// <param name="dto"></param>
  4263. /// <returns></returns>
  4264. [HttpPost]
  4265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4266. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4267. {
  4268. try
  4269. {
  4270. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4271. if (groupData.Code != 0)
  4272. {
  4273. return Ok(JsonView(false, groupData.Msg));
  4274. }
  4275. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4276. }
  4277. catch (Exception ex)
  4278. {
  4279. return Ok(JsonView(false, ex.Message));
  4280. throw;
  4281. }
  4282. }
  4283. /// <summary>
  4284. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4285. /// </summary>
  4286. /// <param name="dto"></param>
  4287. /// <returns></returns>
  4288. [HttpPost]
  4289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4290. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4291. {
  4292. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4293. if (groupData.Code != 0)
  4294. {
  4295. return Ok(JsonView(false, groupData.Msg));
  4296. }
  4297. #region 应用推送
  4298. try
  4299. {
  4300. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4301. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4302. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4303. //2024-10-21 新增LZ UID
  4304. var userIds = new List<int>() { 21 };
  4305. string title = $"系统通知";
  4306. string content = "";
  4307. var diId = dto.DiId;
  4308. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4309. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4310. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4311. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4312. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4313. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4314. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4315. }
  4316. catch (Exception ex)
  4317. {
  4318. }
  4319. #endregion
  4320. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4321. }
  4322. /// <summary>
  4323. /// 商邀删除
  4324. /// </summary>
  4325. /// <param name="dto"></param>
  4326. /// <returns></returns>
  4327. [HttpPost]
  4328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4329. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4330. {
  4331. try
  4332. {
  4333. _sqlSugar.BeginTran();
  4334. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4335. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4336. {
  4337. IsDel = 1,
  4338. DeleteUserId = dto.DeleteUserId,
  4339. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4340. })
  4341. .Where(it => it.Id == dto.Id)
  4342. .ExecuteCommand();
  4343. if (res1 > 0)
  4344. {
  4345. int _diId = 0;
  4346. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4347. if (_ioaInfo != null)
  4348. {
  4349. _diId = _ioaInfo.DiId;
  4350. }
  4351. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4352. .SetColumns(a => new Grp_CreditCardPayment()
  4353. {
  4354. IsDel = 1,
  4355. DeleteUserId = dto.DeleteUserId,
  4356. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4357. })
  4358. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4359. .ExecuteCommand();
  4360. if (res2 > 0)
  4361. {
  4362. _sqlSugar.CommitTran();
  4363. return Ok(JsonView(true, "删除成功!"));
  4364. }
  4365. }
  4366. _sqlSugar.RollbackTran();
  4367. return Ok(JsonView(false, "删除失败"));
  4368. }
  4369. catch (Exception ex)
  4370. {
  4371. _sqlSugar.RollbackTran();
  4372. return Ok(JsonView(false, ex.Message));
  4373. }
  4374. }
  4375. #endregion
  4376. #region 票据上传
  4377. /// <summary>
  4378. /// 团组模块文件上传
  4379. /// </summary>
  4380. /// <param name="dto"></param>
  4381. /// <returns></returns>
  4382. [HttpPost]
  4383. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4384. {
  4385. var jw = JsonView(false);
  4386. long M = 1024 * 1024;
  4387. if (dto.Files == null || dto.Files.Count == 0)
  4388. {
  4389. jw.Msg = "无文件信息!";
  4390. return Ok(jw);
  4391. }
  4392. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4393. {
  4394. jw.Msg = "文件大小超过20M!";
  4395. return Ok(jw);
  4396. }
  4397. //var nameSp = dto.File.FileName.Split(".");
  4398. //if (nameSp.Length < 2)
  4399. //{
  4400. // jw.Msg = "拓展名称有误!";
  4401. // return Ok(jw);
  4402. //}
  4403. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4404. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4405. //{
  4406. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4407. // return Ok(jw);
  4408. //}
  4409. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4410. if (Ctable == null)
  4411. {
  4412. jw.Msg = "Ctable指向有误!";
  4413. return Ok(jw);
  4414. }
  4415. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4416. if (groupInfo == null)
  4417. {
  4418. jw.Msg = "团组信息不存在!";
  4419. return Ok(jw);
  4420. }
  4421. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4422. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4423. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4424. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4425. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4426. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4427. try
  4428. {
  4429. if (!Directory.Exists(fileBase))
  4430. {
  4431. Directory.CreateDirectory(fileBase);
  4432. }
  4433. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4434. foreach (var fileStream in dto.Files)
  4435. {
  4436. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4437. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4438. {
  4439. Cid = dto.Cid,
  4440. CreateTime = DateTime.Now,
  4441. CreateUserId = dto.Userid,
  4442. Ctable = dto.Ctable,
  4443. Diid = dto.Diid,
  4444. IsDel = 0,
  4445. FilePath = saveFilePath,
  4446. FileName = fileStream.FileName
  4447. };
  4448. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4449. {
  4450. fileStream.CopyTo(fs);
  4451. fs.Flush();
  4452. }
  4453. saveArr.Add(file);
  4454. }
  4455. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4456. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4457. jw = JsonView(true, "保存成功!", new
  4458. {
  4459. count = addResult,
  4460. filesName = saveArr.Select(x => x.FileName)
  4461. });
  4462. }
  4463. catch (Exception ex)
  4464. {
  4465. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4466. {
  4467. count = 0,
  4468. filesName = new string[0],
  4469. });
  4470. }
  4471. return Ok(jw);
  4472. }
  4473. /// <summary>
  4474. /// 查询各模块已保存文件
  4475. /// </summary>
  4476. /// <param name="dto"></param>
  4477. /// <returns></returns>
  4478. [HttpPost]
  4479. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4480. {
  4481. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4482. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4483. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4484. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4485. {
  4486. expression = Expressionable.Create<Grp_GroupModelFile>()
  4487. .And(x => visaIds.Contains(x.CreateUserId));
  4488. }
  4489. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4490. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4491. .Where(expression.ToExpression())
  4492. .ToList();
  4493. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4494. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4495. {
  4496. x.FileName,
  4497. x.Id,
  4498. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4499. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4500. })));
  4501. }
  4502. /// <summary>
  4503. /// 下载该团组下的所有文件
  4504. /// </summary>
  4505. /// <param name="dto"></param>
  4506. /// <returns></returns>
  4507. [HttpPost]
  4508. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4509. {
  4510. var jw = JsonView(false);
  4511. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4512. if (groupInfo == null)
  4513. {
  4514. jw.Msg = "团组信息不存在!";
  4515. return Ok(jw);
  4516. }
  4517. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4518. var isModule = Convert.ToBoolean(dto.isModule);
  4519. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4520. IOOperatorHelper io = new IOOperatorHelper();
  4521. if (isModule)
  4522. {
  4523. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4524. foreach (var moduleArr in moduleGroup)
  4525. {
  4526. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4527. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4528. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4529. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4530. foreach (var item in moduleArr)
  4531. {
  4532. if (System.IO.File.Exists(item.FilePath))
  4533. {
  4534. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4535. {
  4536. byte[] bytes = new byte[fileStream.Length];
  4537. fileStream.Read(bytes, 0, bytes.Length);
  4538. fileStream.Close();
  4539. Stream stream = new MemoryStream(bytes);
  4540. chiZips.Add(item.FileName, stream);
  4541. }
  4542. }
  4543. }
  4544. if (chiZips.Count > 0)
  4545. {
  4546. var byts = io.ConvertZipStream(chiZips);
  4547. Stream stream = new MemoryStream(byts);
  4548. Zips.Add(key.Name + "_.zip", stream);
  4549. }
  4550. }
  4551. }
  4552. else
  4553. {
  4554. foreach (var item in dbQuery)
  4555. {
  4556. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4557. {
  4558. byte[] bytes = new byte[fileStream.Length];
  4559. fileStream.Read(bytes, 0, bytes.Length);
  4560. fileStream.Close();
  4561. Stream stream = new MemoryStream(bytes);
  4562. while (Zips.Keys.Contains(item.FileName))
  4563. {
  4564. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4565. }
  4566. Zips.Add(item.FileName, stream);
  4567. }
  4568. }
  4569. }
  4570. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4571. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4572. if (Zips.Count > 0)
  4573. {
  4574. var byts = io.ConvertZipStream(Zips);
  4575. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4576. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4577. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4578. }
  4579. else
  4580. {
  4581. jw.Msg = "暂无生成文件!";
  4582. }
  4583. return Ok(jw);
  4584. }
  4585. /// <summary>
  4586. /// 下载该团组下此模块的所有文件
  4587. /// </summary>
  4588. /// <param name="dto"></param>
  4589. /// <returns></returns>
  4590. [HttpPost]
  4591. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4592. {
  4593. var jw = JsonView(false);
  4594. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4595. if (groupInfo == null)
  4596. {
  4597. jw.Msg = "团组信息不存在!";
  4598. return Ok(jw);
  4599. }
  4600. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4601. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4602. && x.IsDel == 0);
  4603. if (key == null)
  4604. {
  4605. jw.Msg = "Ctable指向错误!";
  4606. return Ok(jw);
  4607. }
  4608. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4609. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4610. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4611. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4612. IOOperatorHelper io = new IOOperatorHelper();
  4613. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4614. foreach (var item in dbQuery)
  4615. {
  4616. if (System.IO.File.Exists(item.FilePath))
  4617. {
  4618. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4619. {
  4620. byte[] bytes = new byte[fileStream.Length];
  4621. fileStream.Read(bytes, 0, bytes.Length);
  4622. fileStream.Close();
  4623. Stream stream = new MemoryStream(bytes);
  4624. while (Zips.Keys.Contains(item.FileName))
  4625. {
  4626. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4627. }
  4628. Zips.Add(item.FileName, stream);
  4629. }
  4630. }
  4631. }
  4632. if (Zips.Count > 0)
  4633. {
  4634. var byts = io.ConvertZipStream(Zips);
  4635. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4636. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4637. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4638. }
  4639. else
  4640. {
  4641. jw.Msg = "暂无生成文件!";
  4642. }
  4643. return Ok(jw);
  4644. }
  4645. /// <summary>
  4646. /// 删除该团组下的指定文件
  4647. /// </summary>
  4648. /// <param name="dto"></param>
  4649. /// <returns></returns>
  4650. [HttpPost]
  4651. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4652. {
  4653. var jw = JsonView(false);
  4654. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4655. if (sing == null)
  4656. {
  4657. jw.Msg = "暂无";
  4658. return Ok(jw);
  4659. }
  4660. if (System.IO.File.Exists(sing.FilePath))
  4661. {
  4662. try
  4663. {
  4664. System.IO.File.Delete(sing.FilePath);
  4665. }
  4666. catch (Exception ex)
  4667. {
  4668. jw.Msg = "删除失败!" + ex.Message;
  4669. return Ok(jw);
  4670. }
  4671. }
  4672. sing.IsDel = 1;
  4673. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4674. sing.DeleteUserId = dto.UserId;
  4675. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4676. jw = JsonView(true, "删除成功!");
  4677. return Ok(jw);
  4678. }
  4679. #endregion
  4680. #region 共享文件上传
  4681. /// <summary>
  4682. /// 共享文件数据初始化
  4683. /// </summary>
  4684. /// <returns></returns>
  4685. [HttpGet]
  4686. public IActionResult SharedFileInit(int userid ,int portType)
  4687. {
  4688. var marketingDepartmentIds = new List<int> { 6, 26 , 27 , 28 };
  4689. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  4690. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  4691. .Select(x => x.Id)
  4692. .ToList()
  4693. .Contains(userid);
  4694. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  4695. .Where(x => x.STid == 111 && x.IsDel == 0)
  4696. .Select(x => new
  4697. {
  4698. x.Name,
  4699. x.Id,
  4700. }).ToList();
  4701. if (isMarketingDepartment)
  4702. {
  4703. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  4704. }
  4705. if (portType == 1)
  4706. {
  4707. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  4708. .Where(x => x.IsDel == 0)
  4709. .Select(x => new
  4710. {
  4711. x.TeamName,
  4712. x.Id,
  4713. }).ToList();
  4714. return Ok(JsonView(true, "SUCCESS!", new
  4715. {
  4716. dropDownType,
  4717. dropDownGroupList,
  4718. isMarketingDepartment
  4719. }));
  4720. }
  4721. else if (portType == 2 || portType == 3)
  4722. {
  4723. return Ok(JsonView(true, "SUCCESS!", new
  4724. {
  4725. dropDownType,
  4726. isMarketingDepartment
  4727. }));
  4728. }
  4729. else
  4730. {
  4731. return Ok(JsonView(false, "portType有误!"));
  4732. }
  4733. }
  4734. /// <summary>
  4735. /// 共享文件上传
  4736. /// </summary>
  4737. /// <param name="dto"></param>
  4738. /// <returns></returns>
  4739. [HttpPost]
  4740. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  4741. {
  4742. var isGroup = new List<int> { 1412 };
  4743. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  4744. {
  4745. return Ok(JsonView(false, "该文件需要关联团组!"));
  4746. }
  4747. if (dto.Files == null || dto.Files.Count == 0)
  4748. {
  4749. return Ok(JsonView(false, "无文件信息!"));
  4750. }
  4751. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  4752. {
  4753. return Ok(JsonView(false, "文件大小超过20M!"));
  4754. }
  4755. if (dto.Userid < 1)
  4756. {
  4757. return Ok(JsonView(false, "请传入有效的Userid!"));
  4758. }
  4759. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  4760. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  4761. .Select((u, j) => new
  4762. {
  4763. u.CnName,
  4764. UserId = u.Id,
  4765. j.JobName,
  4766. })
  4767. .First();
  4768. if (jobInfo == null)
  4769. {
  4770. return Ok(JsonView(false, "请传入有效的Userid!"));
  4771. }
  4772. List<string> commonFileExtensions = new List<string>
  4773. {
  4774. // 文本文件
  4775. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  4776. // 图片文件
  4777. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  4778. // 视频文件
  4779. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  4780. // 音频文件
  4781. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  4782. // 压缩文件
  4783. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  4784. // 数据文件
  4785. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  4786. };
  4787. try
  4788. {
  4789. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  4790. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  4791. commonFileExtensions.AddRange(settingExtend);
  4792. }
  4793. catch (Exception)
  4794. { }
  4795. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  4796. if (setdata == null)
  4797. {
  4798. return Ok(JsonView(false, "请传入有效的FileType!"));
  4799. }
  4800. List<Grp_GroupShareFile> insertList = new List<Grp_GroupShareFile>();
  4801. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  4802. if (!Directory.Exists(winPath))
  4803. {
  4804. Directory.CreateDirectory(winPath);
  4805. }
  4806. foreach (var item in dto.Files)
  4807. {
  4808. var houzui = Path.GetExtension(item.FileName);
  4809. if (!commonFileExtensions.Contains(houzui))
  4810. {
  4811. return Ok(JsonView(false, "未知后缀名称!"));
  4812. }
  4813. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  4814. var saveFilePath = winPath + fileName;
  4815. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4816. {
  4817. item.CopyTo(fs);
  4818. fs.Flush();
  4819. }
  4820. var fileDetail = new Grp_GroupShareFile()
  4821. {
  4822. CreateUserId = dto.Userid,
  4823. CreateTime = DateTime.Now,
  4824. UploadJob = jobInfo.JobName,
  4825. FileName = fileName,
  4826. FileType = dto.FileType,
  4827. Diid = dto.Diid,
  4828. FilePath = winPath + fileName,
  4829. };
  4830. insertList.Add(fileDetail);
  4831. }
  4832. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  4833. return Ok(JsonView(true, "保存成功!"));
  4834. }
  4835. /// <summary>
  4836. /// 查询共享文件列表
  4837. /// </summary>
  4838. /// <param name="dto"></param>
  4839. /// <returns></returns>
  4840. [HttpPost]
  4841. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  4842. {
  4843. var isGroup = new List<int> { 1412 };
  4844. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  4845. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  4846. .And(x => x.Diid == dto.Diid)
  4847. .And(x => x.FileType == dto.FileType)
  4848. .And(x => x.IsDel == 0)
  4849. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  4850. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  4851. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  4852. int totalCount = 0;
  4853. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  4854. .Where(queryExpression.ToExpression())
  4855. .OrderBy(x => x.UploadJob)
  4856. .Select(x => new
  4857. {
  4858. x.Id,
  4859. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  4860. x.FileName,
  4861. x.FileType,
  4862. x.CreateTime,
  4863. })
  4864. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  4865. return Ok(JsonView(true, "SUCCESS!", new
  4866. {
  4867. FileList = dbQuery,
  4868. dto.PageSize,
  4869. dto.PageIndex,
  4870. totalCount
  4871. }));
  4872. }
  4873. /// <summary>
  4874. /// 删除共享文件模块下的指定文件
  4875. /// </summary>
  4876. /// <param name="dto"></param>
  4877. /// <returns></returns>
  4878. [HttpPost]
  4879. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  4880. {
  4881. var jw = JsonView(false);
  4882. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4883. if (sing == null)
  4884. {
  4885. jw.Msg = "暂无文件信息!";
  4886. return Ok(jw);
  4887. }
  4888. if (sing.CreateUserId != dto.UserId)
  4889. {
  4890. jw.Msg = "只能删除自己上传的文件!";
  4891. return Ok(jw);
  4892. }
  4893. if (System.IO.File.Exists(sing.FilePath))
  4894. {
  4895. try
  4896. {
  4897. System.IO.File.Delete(sing.FilePath);
  4898. }
  4899. catch (Exception ex)
  4900. {
  4901. jw.Msg = "删除失败!" + ex.Message;
  4902. return Ok(jw);
  4903. }
  4904. }
  4905. sing.IsDel = 1;
  4906. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4907. sing.DeleteUserId = dto.UserId;
  4908. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  4909. jw = JsonView(true, "删除成功!");
  4910. return Ok(jw);
  4911. }
  4912. #endregion
  4913. #region 团组英文资料
  4914. /// <summary>
  4915. /// 查询团组英文所有资料
  4916. /// </summary>
  4917. /// <param name="dto"></param>
  4918. /// <returns></returns>
  4919. [HttpPost]
  4920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4921. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4922. {
  4923. try
  4924. {
  4925. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4926. if (groupData.Code != 0)
  4927. {
  4928. return Ok(JsonView(false, groupData.Msg));
  4929. }
  4930. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4931. }
  4932. catch (Exception ex)
  4933. {
  4934. return Ok(JsonView(false, "程序错误!"));
  4935. throw;
  4936. }
  4937. }
  4938. /// <summary>
  4939. /// 团组英文资料操作(Status:1.新增,2.修改)
  4940. /// </summary>
  4941. /// <param name="dto"></param>
  4942. /// <returns></returns>
  4943. [HttpPost]
  4944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4945. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4946. {
  4947. try
  4948. {
  4949. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4950. if (groupData.Code != 0)
  4951. {
  4952. return Ok(JsonView(false, groupData.Msg));
  4953. }
  4954. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4955. }
  4956. catch (Exception ex)
  4957. {
  4958. return Ok(JsonView(false, "程序错误!"));
  4959. throw;
  4960. }
  4961. }
  4962. /// <summary>
  4963. /// 团组英文资料Id查询数据
  4964. /// </summary>
  4965. /// <param name="dto"></param>
  4966. /// <returns></returns>
  4967. [HttpPost]
  4968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4969. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4970. {
  4971. try
  4972. {
  4973. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4974. if (_DelegationEnData != null)
  4975. {
  4976. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4977. }
  4978. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4979. }
  4980. catch (Exception ex)
  4981. {
  4982. return Ok(JsonView(false, "程序错误!"));
  4983. throw;
  4984. }
  4985. }
  4986. /// <summary>
  4987. /// 团组英文资料删除
  4988. /// </summary>
  4989. /// <param name="dto"></param>
  4990. /// <returns></returns>
  4991. [HttpPost]
  4992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4993. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4994. {
  4995. try
  4996. {
  4997. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4998. if (!res)
  4999. {
  5000. return Ok(JsonView(false, "删除失败"));
  5001. }
  5002. return Ok(JsonView(true, "删除成功!"));
  5003. }
  5004. catch (Exception ex)
  5005. {
  5006. return Ok(JsonView(false, "程序错误!"));
  5007. throw;
  5008. }
  5009. }
  5010. #endregion
  5011. #region 导出邀请函
  5012. /// <summary>
  5013. /// 导出邀请函页面初始化
  5014. /// </summary>
  5015. /// <param name="dto"></param>
  5016. /// <returns></returns>
  5017. [HttpPost]
  5018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5019. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  5020. {
  5021. try
  5022. {
  5023. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  5024. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  5025. if (dto.DiId == 0)
  5026. {
  5027. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  5028. }
  5029. else
  5030. {
  5031. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  5032. }
  5033. return Ok(JsonView(true, "查询成功!", new
  5034. {
  5035. deleClient = crm_Deles,
  5036. delegations = grp_Delegations
  5037. }));
  5038. }
  5039. catch (Exception ex)
  5040. {
  5041. return Ok(JsonView(false, "程序错误!"));
  5042. throw;
  5043. }
  5044. }
  5045. /// <summary>
  5046. /// 导出邀请函
  5047. /// </summary>
  5048. /// <param name="dto"></param>
  5049. /// <returns></returns>
  5050. [HttpPost]
  5051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5052. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  5053. {
  5054. #region 参数验证
  5055. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5056. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5057. #endregion
  5058. try
  5059. {
  5060. Dictionary<string, string> transDic = new Dictionary<string, string>();
  5061. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  5062. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  5063. From Grp_TourClientList tcl
  5064. Left Join
  5065. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  5066. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  5067. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  5068. From Crm_DeleClient dc
  5069. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  5070. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  5071. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  5072. Where dc.IsDel = 0) temp
  5073. On temp.DcId =tcl.ClientId
  5074. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  5075. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  5076. List<string> texts = new List<string>();
  5077. if (datas.Count != 0)
  5078. {
  5079. foreach (TourClientListDetailsView item in datas)
  5080. {
  5081. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  5082. {
  5083. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  5084. }
  5085. else
  5086. {
  5087. string name = item.LastName + item.FirstName;
  5088. texts.Add(name);
  5089. }
  5090. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  5091. {
  5092. if (!transDic.ContainsKey(item.Job))
  5093. {
  5094. texts.Add(item.Job);
  5095. }
  5096. }
  5097. if (!string.IsNullOrEmpty(item.CompanyFullName))
  5098. {
  5099. texts.Add(item.CompanyFullName);
  5100. }
  5101. }
  5102. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  5103. if (transData.Count > 0)
  5104. {
  5105. foreach (TranslateResult item in transData)
  5106. {
  5107. if (!transDic.ContainsKey(item.Query))
  5108. {
  5109. transDic.Add(item.Query, item.Translation);
  5110. }
  5111. }
  5112. }
  5113. List<GuestList> list = new List<GuestList>();
  5114. foreach (TourClientListDetailsView dele in datas)
  5115. {
  5116. GuestList guestList = new GuestList();
  5117. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  5118. {
  5119. guestList.Name = dele.Pinyin;
  5120. }
  5121. else
  5122. {
  5123. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  5124. guestList.Name = Name;
  5125. }
  5126. if (dele.Sex == 0)
  5127. {
  5128. guestList.Sex = "Male";
  5129. }
  5130. else if (dele.Sex == 1)
  5131. {
  5132. guestList.Sex = "Female";
  5133. }
  5134. guestList.DOB = dele.BirthDay.Replace('-', '.');
  5135. if (!string.IsNullOrEmpty(dele.Job))
  5136. {
  5137. guestList.Job = dele.Job;
  5138. }
  5139. list.Add(guestList);
  5140. }
  5141. //载入模板
  5142. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  5143. DocumentBuilder builder = new DocumentBuilder(doc);
  5144. //获取word里所有表格
  5145. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5146. //获取所填表格的序数
  5147. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5148. var rowStart = tableOne.Rows[0]; //获取第1行
  5149. //循环赋值
  5150. for (int i = 0; i < list.Count; i++)
  5151. {
  5152. builder.MoveToCell(0, i + 1, 0, 0);
  5153. builder.Write(list[i].Name.ToString());
  5154. builder.MoveToCell(0, i + 1, 1, 0);
  5155. builder.Write(list[i].Sex.ToString());
  5156. builder.MoveToCell(0, i + 1, 2, 0);
  5157. builder.Write(list[i].DOB.ToString());
  5158. builder.MoveToCell(0, i + 1, 3, 0);
  5159. builder.Write(list[i].Job.ToString());
  5160. }
  5161. //删除多余行
  5162. while (tableOne.Rows.Count > list.Count + 1)
  5163. {
  5164. tableOne.Rows.RemoveAt(list.Count + 1);
  5165. }
  5166. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5167. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  5168. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  5169. doc.Save(filePath);
  5170. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  5171. return Ok(JsonView(true, "操作成功!", Url));
  5172. }
  5173. else
  5174. {
  5175. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  5176. }
  5177. }
  5178. catch (Exception ex)
  5179. {
  5180. return Ok(JsonView(false, ex.Message));
  5181. throw;
  5182. }
  5183. }
  5184. #endregion
  5185. #region 团组经理模块 出入境费用
  5186. /// <summary>
  5187. /// 团组模块 - 出入境费用 - 省份基础数据源
  5188. /// </summary>
  5189. /// <returns></returns>
  5190. [HttpGet]
  5191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5192. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  5193. {
  5194. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  5195. }
  5196. /// <summary>
  5197. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  5198. /// </summary>
  5199. /// <returns></returns>
  5200. [HttpPost]
  5201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5202. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  5203. {
  5204. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  5205. var groupNamFirst = groupNameData.FirstOrDefault();
  5206. //SetDataInfoView
  5207. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66) .ToListAsync();
  5208. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  5209. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  5210. //验证城市归属并给默认值
  5211. int provinceId = 122;
  5212. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  5213. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  5214. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  5215. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  5216. return Ok(JsonView(true, "查询成功!", new
  5217. {
  5218. GroupNameData = groupNameData,
  5219. CurrencyData = _CurrencyData,
  5220. WordTypeData = wordTypeData,
  5221. ExcelTypeData = excelTypeData,
  5222. CurrencyInit = _currencyInfos,
  5223. ViewPermissionData = viewPermissionData
  5224. }));
  5225. }
  5226. /// <summary>
  5227. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  5228. /// </summary>
  5229. /// <returns></returns>
  5230. [HttpGet("{provinceId}")]
  5231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5232. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  5233. {
  5234. //验证城市归属并给默认值
  5235. if (provinceId < 1) provinceId = 122;
  5236. /*
  5237. * 122 四川
  5238. * 108 贵州
  5239. * 103 重庆
  5240. * 132 云南
  5241. */
  5242. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  5243. return Ok(JsonView(true, "查询成功!", new
  5244. {
  5245. WordTypeData = wordTypeData,
  5246. ExcelTypeData = excelTypeData,
  5247. }));
  5248. }
  5249. /// <summary>
  5250. /// 团组模块 - 出入境费用
  5251. /// 实时汇率 tips
  5252. /// 签证费用 tips
  5253. /// 机票费用 tips
  5254. /// </summary>
  5255. /// <returns></returns>
  5256. [HttpPost]
  5257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5258. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  5259. {
  5260. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  5261. //默认币种显示
  5262. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  5263. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  5264. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  5265. return Ok(JsonView(true, "查询成功!", new
  5266. {
  5267. //GroupNameData = groupNameData.Data,
  5268. visaData = visaData.Data,
  5269. airData = airData.Data,
  5270. reteInfos = reteInfos
  5271. }));
  5272. }
  5273. /// <summary>
  5274. /// 团组模块 - 出入境费用 - Info
  5275. /// </summary>
  5276. /// <returns></returns>
  5277. [HttpPost]
  5278. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  5279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5280. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  5281. {
  5282. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  5283. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  5284. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  5285. }
  5286. /// <summary>
  5287. /// 团组模块 - 出入境费用 - 设置view权限
  5288. /// </summary>
  5289. /// <returns></returns>
  5290. [HttpPost]
  5291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5292. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  5293. {
  5294. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  5295. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  5296. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  5297. var permissions = new List<Grp_EnterExitCostPermission>();
  5298. foreach (var userId in dto.UserIds)
  5299. {
  5300. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  5301. }
  5302. if (permissions.Any())
  5303. {
  5304. _sqlSugar.BeginTran();
  5305. try
  5306. {
  5307. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  5308. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  5309. if (result < 1)
  5310. {
  5311. _sqlSugar.RollbackTran();
  5312. return Ok(JsonView(false));
  5313. }
  5314. }
  5315. catch (Exception ex)
  5316. {
  5317. _sqlSugar.RollbackTran();
  5318. return Ok(JsonView(false, ex.Message));
  5319. }
  5320. _sqlSugar.CommitTran();
  5321. return Ok(JsonView(true));
  5322. }
  5323. return Ok(JsonView(false));
  5324. }
  5325. /// <summary>
  5326. /// 团组模块 - 出入境费用 - Add And Update
  5327. /// </summary>
  5328. /// <returns></returns>
  5329. [HttpPost]
  5330. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  5331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5332. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  5333. {
  5334. try
  5335. {
  5336. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5337. if (dto.DayOtherPriceData.Any())
  5338. {
  5339. var inserList = dto.DayOtherPriceData
  5340. .Where(x => x.Id == 0)
  5341. .Select(x => new Grp_DayOtherPrice
  5342. {
  5343. Cost = x.Cost,
  5344. Id = x.Id,
  5345. CreateTime = DateTime.Now,
  5346. CreateUserId = dto.UserId,
  5347. Currency = x.Currency,
  5348. Diid = x.DiId,
  5349. Index = x.Index,
  5350. IsDel = 0,
  5351. SetDataId = x.SetDataId,
  5352. SubTotal = x.SubTotal,
  5353. Remark = x.Remark
  5354. })
  5355. .ToList();
  5356. var updateList = dto.DayOtherPriceData
  5357. .Where(x => x.Id != 0)
  5358. .Select(x => new Grp_DayOtherPrice
  5359. {
  5360. Cost = x.Cost,
  5361. Id = x.Id,
  5362. CreateTime = DateTime.Now,
  5363. CreateUserId = dto.UserId,
  5364. Currency = x.Currency,
  5365. Diid = x.DiId,
  5366. Index = x.Index,
  5367. IsDel = 0,
  5368. SetDataId = x.SetDataId,
  5369. SubTotal = x.SubTotal,
  5370. Remark = x.Remark
  5371. })
  5372. .ToList();
  5373. //添加
  5374. _sqlSugar.BeginTran();
  5375. if (inserList.Any())
  5376. {
  5377. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  5378. }
  5379. if (updateList.Any())
  5380. {
  5381. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  5382. }
  5383. _sqlSugar.CommitTran();
  5384. }
  5385. if (data.Code != 0)
  5386. {
  5387. return Ok(JsonView(false, data.Msg));
  5388. }
  5389. //生成默认文件pdf并且通知人员
  5390. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  5391. {
  5392. DiId = dto.DiId,
  5393. ExportType = 1,
  5394. SubTypeId = 1005
  5395. }, "pdf");
  5396. //发送通知
  5397. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  5398. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  5399. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  5400. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  5401. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  5402. //汇率信息记录
  5403. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  5404. return Ok(JsonView(true, data.Msg, data.Data));
  5405. }
  5406. catch (Exception ex)
  5407. {
  5408. return Ok(JsonView(false, ex.Message));
  5409. }
  5410. }
  5411. /// <summary>
  5412. /// 团组模块 - 出入境费用 - Confirm 费用
  5413. /// </summary>
  5414. /// <returns></returns>
  5415. [HttpPost]
  5416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5417. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  5418. {
  5419. //TODO:测试完毕需把对应的用户ID更改
  5420. //1、数据表添加字段
  5421. //2、更改字段接口()
  5422. var _view = await _enterExitCostRep.ConfirmCost(dto);
  5423. //3、确认成功 给财务发送消息
  5424. if (_view.Code == 200)
  5425. {
  5426. if (dto.Type == 1)
  5427. {
  5428. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  5429. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  5430. }
  5431. }
  5432. return Ok(_view);
  5433. }
  5434. /// <summary>
  5435. /// 团组模块 - 出入境费用 - File download
  5436. /// </summary>
  5437. /// <param name="dto"></param>
  5438. /// <returns></returns>
  5439. [HttpPost]
  5440. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  5441. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5442. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  5443. {
  5444. try
  5445. {
  5446. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  5447. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  5448. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  5449. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  5450. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  5451. 3 团组成员名单 1 团组成员名单", ""));
  5452. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  5453. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  5454. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  5455. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  5456. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  5457. //数据源
  5458. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  5459. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  5460. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  5461. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  5462. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  5463. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  5464. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  5465. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  5466. .Select((x, a, b) => new
  5467. {
  5468. x.Index,
  5469. itemName = a.Name,
  5470. CurrencyStr = b.Name,
  5471. x.Cost,
  5472. x.SubTotal,
  5473. x.Remark
  5474. })
  5475. .OrderBy((x) => x.Index)
  5476. .ToList(); //其他款项费用
  5477. var peiceItemCurrencys = new List<string>();
  5478. if (_DayAndCosts.Any())
  5479. {
  5480. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  5481. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  5482. }
  5483. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  5484. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  5485. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  5486. {
  5487. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  5488. }
  5489. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5490. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5491. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5492. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5493. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5494. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5495. .Select((tcl, dc, cc) => new ClientInfo
  5496. {
  5497. LastName = dc.LastName,
  5498. FirstName = dc.FirstName,
  5499. Sex = dc.Sex,
  5500. Birthday = dc.BirthDay,
  5501. Company = cc.CompanyFullName,
  5502. Job = dc.Job
  5503. })
  5504. .ToList();
  5505. foreach (var item in DeleClientList)
  5506. {
  5507. EncryptionProcessor.DecryptProperties(item);
  5508. }
  5509. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5510. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5511. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5512. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5513. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5514. if (dto.ExportType == 1) //明细表
  5515. {
  5516. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5517. {
  5518. //获取模板
  5519. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5520. //载入模板
  5521. Document doc = new Document(tempPath);
  5522. DocumentBuilder builder = new DocumentBuilder(doc);
  5523. //利用键值对存放数据
  5524. Dictionary<string, string> dic = new Dictionary<string, string>();
  5525. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5526. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5527. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5528. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5529. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5530. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5531. //境内费用(其他费用)
  5532. if (_EnterExitCosts.ChoiceOne == 1)
  5533. {
  5534. string row1_1 = "";
  5535. if (_EnterExitCosts.Visa > 0)
  5536. {
  5537. //insidePayTotal += _EnterExitCosts.Visa;
  5538. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5539. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5540. {
  5541. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5542. }
  5543. }
  5544. string row1_2 = "";
  5545. if (_EnterExitCosts.YiMiao > 0)
  5546. {
  5547. //insidePayTotal += _EnterExitCosts.YiMiao;
  5548. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5549. }
  5550. if (_EnterExitCosts.HeSuan > 0)
  5551. {
  5552. //insidePayTotal += _EnterExitCosts.HeSuan;
  5553. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5554. }
  5555. if (_EnterExitCosts.Service > 0)
  5556. {
  5557. //insidePayTotal += _EnterExitCosts.Service;
  5558. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5559. }
  5560. string row1_3 = "";
  5561. if (_EnterExitCosts.Safe > 0)
  5562. {
  5563. //insidePayTotal += _EnterExitCosts.Safe;
  5564. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5565. }
  5566. if (_EnterExitCosts.Ticket > 0)
  5567. {
  5568. //insidePayTotal += _EnterExitCosts.Ticket;
  5569. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5570. }
  5571. string row1 = "";
  5572. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5573. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5574. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5575. row1 += $"备注:{_EnterExitCosts.Remark}";
  5576. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5577. dic.Add("Row1Str", row1);
  5578. }
  5579. string airTotalStr = string.Empty,
  5580. airPriceStr = string.Empty;
  5581. //经济舱
  5582. if (_EnterExitCosts.SumJJC == 1)
  5583. {
  5584. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5585. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5586. }
  5587. //公务舱
  5588. if (_EnterExitCosts.SumGWC == 1)
  5589. {
  5590. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5591. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5592. }
  5593. //头等舱
  5594. if (_EnterExitCosts.SumTDC == 1)
  5595. {
  5596. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5597. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5598. }
  5599. //汇率描述
  5600. string rateStr = "";
  5601. if (peiceItemCurrencyInfos.Any())
  5602. {
  5603. rateStr = "\r\n汇率描述:";
  5604. foreach (var item in peiceItemCurrencyInfos)
  5605. {
  5606. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  5607. }
  5608. }
  5609. string twoItemRemark = "备注:";
  5610. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  5611. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  5612. dic.Add("AirTotalStr", airTotalStr);
  5613. dic.Add("AirPriceStr", airPriceStr);
  5614. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5615. dic.Add("TwoItemRemark", twoItemRemark);
  5616. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5617. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5618. int table1Row = 0,
  5619. table2Row = 0,
  5620. table3Row = 0,
  5621. table4Row = 0,
  5622. table5Row = 0;
  5623. //住宿费
  5624. if (_EnterExitCosts.ChoiceThree == 1)
  5625. {
  5626. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5627. table1Row = dac1.Count;
  5628. #region 填充word表格内容
  5629. for (int i = 0; i < dac1.Count; i++)
  5630. {
  5631. Grp_DayAndCost dac = dac1[i];
  5632. if (dac == null) continue;
  5633. builder.MoveToCell(0, i, 0, 0);
  5634. builder.Write("第" + dac.Days.ToString() + "晚:");
  5635. builder.MoveToCell(0, i, 1, 0);
  5636. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5637. //builder.Write(dac.Place == null ? "" : dac.Place);
  5638. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5639. builder.MoveToCell(0, i, 2, 0);
  5640. builder.Write("费用标准:");
  5641. string curr = "";
  5642. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5643. if (currData != null)
  5644. {
  5645. curr = currData.Name;
  5646. }
  5647. builder.MoveToCell(0, i, 3, 0);
  5648. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5649. builder.MoveToCell(0, i, 4, 0);
  5650. builder.Write("费用小计:");
  5651. builder.MoveToCell(0, i, 5, 0);
  5652. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5653. }
  5654. #endregion
  5655. }
  5656. else dic.Add("SubZS", "0.00");
  5657. //删除多余行
  5658. while (table1.Rows.Count > table1Row)
  5659. {
  5660. table1.Rows.RemoveAt(table1Row);
  5661. }
  5662. //伙食费
  5663. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5664. if (_EnterExitCosts.ChoiceFour == 1)
  5665. {
  5666. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5667. table2Row = dac2.Count;
  5668. #region 填充word表格内容
  5669. for (int i = 0; i < dac2.Count; i++)
  5670. {
  5671. Grp_DayAndCost dac = dac2[i];
  5672. if (dac == null) continue;
  5673. builder.MoveToCell(1, i, 0, 0);
  5674. builder.Write("第" + dac.Days.ToString() + "天:");
  5675. builder.MoveToCell(1, i, 1, 0);
  5676. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5677. builder.MoveToCell(1, i, 2, 0);
  5678. builder.Write("费用标准:");
  5679. string curr = "";
  5680. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5681. if (currData != null)
  5682. {
  5683. curr = currData.Name;
  5684. }
  5685. builder.MoveToCell(1, i, 3, 0);
  5686. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5687. builder.MoveToCell(1, i, 4, 0);
  5688. builder.Write("费用小计:");
  5689. builder.MoveToCell(1, i, 5, 0);
  5690. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5691. }
  5692. #endregion
  5693. }
  5694. else dic.Add("SubHS", "0.00");
  5695. //删除多余行
  5696. while (table2.Rows.Count > table2Row)
  5697. {
  5698. table2.Rows.RemoveAt(table2Row);
  5699. }
  5700. //公杂费
  5701. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5702. if (_EnterExitCosts.ChoiceFive == 1)
  5703. {
  5704. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5705. table3Row = dac3.Count;
  5706. #region 填充word表格内容
  5707. for (int i = 0; i < dac3.Count; i++)
  5708. {
  5709. Grp_DayAndCost dac = dac3[i];
  5710. if (dac == null) continue;
  5711. builder.MoveToCell(2, i, 0, 0);
  5712. builder.Write("第" + dac.Days.ToString() + "天:");
  5713. builder.MoveToCell(2, i, 1, 0);
  5714. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5715. builder.MoveToCell(2, i, 2, 0);
  5716. builder.Write("费用标准:");
  5717. string curr = "";
  5718. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5719. if (currData != null)
  5720. {
  5721. curr = currData.Name;
  5722. }
  5723. builder.MoveToCell(2, i, 3, 0);
  5724. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5725. builder.MoveToCell(2, i, 4, 0);
  5726. builder.Write("费用小计:");
  5727. builder.MoveToCell(2, i, 5, 0);
  5728. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5729. }
  5730. //删除多余行
  5731. while (table3.Rows.Count > table3Row)
  5732. {
  5733. table3.Rows.RemoveAt(table3Row);
  5734. }
  5735. #endregion
  5736. }
  5737. else dic.Add("SubGZF", "0.00");
  5738. //删除多余行
  5739. while (table3.Rows.Count > table3Row)
  5740. {
  5741. table3.Rows.RemoveAt(table3Row);
  5742. }
  5743. //培训费
  5744. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5745. if (_EnterExitCosts.ChoiceSix == 1)
  5746. {
  5747. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5748. dic.Add("SubPX", pxStr);
  5749. table4Row = dac4.Count;
  5750. #region 填充word表格内容
  5751. for (int i = 0; i < dac4.Count; i++)
  5752. {
  5753. Grp_DayAndCost dac = dac4[i];
  5754. if (dac == null) continue;
  5755. builder.MoveToCell(3, i, 0, 0);
  5756. builder.Write("第" + dac.Days.ToString() + "天:");
  5757. builder.MoveToCell(3, i, 1, 0);
  5758. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5759. builder.MoveToCell(3, i, 2, 0);
  5760. builder.Write("费用标准:");
  5761. string curr = "";
  5762. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5763. if (currData != null)
  5764. {
  5765. curr = currData.Name;
  5766. }
  5767. builder.MoveToCell(3, i, 3, 0);
  5768. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5769. builder.MoveToCell(3, i, 4, 0);
  5770. builder.Write("费用小计:");
  5771. builder.MoveToCell(3, i, 5, 0);
  5772. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5773. }
  5774. #endregion
  5775. }
  5776. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  5777. //删除多余行
  5778. while (table4.Rows.Count > table4Row)
  5779. {
  5780. table4.Rows.RemoveAt(table4Row);
  5781. }
  5782. //其他费用
  5783. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5784. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5785. {
  5786. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5787. dic.Add("titleQi", qtStr);
  5788. table5Row = dac5.Count;
  5789. #region 填充word表格内容
  5790. for (int i = 0; i < dac5.Count; i++)
  5791. {
  5792. var dac = dac5[i];
  5793. if (dac == null) continue;
  5794. builder.MoveToCell(4, i, 0, 0);
  5795. builder.Write("第" + dac.Index.ToString() + "项:");
  5796. builder.MoveToCell(4, i, 1, 0);
  5797. builder.Write(dac.itemName);
  5798. builder.MoveToCell(4, i, 2, 0);
  5799. builder.Write("费用标准:");
  5800. builder.MoveToCell(4, i, 3, 0);
  5801. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5802. builder.MoveToCell(4, i, 4, 0);
  5803. builder.Write("费用小计:");
  5804. builder.MoveToCell(4, i, 5, 0);
  5805. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5806. builder.MoveToCell(4, i, 6, 0);
  5807. builder.Write("备注:");
  5808. builder.MoveToCell(4, i, 7, 0);
  5809. builder.Write(dac.Remark);
  5810. }
  5811. #endregion
  5812. }
  5813. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5814. //删除多余行
  5815. while (table5.Rows.Count > table5Row)
  5816. {
  5817. table5.Rows.RemoveAt(table5Row);
  5818. }
  5819. //加上其他费用
  5820. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5821. decimal subJJC = 0.00M,
  5822. subGWC = 0.00M,
  5823. subTDC = 0.00M;
  5824. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  5825. string totalLabel = string.Format("全部费用总计:");
  5826. //经济舱
  5827. if (_EnterExitCosts.SumJJC == 1)
  5828. {
  5829. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5830. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  5831. }
  5832. //公务舱
  5833. if (_EnterExitCosts.SumGWC == 1)
  5834. {
  5835. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5836. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  5837. }
  5838. //头等舱
  5839. if (_EnterExitCosts.SumTDC == 1)
  5840. {
  5841. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5842. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  5843. }
  5844. //TotalLabel
  5845. dic.Add("TotalLabel", totalLabel);
  5846. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5847. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5848. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5849. #region 填充word模板书签内容
  5850. foreach (var key in dic.Keys)
  5851. {
  5852. Bookmark bookmark = doc.Range.Bookmarks[key];
  5853. if (bookmark != null)
  5854. {
  5855. builder.MoveToBookmark(key);
  5856. builder.Write(dic[key]);
  5857. }
  5858. }
  5859. #endregion
  5860. #region 设置页眉
  5861. string userLabel = string.Empty;
  5862. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5863. if (currUserInfo != null)
  5864. {
  5865. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5866. if (userInfo != null)
  5867. {
  5868. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5869. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5870. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5871. }
  5872. }
  5873. //设置页脚
  5874. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5875. #endregion
  5876. //文件名
  5877. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5878. AsposeHelper.removewatermark_v2180();
  5879. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5880. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5881. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5882. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5883. }
  5884. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5885. {
  5886. //获取模板
  5887. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5888. //载入模板
  5889. Document doc = new Document(tempPath);
  5890. DocumentBuilder builder = new DocumentBuilder(doc);
  5891. Dictionary<string, string> dic = new Dictionary<string, string>();
  5892. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5893. {
  5894. List<string> list = new List<string>();
  5895. try
  5896. {
  5897. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5898. foreach (var item in spilitArr)
  5899. {
  5900. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5901. var depCode = spDotandEmpty[2].Substring(0, 3);
  5902. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5903. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5904. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5905. list.Add(depName);
  5906. list.Add(arrName);
  5907. }
  5908. list = list.Distinct().ToList();
  5909. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5910. }
  5911. catch (Exception)
  5912. {
  5913. dic.Add("ReturnCode", "行程录入不正确!");
  5914. }
  5915. }
  5916. else
  5917. {
  5918. dic.Add("ReturnCode", "未录入行程!");
  5919. }
  5920. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5921. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5922. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5923. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5924. {
  5925. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5926. dic.Add("Day", sp.Days.ToString());
  5927. }
  5928. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5929. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5930. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5931. //dic.Add("Names", Names);
  5932. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5933. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5934. decimal dac1totalPrice = 0.00M;
  5935. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5936. foreach (var dac in dac1)
  5937. {
  5938. if (dac.SubTotal == 0.00M)
  5939. {
  5940. continue;
  5941. }
  5942. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5943. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5944. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5945. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5946. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5947. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5948. builder.Write(currency);//币种
  5949. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5950. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5951. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5952. builder.Write("");//人数
  5953. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5954. builder.Write("");//天数
  5955. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5956. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5957. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5958. decimal rate = 0.00M;
  5959. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5960. builder.Write(rate.ToString("#0.0000"));//汇率
  5961. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5962. decimal rbmPrice = dac.SubTotal;
  5963. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5964. accommodationStartIndex++;
  5965. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5966. }
  5967. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5968. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5969. {
  5970. table1.Rows.RemoveAt(i - 1);
  5971. foodandotherStartIndex--;
  5972. }
  5973. if (dac2.Count == dac3.Count)//国家 币种 金额
  5974. {
  5975. for (int i = 0; i < dac2.Count; i++)
  5976. {
  5977. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5978. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5979. }
  5980. }
  5981. decimal dac2totalPrice = 0.00M;
  5982. foreach (var dac in dac2)
  5983. {
  5984. if (dac.SubTotal == 0)
  5985. {
  5986. continue;
  5987. }
  5988. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5989. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5990. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5991. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5992. builder.Write(currency);//币种
  5993. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5994. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5995. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5996. builder.Write("");//人数
  5997. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5998. builder.Write("");//天数
  5999. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6000. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6001. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6002. decimal rate = 0.00M;
  6003. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6004. builder.Write(rate.ToString("#0.0000"));//汇率
  6005. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6006. decimal rbmPrice = dac.SubTotal;
  6007. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6008. foodandotherStartIndex++;
  6009. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6010. }
  6011. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6012. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  6013. {
  6014. table1.Rows.RemoveAt(i - 1);
  6015. }
  6016. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6017. string otherFeeStr = "";
  6018. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  6019. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  6020. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  6021. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6022. foreach (var otherInfo in dac5)
  6023. {
  6024. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6025. }
  6026. #endregion
  6027. if (otherFeeStr.Length > 0)
  6028. {
  6029. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6030. otherFeeStr = $"({otherFeeStr})";
  6031. dic.Add("OtherFeeStr", otherFeeStr);
  6032. }
  6033. //总计
  6034. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  6035. //国际旅费
  6036. string outsideAir = string.Empty;
  6037. string allPriceAir = string.Empty;
  6038. if (_EnterExitCosts.SumJJC == 1)
  6039. {
  6040. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6041. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  6042. }
  6043. if (_EnterExitCosts.SumGWC == 1)
  6044. {
  6045. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  6046. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6047. }
  6048. if (_EnterExitCosts.SumTDC == 1)
  6049. {
  6050. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  6051. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  6052. }
  6053. dic.Add("InTravelPrice", $"({outsideAir})");
  6054. dic.Add("FinalSumPrice", $"({allPriceAir})");
  6055. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  6056. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  6057. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  6058. foreach (var key in dic.Keys)
  6059. {
  6060. builder.MoveToBookmark(key);
  6061. builder.Write(dic[key]);
  6062. }
  6063. //模板文件名
  6064. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6065. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6066. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6067. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6068. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6069. }
  6070. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  6071. {
  6072. //获取模板
  6073. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  6074. //载入模板
  6075. WorkbookDesigner designer = new WorkbookDesigner();
  6076. designer.Workbook = new Workbook(tempPath);
  6077. Dictionary<string, string> dic = new Dictionary<string, string>();
  6078. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6079. {
  6080. List<string> list = new List<string>();
  6081. try
  6082. {
  6083. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6084. foreach (var item in spilitArr)
  6085. {
  6086. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6087. var depCode = spDotandEmpty[2].Substring(0, 3);
  6088. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6089. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  6090. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  6091. list.Add(depName);
  6092. list.Add(arrName);
  6093. }
  6094. list = list.Distinct().ToList();
  6095. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6096. }
  6097. catch (Exception)
  6098. {
  6099. dic.Add("ReturnCode", "行程录入不正确!");
  6100. }
  6101. }
  6102. else
  6103. {
  6104. dic.Add("ReturnCode", "未录入行程!");
  6105. }
  6106. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6107. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6108. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6109. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6110. {
  6111. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6112. dic.Add("Day", sp.Days.ToString());
  6113. }
  6114. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6115. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6116. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6117. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  6118. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  6119. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  6120. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  6121. designer.SetDataSource("Name", Names);
  6122. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  6123. designer.SetDataSource("Day", dic["Day"] + "天");
  6124. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  6125. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  6126. int startIndex = 10;
  6127. const int startIndexcopy = 10;
  6128. if (dac2.Count == dac3.Count)//国家 币种 金额
  6129. {
  6130. for (int i = 0; i < dac2.Count; i++)
  6131. {
  6132. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6133. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6134. }
  6135. }
  6136. DataTable dtdac1 = new DataTable();
  6137. List<string> place = new List<string>();
  6138. dtdac1.Columns.AddRange(new DataColumn[] {
  6139. new DataColumn(){ ColumnName = "city"},
  6140. new DataColumn(){ ColumnName = "curr"},
  6141. new DataColumn(){ ColumnName = "criterion"},
  6142. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6143. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6144. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6145. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6146. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  6147. });
  6148. DataTable dtdac2 = new DataTable();
  6149. dtdac2.Columns.AddRange(new DataColumn[] {
  6150. new DataColumn(){ ColumnName = "city"},
  6151. new DataColumn(){ ColumnName = "curr"},
  6152. new DataColumn(){ ColumnName = "criterion"},
  6153. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  6154. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  6155. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  6156. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  6157. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  6158. });
  6159. dtdac1.TableName = "tb1";
  6160. dtdac2.TableName = "tb2";
  6161. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  6162. foreach (var item in dac1)
  6163. {
  6164. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6165. if (place.Contains(item.Place))
  6166. {
  6167. continue;
  6168. }
  6169. DataRow row = dtdac1.NewRow();
  6170. row["city"] = item.Place;
  6171. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6172. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6173. row["curr"] = currency;
  6174. row["rate"] = rate.ToString("#0.0000");
  6175. row["criterion"] = item.Cost.ToString("#0.00");
  6176. row["number"] = 1;
  6177. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6178. //row["costRMB"] = rbmPrice;
  6179. dtdac1.Rows.Add(row);
  6180. place.Add(item.Place);
  6181. }
  6182. place = new List<string>();
  6183. foreach (var item in dac2)
  6184. {
  6185. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  6186. if (place.Contains(item.Place))
  6187. {
  6188. continue;
  6189. }
  6190. DataRow row = dtdac2.NewRow();
  6191. row["city"] = item.Place;
  6192. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  6193. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6194. row["curr"] = currency;
  6195. row["rate"] = rate.ToString("#0.0000");
  6196. row["criterion"] = item.Cost.ToString("#0.00");
  6197. row["number"] = 1;
  6198. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  6199. //row["cost"] = item.SubTotal;
  6200. //row["costRMB"] = rbmPrice;
  6201. dtdac2.Rows.Add(row);
  6202. place.Add(item.Place);
  6203. //dac2totalPrice += rbmPrice;
  6204. }
  6205. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  6206. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  6207. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6208. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  6209. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  6210. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  6211. string cell4Str1 = string.Empty;
  6212. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  6213. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  6214. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  6215. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  6216. string cellStr = $" 5.其他费用(";
  6217. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6218. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6219. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6220. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6221. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6222. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6223. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  6224. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  6225. foreach (var otherInfo in dac5)
  6226. {
  6227. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6228. }
  6229. #endregion
  6230. if (cellStr.Length > 8)
  6231. {
  6232. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  6233. }
  6234. cellStr += ")";
  6235. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  6236. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  6237. decimal pxFee = dac4.Sum(it => it.Cost);
  6238. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  6239. string celllastStr1 = "";
  6240. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  6241. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  6242. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  6243. celllastStr1 += $",国际旅费 元";
  6244. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  6245. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  6246. designer.SetDataSource("cell4Str", cell4Str);
  6247. designer.SetDataSource("cellStr", cellStr);
  6248. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  6249. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6250. designer.SetDataSource("celllastStr", celllastStr);
  6251. Workbook wb = designer.Workbook;
  6252. var sheet = wb.Worksheets[0];
  6253. //绑定datatable数据集
  6254. designer.SetDataSource(dtdac1);
  6255. designer.SetDataSource(dtdac2);
  6256. designer.Process();
  6257. var rowStart = dtdac1.Rows.Count;
  6258. while (rowStart > 0)
  6259. {
  6260. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  6261. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6262. startIndex++;
  6263. rowStart--;
  6264. }
  6265. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  6266. startIndex += 1; //总计行
  6267. rowStart = dtdac2.Rows.Count;
  6268. while (rowStart > 0)
  6269. {
  6270. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  6271. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  6272. startIndex++;
  6273. rowStart--;
  6274. }
  6275. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  6276. wb.CalculateFormula(true);
  6277. //模板文件名
  6278. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  6279. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6280. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6281. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6282. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6283. }
  6284. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  6285. {
  6286. //获取模板
  6287. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  6288. //载入模板
  6289. Document doc = new Document(tempPath);
  6290. DocumentBuilder builder = new DocumentBuilder(doc);
  6291. Dictionary<string, string> dic = new Dictionary<string, string>();
  6292. dic.Add("GroupName", _DelegationInfo.TeamName);
  6293. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6294. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  6295. string missionLeaderJob = "";//负责人job
  6296. //int groupNumber = 0; //团人数
  6297. if (DeleClientList.Count > 0)
  6298. {
  6299. missionLeader = DeleClientList[0]?.Name ?? "";
  6300. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  6301. }
  6302. dic.Add("MissionLeader", missionLeader); //团负责人
  6303. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  6304. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  6305. #region MyRegion
  6306. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6307. //{
  6308. // List<string> list = new List<string>();
  6309. // try
  6310. // {
  6311. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6312. // foreach (var item in spilitArr)
  6313. // {
  6314. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6315. // var depCode = spDotandEmpty[2].Substring(0, 3);
  6316. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  6317. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6318. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6319. // list.Add(depName);
  6320. // list.Add(arrName);
  6321. // }
  6322. // list = list.Distinct().ToList();
  6323. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6324. // }
  6325. // catch (Exception)
  6326. // {
  6327. // dic.Add("ReturnCode", "行程录入不正确!");
  6328. // }
  6329. //}
  6330. //else
  6331. //{
  6332. // dic.Add("ReturnCode", "未录入行程!");
  6333. //}
  6334. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  6335. dic.Add("ReturnCode", string.Join("、", countrys));
  6336. #endregion
  6337. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6338. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6339. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6340. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6341. //{
  6342. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6343. // dic.Add("Day", sp.Days.ToString());
  6344. //}
  6345. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  6346. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  6347. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6348. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6349. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6350. //培训人员名单
  6351. int cultivateRowIndex = 7;
  6352. foreach (var item in DeleClientList)
  6353. {
  6354. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  6355. builder.Write(item.Name);
  6356. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  6357. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  6358. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  6359. string birthDay = "";
  6360. if (item.Birthday != null)
  6361. {
  6362. DateTime dt = Convert.ToDateTime(item.Birthday);
  6363. birthDay = $"{dt.Year}.{dt.Month}";
  6364. }
  6365. builder.Write(birthDay);
  6366. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  6367. builder.Write(item.Company);
  6368. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  6369. builder.Write(item.Job);
  6370. cultivateRowIndex++;
  6371. }
  6372. //删除多余行
  6373. //cultivateRowIndex -= 2;
  6374. int delRows = 10 + 7 - cultivateRowIndex;
  6375. if (delRows > 0)
  6376. {
  6377. for (int i = 0; i < delRows; i++)
  6378. {
  6379. table1.Rows.RemoveAt(cultivateRowIndex);
  6380. //cultivateRowIndex++;
  6381. }
  6382. }
  6383. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  6384. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  6385. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  6386. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  6387. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  6388. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  6389. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  6390. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  6391. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  6392. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  6393. //其他费用
  6394. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  6395. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  6396. //其他费用合计
  6397. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  6398. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  6399. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  6400. //公务舱合计
  6401. //国际旅费
  6402. //string outsideJJ = "";
  6403. //string allPriceJJ = "";
  6404. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  6405. {
  6406. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6407. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  6408. }
  6409. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  6410. {
  6411. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  6412. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  6413. }
  6414. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  6415. {
  6416. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  6417. dic.Add("AirFeeTotal", airFeeTotalStr);
  6418. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  6419. dic.Add("FeeTotal", feeTotalStr);
  6420. }
  6421. foreach (var key in dic.Keys)
  6422. {
  6423. builder.MoveToBookmark(key);
  6424. builder.Write(dic[key]);
  6425. }
  6426. //模板文件名
  6427. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  6428. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6429. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6430. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6431. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6432. }
  6433. }
  6434. else if (dto.ExportType == 2) //表格
  6435. {
  6436. //利用键值对存放数据
  6437. Dictionary<string, string> dic = new Dictionary<string, string>();
  6438. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6439. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6440. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6441. dic.Add("Day", sp.Days.ToString());
  6442. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6443. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  6444. {
  6445. //获取模板
  6446. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  6447. //载入模板
  6448. Document doc = new Document(tempPath);
  6449. DocumentBuilder builder = new DocumentBuilder(doc);
  6450. dic.Add("TeamName", _DelegationInfo.TeamName);
  6451. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6452. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  6453. string missionLeaderName = "",
  6454. missionLeaderJob = "";
  6455. if (DeleClientList.Count > 0)
  6456. {
  6457. missionLeaderName = DeleClientList[0].Name;
  6458. missionLeaderJob = DeleClientList[0].Job;
  6459. }
  6460. dic.Add("MissionLeaderName", missionLeaderName);
  6461. dic.Add("MissionLeaderJob", missionLeaderJob);
  6462. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  6463. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  6464. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6465. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6466. int rowCount = 10;//总人数行
  6467. int startRowIndex = 7; //起始行
  6468. for (int i = 0; i < DeleClientList.Count; i++)
  6469. {
  6470. builder.MoveToCell(0, startRowIndex, 0, 0);
  6471. builder.Write(DeleClientList[i].Name); //出国人员姓名
  6472. builder.MoveToCell(0, startRowIndex, 1, 0);
  6473. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6474. builder.Write(sex);//性别
  6475. builder.MoveToCell(0, startRowIndex, 2, 0);
  6476. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  6477. builder.MoveToCell(0, startRowIndex, 3, 0);
  6478. builder.Write(DeleClientList[i].Company);//工作单位
  6479. builder.MoveToCell(0, startRowIndex, 4, 0);
  6480. builder.Write(DeleClientList[i].Job);//职务及级别
  6481. builder.MoveToCell(0, startRowIndex, 5, 0);
  6482. builder.Write("");//人员属性
  6483. builder.MoveToCell(0, startRowIndex, 6, 0);
  6484. builder.Write("");//上次出国时间
  6485. startRowIndex++;
  6486. }
  6487. int nullRow = rowCount - DeleClientList.Count;//空行
  6488. for (int i = 0; i < nullRow; i++)
  6489. {
  6490. table1.Rows.Remove(table1.Rows[startRowIndex]);
  6491. }
  6492. foreach (var key in dic.Keys)
  6493. {
  6494. builder.MoveToBookmark(key);
  6495. builder.Write(dic[key]);
  6496. }
  6497. //模板文件名
  6498. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  6499. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6500. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6501. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  6502. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  6503. }
  6504. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  6505. {
  6506. //获取模板
  6507. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  6508. //载入模板
  6509. Document doc = new Document(tempPath);
  6510. DocumentBuilder builder = new DocumentBuilder(doc);
  6511. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6512. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6513. dic.Add("Names", Names);
  6514. int accommodationRows = 12;
  6515. //int foodandotherRows = 12;
  6516. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6517. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6518. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6519. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6520. int accommodationStartIndex = 6;
  6521. decimal dac1totalPrice = 0.00M;
  6522. foreach (var dac in dac1)
  6523. {
  6524. if (dac.SubTotal == 0)
  6525. {
  6526. continue;
  6527. }
  6528. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6529. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6530. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6531. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6532. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6533. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6534. builder.Write(currency);//币种
  6535. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6536. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6537. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6538. builder.Write("");//人数
  6539. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6540. builder.Write("");//天数
  6541. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6542. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6543. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6544. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6545. builder.Write(rate.ToString("#0.0000"));//汇率
  6546. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6547. decimal rbmPrice = rate * dac.SubTotal;
  6548. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6549. accommodationStartIndex++;
  6550. dac1totalPrice += rbmPrice;
  6551. }
  6552. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6553. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6554. builder.Write("小计");
  6555. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6556. builder.Write(dac1totalPrice.ToString("#0.00"));
  6557. accommodationStartIndex++;
  6558. int nullRow = accommodationRows - dac1.Count;
  6559. //删除空行
  6560. //if (nullRow > 0)
  6561. //{
  6562. // int rowIndex = accommodationStartIndex;
  6563. // for (int i = 0; i < nullRow; i++)
  6564. // {
  6565. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6566. // row.Remove();
  6567. // rowIndex++;
  6568. // }
  6569. //}
  6570. if (dac2.Count == dac3.Count)//国家 币种 金额
  6571. {
  6572. for (int i = 0; i < dac2.Count; i++)
  6573. {
  6574. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6575. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6576. }
  6577. }
  6578. int foodandotherStartIndex = 19;//
  6579. decimal dac2totalPrice = 0.00M;
  6580. foreach (var dac in dac2)
  6581. {
  6582. if (dac.SubTotal == 0)
  6583. {
  6584. continue;
  6585. }
  6586. //foodandotherStartIndex = 12;
  6587. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6588. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6589. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6590. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6591. builder.Write(currency);//币种
  6592. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6593. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6594. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6595. builder.Write("");//人数
  6596. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6597. builder.Write("");//天数
  6598. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6599. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6600. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6601. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6602. builder.Write(rate.ToString("#0.0000"));//汇率
  6603. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6604. decimal rbmPrice = rate * dac.SubTotal;
  6605. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6606. foodandotherStartIndex++;
  6607. dac2totalPrice += rbmPrice;
  6608. }
  6609. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6610. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6611. //删除空行
  6612. //if (dac2.Count < foodandotherRows)
  6613. //{
  6614. // while (table2.Rows.Count > dac2.Count)
  6615. // {
  6616. // table2.Rows.RemoveAt(dac2.Count);
  6617. // }
  6618. //}
  6619. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6620. string otherFeeStr = "";
  6621. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6622. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6623. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6624. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6625. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6626. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6627. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6628. foreach (var otherInfo in dac5)
  6629. {
  6630. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6631. }
  6632. #endregion
  6633. if (otherFeeStr.Length > 0)
  6634. {
  6635. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6636. otherFeeStr = $"({otherFeeStr})";
  6637. dic.Add("OtherFeeStr", otherFeeStr);
  6638. }
  6639. foreach (var key in dic.Keys)
  6640. {
  6641. builder.MoveToBookmark(key);
  6642. builder.Write(dic[key]);
  6643. }
  6644. //模板文件名
  6645. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6646. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6647. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6648. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6649. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6650. }
  6651. }
  6652. else if (dto.ExportType == 3)
  6653. {
  6654. if (dto.SubTypeId == 1) //团组成员名单
  6655. {
  6656. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6657. //获取模板
  6658. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6659. //载入模板
  6660. Document doc = new Document(tempPath);
  6661. DocumentBuilder builder = new DocumentBuilder(doc);
  6662. //获取word里所有表格
  6663. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6664. //获取所填表格的序数
  6665. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6666. var rowStart = tableOne.Rows[0]; //获取第1行
  6667. //循环赋值
  6668. for (int i = 0; i < DeleClientList.Count; i++)
  6669. {
  6670. builder.MoveToCell(0, i + 1, 0, 0);
  6671. builder.Write(DeleClientList[i].Name);
  6672. builder.MoveToCell(0, i + 1, 1, 0);
  6673. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6674. builder.Write(sex);
  6675. builder.MoveToCell(0, i + 1, 2, 0);
  6676. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6677. builder.MoveToCell(0, i + 1, 3, 0);
  6678. builder.Write(DeleClientList[i].Company);
  6679. builder.MoveToCell(0, i + 1, 4, 0);
  6680. builder.Write(DeleClientList[i].Job);
  6681. }
  6682. //删除多余行
  6683. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6684. {
  6685. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6686. }
  6687. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6688. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6689. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6690. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6691. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6692. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6693. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6694. }
  6695. }
  6696. return Ok(JsonView(400, "操作失败!", ""));
  6697. }
  6698. catch (Exception ex)
  6699. {
  6700. return Ok(JsonView(400, ex.Message, ""));
  6701. }
  6702. }
  6703. /// <summary>
  6704. /// 获取三公费用标准city
  6705. /// </summary>
  6706. /// <param name="placeData"></param>
  6707. /// <param name="nationalTravelFeeId"></param>
  6708. /// <returns></returns>
  6709. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6710. {
  6711. string _city = string.Empty;
  6712. if (placeData.Count < 1) return _city;
  6713. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6714. if (data == null) return _city;
  6715. string country = data.Country;
  6716. string city = data.City;
  6717. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6718. else _city = city;
  6719. return _city;
  6720. }
  6721. ///// <summary>
  6722. ///// 团组模块 - 出入境费用 - 明细表导出
  6723. ///// </summary>
  6724. ///// <returns></returns>
  6725. //[HttpPost]
  6726. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6727. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6728. //{
  6729. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6730. // if (data.Code != 0)
  6731. // {
  6732. // return Ok(JsonView(false, data.Msg));
  6733. // }
  6734. // return Ok(JsonView(true, data.Msg, data.Data));
  6735. //}
  6736. /// <summary>
  6737. /// 团组模块 - 出入境费用 - 一键清空
  6738. /// </summary>
  6739. /// <returns></returns>
  6740. [HttpPost]
  6741. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6743. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6744. {
  6745. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6746. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6747. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6748. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6749. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6750. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6751. .SetColumns(x => new Grp_DayOtherPrice
  6752. {
  6753. IsDel = 1,
  6754. DeleteUserId = dto.UserId,
  6755. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6756. })
  6757. .ExecuteCommandAsync();
  6758. if (_view.Code == 0)
  6759. {
  6760. return Ok(JsonView(true, "操作成功"));
  6761. }
  6762. return Ok(JsonView(false, "操作失败"));
  6763. }
  6764. /// <summary>
  6765. /// 团组模块 - 出入境费用 - 子项删除
  6766. /// </summary>
  6767. /// <returns></returns>
  6768. [HttpPost]
  6769. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6771. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6772. {
  6773. try
  6774. {
  6775. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6776. if (data.Code != 0)
  6777. {
  6778. return Ok(JsonView(false, data.Msg));
  6779. }
  6780. return Ok(JsonView(true, "操作成功!", data.Data));
  6781. }
  6782. catch (Exception ex)
  6783. {
  6784. return Ok(JsonView(false, ex.Message));
  6785. }
  6786. }
  6787. /// <summary>
  6788. /// 删除三公其他费用
  6789. /// </summary>
  6790. /// <param name="dto"></param>
  6791. /// <returns></returns>
  6792. [HttpPost]
  6793. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6794. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6795. {
  6796. var jw = JsonView(false, "删除失败!");
  6797. var data = new Grp_DayOtherPrice()
  6798. {
  6799. Id = dto.Id,
  6800. IsDel = 1,
  6801. DeleteUserId = dto.DeleteUserId,
  6802. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6803. };
  6804. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6805. if (del > 0)
  6806. {
  6807. jw.Code = 200;
  6808. jw.Msg = "删除成功!";
  6809. }
  6810. return Ok(jw);
  6811. }
  6812. /// <summary>
  6813. /// 团组模块 - 出入境国家费用标准 List
  6814. /// </summary>
  6815. /// <returns></returns>
  6816. [HttpPost]
  6817. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6818. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  6819. {
  6820. int provinceId = dto.ProvinceId;
  6821. if (provinceId < 1) provinceId = 122; //默认四川省数据
  6822. var nftData = await _sqlSugar
  6823. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  6824. JoinType.Left, ntf.Currency == sd1.Id,
  6825. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  6826. JoinType.Left, ntf.ProvinceId == c.Id
  6827. ))
  6828. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  6829. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  6830. {
  6831. Id = ntf.Id,
  6832. ProvinceId = ntf.ProvinceId,
  6833. ProvinceName = c.Name_CN,
  6834. Continent = ntf.Continent,
  6835. Country = ntf.Country,
  6836. City = ntf.City,
  6837. Currency = ntf.Currency,
  6838. CurrencyCode = sd1.Name,
  6839. CurrencyName = sd1.Remark,
  6840. RoomCost = ntf.RoomCost,
  6841. FoodCost = ntf.FoodCost,
  6842. PublicCost = ntf.PublicCost,
  6843. LastUpdateUserId = ntf.LastUpdateUserId,
  6844. LastUpdateUserName = u.CnName,
  6845. LastUpdateTime = ntf.LastUpdateTime
  6846. })
  6847. .ToListAsync();
  6848. return Ok(JsonView(true, "查询成功!", nftData));
  6849. }
  6850. /// <summary>
  6851. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6852. /// </summary>
  6853. /// <returns></returns>
  6854. [HttpPost]
  6855. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6856. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6857. {
  6858. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6859. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6860. List<string> countryData = new List<string>();
  6861. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  6862. countryData = countryData.Distinct().ToList();
  6863. List<dynamic> dataSource = new List<dynamic>();
  6864. foreach (var item in countryData)
  6865. {
  6866. var cityData1 = new List<string>();
  6867. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  6868. var countryData2 = new
  6869. {
  6870. CountryName = item,
  6871. CityData = cityData1
  6872. };
  6873. if (!dataSource.Contains(countryData2))
  6874. {
  6875. dataSource.Add(countryData2);
  6876. }
  6877. }
  6878. return Ok(JsonView(true, "查询成功!", dataSource));
  6879. }
  6880. /// <summary>
  6881. /// 团组模块 - 出入境国家费用标准 Page List
  6882. /// </summary>
  6883. /// <returns></returns>
  6884. [HttpPost]
  6885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6886. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6887. {
  6888. int portId = dto.PortType,
  6889. pageIndex = dto.PageIndex,
  6890. pageSize = dto.PageSize;
  6891. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6892. if (pageIndex == 0) pageIndex = 1;
  6893. if (pageSize == 0) pageSize = 10;
  6894. RefAsync<int> total = 0;
  6895. var nationalTravelFeeData = await _sqlSugar
  6896. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  6897. JoinType.Left, ntf.Currency == sd1.Id,
  6898. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  6899. JoinType.Left, ntf.ProvinceId == sd2.Id
  6900. ))
  6901. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  6902. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  6903. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  6904. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  6905. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  6906. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  6907. {
  6908. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  6909. Id = ntf.Id,
  6910. ProvinceId = ntf.ProvinceId,
  6911. ProvinceName = sd2.Name_CN,
  6912. Continent = ntf.Continent,
  6913. Country = ntf.Country,
  6914. City = ntf.City,
  6915. Currency = ntf.Currency,
  6916. CurrencyCode = sd1.Name,
  6917. CurrencyName = sd1.Remark,
  6918. RoomCost = ntf.RoomCost,
  6919. FoodCost = ntf.FoodCost,
  6920. PublicCost = ntf.PublicCost,
  6921. LastUpdateUserId = ntf.LastUpdateUserId,
  6922. LastUpdateUserName = u.CnName,
  6923. LastUpdateTime = ntf.LastUpdateTime,
  6924. Remark = ntf.Remark
  6925. })
  6926. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6927. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6928. }
  6929. /// <summary>
  6930. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6931. /// </summary>
  6932. /// <returns></returns>
  6933. [HttpPost]
  6934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6935. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6936. {
  6937. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6938. int portId = dto.PortType;
  6939. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6940. string whereSql = string.Empty;
  6941. if (!string.IsNullOrEmpty(dto.Country))
  6942. {
  6943. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6944. }
  6945. if (!string.IsNullOrEmpty(dto.City))
  6946. {
  6947. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6948. }
  6949. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6950. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  6951. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6952. From Grp_NationalTravelFee gntf
  6953. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6954. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6955. Where gntf.Isdel = 0 {0} ", whereSql);
  6956. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6957. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6958. }
  6959. /// <summary>
  6960. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6961. /// </summary>
  6962. /// <returns></returns>
  6963. [HttpPost]
  6964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6965. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6966. {
  6967. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  6968. }
  6969. /// <summary>
  6970. /// 团组模块 - 出入境国家费用标准 - Del
  6971. /// </summary>
  6972. /// <returns></returns>
  6973. [HttpPost]
  6974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6975. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6976. {
  6977. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6978. {
  6979. Id = dto.Id,
  6980. DeleteUserId = dto.DeleteUserId,
  6981. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6982. IsDel = 1
  6983. };
  6984. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6985. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6986. .WhereColumns(it => new { it.Id })
  6987. .ExecuteCommandAsync();
  6988. if (delStatus <= 0)
  6989. {
  6990. return Ok(JsonView(false, "删除失败!"));
  6991. }
  6992. return Ok(JsonView(true, "操作成功!"));
  6993. }
  6994. /// <summary>
  6995. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6996. /// 注:Get 请求Headers 加 Token
  6997. /// </summary>
  6998. /// <param name="groupId"></param>
  6999. /// <returns></returns>
  7000. [HttpGet("{groupId}")]
  7001. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7002. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  7003. {
  7004. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7005. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  7006. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  7007. data.ForEach(x =>
  7008. {
  7009. x.CreateUserId = _currUserInfo.UserId;
  7010. });
  7011. if (data.Any())
  7012. {
  7013. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  7014. if (add > 0)
  7015. {
  7016. return Ok(JsonView(true, "操作成功!"));
  7017. }
  7018. }
  7019. return Ok(JsonView(false, "未操作!"));
  7020. }
  7021. #endregion
  7022. #region 团组经理模块 出入境费用-草稿
  7023. /// <summary>
  7024. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  7025. /// </summary>
  7026. /// <returns></returns>
  7027. [HttpGet]
  7028. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7029. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  7030. {
  7031. var provData = await _groupRepository.ProvinceBasicSource();
  7032. return Ok(JsonView(true, "查询成功!", provData));
  7033. }
  7034. /// <summary>
  7035. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  7036. /// </summary>
  7037. /// <returns></returns>
  7038. [HttpGet("{provinceId}")]
  7039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7040. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  7041. {
  7042. //验证城市归属并给默认值
  7043. if (provinceId < 1) provinceId = 122;
  7044. /*
  7045. * 122 四川
  7046. * 108 贵州
  7047. * 103 重庆
  7048. * 132 云南
  7049. */
  7050. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  7051. return Ok(JsonView(true, "查询成功!", new
  7052. {
  7053. WordTypeData = wordTypeData,
  7054. ExcelTypeData = excelTypeData,
  7055. }));
  7056. }
  7057. /// <summary>
  7058. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  7059. /// </summary>
  7060. /// <returns></returns>
  7061. [HttpPost]
  7062. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7063. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  7064. {
  7065. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  7066. .Where(x => x.IsDel == 0)
  7067. .OrderByDescending(x => x.CreateTime)
  7068. .Select(x => new { x.Id, x.DraftName })
  7069. .ToListAsync();
  7070. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7071. //SetDataInfoView
  7072. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  7073. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  7074. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  7075. int provinceId = dto.ProvinceId;
  7076. if (provinceId < 1) provinceId = 122;
  7077. /*
  7078. * 122 四川
  7079. * 108 贵州
  7080. * 103 重庆
  7081. * 132 云南
  7082. */
  7083. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  7084. //默认币种显示
  7085. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  7086. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  7087. return Ok(JsonView(true, "查询成功!", new
  7088. {
  7089. DraftNameDatas = draftNameDatas,
  7090. CurrencyData = _CurrencyData,
  7091. WordTypeData = wordTypeData,
  7092. ExcelTypeData = excelTypeData,
  7093. CurrencyInit = _currencyInfos,
  7094. ViewPermissionData = viewPermissionData
  7095. }));
  7096. }
  7097. /// <summary>
  7098. /// 团组模块 - 出入境费用-草稿
  7099. /// 实时汇率 tips
  7100. /// 机票费用 tips
  7101. /// </summary>
  7102. /// <returns></returns>
  7103. [HttpPost]
  7104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7105. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  7106. {
  7107. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  7108. return Ok(JsonView(true, "查询成功!", new
  7109. {
  7110. //GroupNameData = groupNameData.Data,
  7111. //visaData = visaData.Data,
  7112. //airData = airData.Data,
  7113. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  7114. }));
  7115. }
  7116. /// <summary>
  7117. /// 团组模块 - 出入境费用-草稿
  7118. /// 签证费用 tips
  7119. /// </summary>
  7120. /// <returns></returns>
  7121. [HttpPost]
  7122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7123. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  7124. {
  7125. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  7126. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  7127. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  7128. .Select(x => x.NationalTravelFeeId)
  7129. .Distinct()
  7130. .ToListAsync();
  7131. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7132. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7133. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  7134. .Select(x => x.Country)
  7135. .Distinct()
  7136. .ToArrayAsync();
  7137. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  7138. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  7139. return Ok(JsonView(true, "查询成功!", new
  7140. {
  7141. totalAmt = totalAmt,
  7142. remark = remark
  7143. }));
  7144. }
  7145. /// <summary>
  7146. /// 团组模块 - 出入境费用-草稿 - Info
  7147. /// </summary>
  7148. /// <returns></returns>
  7149. [HttpPost]
  7150. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  7151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7152. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  7153. {
  7154. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  7155. }
  7156. /// <summary>
  7157. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  7158. /// </summary>
  7159. /// <returns></returns>
  7160. [HttpPost]
  7161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7162. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  7163. {
  7164. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7165. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  7166. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  7167. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  7168. foreach (var userId in dto.UserIds)
  7169. {
  7170. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  7171. }
  7172. if (permissions.Any())
  7173. {
  7174. _sqlSugar.BeginTran();
  7175. try
  7176. {
  7177. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  7178. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  7179. if (result < 1)
  7180. {
  7181. _sqlSugar.RollbackTran();
  7182. return Ok(JsonView(false));
  7183. }
  7184. }
  7185. catch (Exception ex)
  7186. {
  7187. _sqlSugar.RollbackTran();
  7188. return Ok(JsonView(false, ex.Message));
  7189. }
  7190. _sqlSugar.CommitTran();
  7191. return Ok(JsonView(true));
  7192. }
  7193. return Ok(JsonView(false));
  7194. }
  7195. /// <summary>
  7196. /// 团组模块 - 出入境费用-草稿 - Add And Update
  7197. /// </summary>
  7198. /// <returns></returns>
  7199. [HttpPost]
  7200. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  7201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7202. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  7203. {
  7204. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  7205. if (data.Code != 0)
  7206. {
  7207. return Ok(JsonView(false, data.Msg));
  7208. }
  7209. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  7210. //汇率信息记录
  7211. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  7212. return Ok(JsonView(true, data.Msg, data.Data));
  7213. }
  7214. /// <summary>
  7215. /// 团组模块 - 出入境费用-草稿 - File downlaod
  7216. /// </summary>
  7217. /// <param name="dto"></param>
  7218. /// <returns></returns>
  7219. [HttpPost]
  7220. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  7221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7222. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  7223. {
  7224. try
  7225. {
  7226. var id = dto.Id;
  7227. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  7228. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  7229. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  7230. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  7231. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  7232. 3 团组成员名单 1 团组成员名单", ""));
  7233. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  7234. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  7235. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  7236. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  7237. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  7238. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  7239. //数据源
  7240. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  7241. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  7242. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  7243. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  7244. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  7245. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  7246. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  7247. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  7248. .Select((x, a, b) => new
  7249. {
  7250. x.Index,
  7251. itemName = a.Name,
  7252. CurrencyStr = b.Name,
  7253. x.Cost,
  7254. x.SubTotal,
  7255. x.Remark
  7256. })
  7257. .OrderBy((x) => x.Index)
  7258. .ToList(); //其他款项费用
  7259. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7260. var peiceItemCurrencys = new List<string>();
  7261. if (_DayAndCosts.Any())
  7262. {
  7263. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  7264. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  7265. }
  7266. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  7267. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  7268. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  7269. {
  7270. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  7271. }
  7272. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  7273. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  7274. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  7275. if (dto.ExportType == 1) //明细表
  7276. {
  7277. if (dto.SubTypeId == 1005) //1005(默认明细表)
  7278. {
  7279. //获取模板
  7280. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  7281. //载入模板
  7282. Document doc = new Document(tempPath);
  7283. DocumentBuilder builder = new DocumentBuilder(doc);
  7284. //利用键值对存放数据
  7285. Dictionary<string, string> dic = new Dictionary<string, string>();
  7286. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  7287. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  7288. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  7289. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  7290. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  7291. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  7292. //境内费用(其他费用)
  7293. if (_EnterExitCosts.ChoiceOne == 1)
  7294. {
  7295. string row1_1 = "";
  7296. if (_EnterExitCosts.Visa > 0)
  7297. {
  7298. //insidePayTotal += _EnterExitCosts.Visa;
  7299. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  7300. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  7301. {
  7302. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  7303. }
  7304. }
  7305. string row1_2 = "";
  7306. if (_EnterExitCosts.YiMiao > 0)
  7307. {
  7308. //insidePayTotal += _EnterExitCosts.YiMiao;
  7309. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  7310. }
  7311. if (_EnterExitCosts.HeSuan > 0)
  7312. {
  7313. //insidePayTotal += _EnterExitCosts.HeSuan;
  7314. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  7315. }
  7316. if (_EnterExitCosts.Service > 0)
  7317. {
  7318. //insidePayTotal += _EnterExitCosts.Service;
  7319. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  7320. }
  7321. string row1_3 = "";
  7322. if (_EnterExitCosts.Safe > 0)
  7323. {
  7324. //insidePayTotal += _EnterExitCosts.Safe;
  7325. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  7326. }
  7327. if (_EnterExitCosts.Ticket > 0)
  7328. {
  7329. //insidePayTotal += _EnterExitCosts.Ticket;
  7330. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  7331. }
  7332. string row1 = "";
  7333. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  7334. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  7335. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  7336. row1 += $"备注:{_EnterExitCosts.Remark}";
  7337. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  7338. dic.Add("Row1Str", row1);
  7339. }
  7340. string airTotalStr = string.Empty,
  7341. airPriceStr = string.Empty;
  7342. //经济舱
  7343. if (_EnterExitCosts.SumJJC == 1)
  7344. {
  7345. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  7346. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  7347. }
  7348. //公务舱
  7349. if (_EnterExitCosts.SumGWC == 1)
  7350. {
  7351. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  7352. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  7353. }
  7354. //头等舱
  7355. if (_EnterExitCosts.SumTDC == 1)
  7356. {
  7357. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  7358. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  7359. }
  7360. //汇率描述
  7361. string rateStr = "";
  7362. if (peiceItemCurrencyInfos.Any())
  7363. {
  7364. rateStr = "\r\n汇率描述:";
  7365. foreach (var item in peiceItemCurrencyInfos)
  7366. {
  7367. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  7368. }
  7369. }
  7370. string twoItemRemark = "备注:";
  7371. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7372. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7373. dic.Add("AirTotalStr", airTotalStr);
  7374. dic.Add("AirPriceStr", airPriceStr);
  7375. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7376. dic.Add("TwoItemRemark", twoItemRemark);
  7377. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7378. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7379. int table1Row = 0,
  7380. table2Row = 0,
  7381. table3Row = 0,
  7382. table4Row = 0,
  7383. table5Row = 0;
  7384. //住宿费
  7385. if (_EnterExitCosts.ChoiceThree == 1)
  7386. {
  7387. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  7388. table1Row = dac1.Count;
  7389. #region 填充word表格内容
  7390. for (int i = 0; i < dac1.Count; i++)
  7391. {
  7392. var dac = dac1[i];
  7393. if (dac == null) continue;
  7394. builder.MoveToCell(0, i, 0, 0);
  7395. builder.Write("第" + dac.Days.ToString() + "晚:");
  7396. builder.MoveToCell(0, i, 1, 0);
  7397. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  7398. //builder.Write(dac.Place == null ? "" : dac.Place);
  7399. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7400. builder.MoveToCell(0, i, 2, 0);
  7401. builder.Write("费用标准:");
  7402. string curr = "";
  7403. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7404. if (currData != null)
  7405. {
  7406. curr = currData.Name;
  7407. }
  7408. builder.MoveToCell(0, i, 3, 0);
  7409. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7410. builder.MoveToCell(0, i, 4, 0);
  7411. builder.Write("费用小计:");
  7412. builder.MoveToCell(0, i, 5, 0);
  7413. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7414. }
  7415. #endregion
  7416. }
  7417. else dic.Add("SubZS", "0.00");
  7418. //删除多余行
  7419. while (table1.Rows.Count > table1Row)
  7420. {
  7421. table1.Rows.RemoveAt(table1Row);
  7422. }
  7423. //伙食费
  7424. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7425. if (_EnterExitCosts.ChoiceFour == 1)
  7426. {
  7427. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7428. table2Row = dac2.Count;
  7429. #region 填充word表格内容
  7430. for (int i = 0; i < dac2.Count; i++)
  7431. {
  7432. var dac = dac2[i];
  7433. if (dac == null) continue;
  7434. builder.MoveToCell(1, i, 0, 0);
  7435. builder.Write("第" + dac.Days.ToString() + "天:");
  7436. builder.MoveToCell(1, i, 1, 0);
  7437. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7438. builder.MoveToCell(1, i, 2, 0);
  7439. builder.Write("费用标准:");
  7440. string curr = "";
  7441. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7442. if (currData != null)
  7443. {
  7444. curr = currData.Name;
  7445. }
  7446. builder.MoveToCell(1, i, 3, 0);
  7447. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7448. builder.MoveToCell(1, i, 4, 0);
  7449. builder.Write("费用小计:");
  7450. builder.MoveToCell(1, i, 5, 0);
  7451. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7452. }
  7453. #endregion
  7454. }
  7455. else dic.Add("SubHS", "0.00");
  7456. //删除多余行
  7457. while (table2.Rows.Count > table2Row)
  7458. {
  7459. table2.Rows.RemoveAt(table2Row);
  7460. }
  7461. //公杂费
  7462. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7463. if (_EnterExitCosts.ChoiceFive == 1)
  7464. {
  7465. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7466. table3Row = dac3.Count;
  7467. #region 填充word表格内容
  7468. for (int i = 0; i < dac3.Count; i++)
  7469. {
  7470. var dac = dac3[i];
  7471. if (dac == null) continue;
  7472. builder.MoveToCell(2, i, 0, 0);
  7473. builder.Write("第" + dac.Days.ToString() + "天:");
  7474. builder.MoveToCell(2, i, 1, 0);
  7475. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7476. builder.MoveToCell(2, i, 2, 0);
  7477. builder.Write("费用标准:");
  7478. string curr = "";
  7479. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7480. if (currData != null)
  7481. {
  7482. curr = currData.Name;
  7483. }
  7484. builder.MoveToCell(2, i, 3, 0);
  7485. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7486. builder.MoveToCell(2, i, 4, 0);
  7487. builder.Write("费用小计:");
  7488. builder.MoveToCell(2, i, 5, 0);
  7489. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7490. }
  7491. //删除多余行
  7492. while (table3.Rows.Count > table3Row)
  7493. {
  7494. table3.Rows.RemoveAt(table3Row);
  7495. }
  7496. #endregion
  7497. }
  7498. else dic.Add("SubGZF", "0.00");
  7499. //删除多余行
  7500. while (table3.Rows.Count > table3Row)
  7501. {
  7502. table3.Rows.RemoveAt(table3Row);
  7503. }
  7504. //培训费
  7505. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7506. if (_EnterExitCosts.ChoiceSix == 1)
  7507. {
  7508. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  7509. dic.Add("SubPX", pxStr);
  7510. table4Row = dac4.Count;
  7511. #region 填充word表格内容
  7512. for (int i = 0; i < dac4.Count; i++)
  7513. {
  7514. var dac = dac4[i];
  7515. if (dac == null) continue;
  7516. builder.MoveToCell(3, i, 0, 0);
  7517. builder.Write("第" + dac.Days.ToString() + "天:");
  7518. builder.MoveToCell(3, i, 1, 0);
  7519. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7520. builder.MoveToCell(3, i, 2, 0);
  7521. builder.Write("费用标准:");
  7522. string curr = "";
  7523. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7524. if (currData != null)
  7525. {
  7526. curr = currData.Name;
  7527. }
  7528. builder.MoveToCell(3, i, 3, 0);
  7529. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7530. builder.MoveToCell(3, i, 4, 0);
  7531. builder.Write("费用小计:");
  7532. builder.MoveToCell(3, i, 5, 0);
  7533. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7534. }
  7535. #endregion
  7536. }
  7537. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  7538. //删除多余行
  7539. while (table4.Rows.Count > table4Row)
  7540. {
  7541. table4.Rows.RemoveAt(table4Row);
  7542. }
  7543. //其他费用
  7544. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7545. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7546. {
  7547. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  7548. dic.Add("titleQi", qtStr);
  7549. table5Row = dac5.Count;
  7550. #region 填充word表格内容
  7551. for (int i = 0; i < dac5.Count; i++)
  7552. {
  7553. var dac = dac5[i];
  7554. if (dac == null) continue;
  7555. builder.MoveToCell(4, i, 0, 0);
  7556. builder.Write("第" + dac.Index.ToString() + "项:");
  7557. builder.MoveToCell(4, i, 1, 0);
  7558. builder.Write(dac.itemName);
  7559. builder.MoveToCell(4, i, 2, 0);
  7560. builder.Write("费用标准:");
  7561. builder.MoveToCell(4, i, 3, 0);
  7562. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7563. builder.MoveToCell(4, i, 4, 0);
  7564. builder.Write("费用小计:");
  7565. builder.MoveToCell(4, i, 5, 0);
  7566. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7567. builder.MoveToCell(4, i, 6, 0);
  7568. builder.Write("备注:");
  7569. builder.MoveToCell(4, i, 7, 0);
  7570. builder.Write(dac.Remark);
  7571. }
  7572. #endregion
  7573. }
  7574. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7575. //删除多余行
  7576. while (table5.Rows.Count > table5Row)
  7577. {
  7578. table5.Rows.RemoveAt(table5Row);
  7579. }
  7580. //加上其他费用
  7581. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7582. decimal subJJC = 0.00M,
  7583. subGWC = 0.00M,
  7584. subTDC = 0.00M;
  7585. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7586. string totalLabel = string.Format("全部费用总计:");
  7587. //经济舱
  7588. if (_EnterExitCosts.SumJJC == 1)
  7589. {
  7590. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7591. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  7592. }
  7593. //公务舱
  7594. if (_EnterExitCosts.SumGWC == 1)
  7595. {
  7596. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7597. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  7598. }
  7599. //头等舱
  7600. if (_EnterExitCosts.SumTDC == 1)
  7601. {
  7602. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7603. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  7604. }
  7605. //TotalLabel
  7606. dic.Add("TotalLabel", totalLabel);
  7607. #region 填充word模板书签内容
  7608. foreach (var key in dic.Keys)
  7609. {
  7610. Bookmark bookmark = doc.Range.Bookmarks[key];
  7611. if (bookmark != null)
  7612. {
  7613. builder.MoveToBookmark(key);
  7614. builder.Write(dic[key]);
  7615. }
  7616. }
  7617. #endregion
  7618. //文件名
  7619. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7620. strFileName = CommonFun.ValidFileName(strFileName);
  7621. AsposeHelper.removewatermark_v2180();
  7622. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7623. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7624. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7625. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7626. }
  7627. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7628. {
  7629. //获取模板
  7630. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7631. //载入模板
  7632. Document doc = new Document(tempPath);
  7633. DocumentBuilder builder = new DocumentBuilder(doc);
  7634. Dictionary<string, string> dic = new Dictionary<string, string>();
  7635. string returnCodeLabel = string.Empty;
  7636. if (nationalTravelFeeData.Any())
  7637. {
  7638. List<string> list = new List<string>();
  7639. foreach (var item in nationalTravelFeeData)
  7640. {
  7641. list.Add($"{item.Country}({item.City})");
  7642. }
  7643. list = list.Distinct().ToList();
  7644. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7645. }
  7646. var countryLabel = string.Empty;
  7647. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7648. if (countryData.Any())
  7649. {
  7650. countryLabel = string.Join("、", countryData);
  7651. }
  7652. dic.Add("ReturnCodeAir", returnCodeLabel);
  7653. dic.Add("VisitStartDate", "-");
  7654. dic.Add("VisitEndDate", "-");
  7655. dic.Add("Day", "-");
  7656. dic.Add("VisitCountry", countryLabel);
  7657. dic.Add("ClientUnit", "-");
  7658. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7659. //dic.Add("Names", Names);
  7660. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7661. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7662. decimal dac1totalPrice = 0.00M;
  7663. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7664. foreach (var dac in dac1)
  7665. {
  7666. if (dac.SubTotal == 0.00M)
  7667. {
  7668. continue;
  7669. }
  7670. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7671. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7672. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7673. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7674. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7675. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7676. builder.Write(currency);//币种
  7677. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7678. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7679. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7680. builder.Write("");//人数
  7681. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7682. builder.Write("");//天数
  7683. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7684. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7685. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7686. decimal rate = 0.00M;
  7687. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7688. builder.Write(rate.ToString("#0.0000"));//汇率
  7689. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7690. decimal rbmPrice = dac.SubTotal;
  7691. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7692. accommodationStartIndex++;
  7693. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7694. }
  7695. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7696. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7697. {
  7698. table1.Rows.RemoveAt(i - 1);
  7699. foodandotherStartIndex--;
  7700. }
  7701. if (dac2.Count == dac3.Count)//国家 币种 金额
  7702. {
  7703. for (int i = 0; i < dac2.Count; i++)
  7704. {
  7705. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7706. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7707. }
  7708. }
  7709. decimal dac2totalPrice = 0.00M;
  7710. foreach (var dac in dac2)
  7711. {
  7712. if (dac.SubTotal == 0)
  7713. {
  7714. continue;
  7715. }
  7716. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7717. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7718. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7719. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7720. builder.Write(currency);//币种
  7721. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7722. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7723. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7724. builder.Write("");//人数
  7725. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7726. builder.Write("");//天数
  7727. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7728. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7729. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7730. decimal rate = 0.00M;
  7731. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7732. builder.Write(rate.ToString("#0.0000"));//汇率
  7733. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7734. decimal rbmPrice = dac.SubTotal;
  7735. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7736. foodandotherStartIndex++;
  7737. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7738. }
  7739. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7740. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7741. {
  7742. table1.Rows.RemoveAt(i - 1);
  7743. }
  7744. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7745. string otherFeeStr = "";
  7746. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7747. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7748. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7749. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7750. foreach (var otherInfo in dac5)
  7751. {
  7752. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7753. }
  7754. #endregion
  7755. if (otherFeeStr.Length > 0)
  7756. {
  7757. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7758. otherFeeStr = $"({otherFeeStr})";
  7759. dic.Add("OtherFeeStr", otherFeeStr);
  7760. }
  7761. //总计
  7762. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7763. //国际旅费
  7764. string outsideAir = string.Empty;
  7765. string allPriceAir = string.Empty;
  7766. if (_EnterExitCosts.SumJJC == 1)
  7767. {
  7768. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7769. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7770. }
  7771. if (_EnterExitCosts.SumGWC == 1)
  7772. {
  7773. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7774. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7775. }
  7776. if (_EnterExitCosts.SumTDC == 1)
  7777. {
  7778. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7779. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7780. }
  7781. dic.Add("InTravelPrice", $"({outsideAir})");
  7782. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7783. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7784. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7785. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7786. foreach (var key in dic.Keys)
  7787. {
  7788. builder.MoveToBookmark(key);
  7789. builder.Write(dic[key]);
  7790. }
  7791. //模板文件名
  7792. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7793. strFileName = CommonFun.ValidFileName(strFileName);
  7794. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7795. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7796. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7797. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7798. }
  7799. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7800. {
  7801. //获取模板
  7802. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7803. //载入模板
  7804. WorkbookDesigner designer = new WorkbookDesigner();
  7805. designer.Workbook = new Workbook(tempPath);
  7806. Dictionary<string, string> dic = new Dictionary<string, string>();
  7807. string returnCodeLabel = string.Empty;
  7808. if (nationalTravelFeeData.Any())
  7809. {
  7810. List<string> list = new List<string>();
  7811. foreach (var item in nationalTravelFeeData)
  7812. {
  7813. list.Add($"{item.Country}({item.City})");
  7814. }
  7815. list = list.Distinct().ToList();
  7816. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7817. }
  7818. var countryLabel = string.Empty;
  7819. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7820. if (countryData.Any())
  7821. {
  7822. countryLabel = string.Join("、", countryData);
  7823. }
  7824. dic.Add("ReturnCodeAir", returnCodeLabel);
  7825. dic.Add("VisitStartDate", "-");
  7826. dic.Add("VisitEndDate", "-");
  7827. dic.Add("Day", "0");
  7828. dic.Add("VisitCountry", countryLabel);
  7829. dic.Add("ClientUnit", "-");
  7830. designer.SetDataSource("ClientUnit", "-");
  7831. designer.SetDataSource("VisitCountry", countryLabel);
  7832. designer.SetDataSource("Group", "-");
  7833. designer.SetDataSource("ClientUnitTitle", "-");
  7834. designer.SetDataSource("Name", "-");
  7835. designer.SetDataSource("VisitStartDate", "-");
  7836. designer.SetDataSource("Day", "0");
  7837. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7838. designer.SetDataSource("ReturnCodeAir", "-");
  7839. int startIndex = 10;
  7840. const int startIndexcopy = 10;
  7841. if (dac2.Count == dac3.Count)//国家 币种 金额
  7842. {
  7843. for (int i = 0; i < dac2.Count; i++)
  7844. {
  7845. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7846. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7847. }
  7848. }
  7849. DataTable dtdac1 = new DataTable();
  7850. List<string> place = new List<string>();
  7851. dtdac1.Columns.AddRange(new DataColumn[] {
  7852. new DataColumn(){ ColumnName = "city"},
  7853. new DataColumn(){ ColumnName = "curr"},
  7854. new DataColumn(){ ColumnName = "criterion"},
  7855. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7856. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7857. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7858. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7859. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7860. });
  7861. DataTable dtdac2 = new DataTable();
  7862. dtdac2.Columns.AddRange(new DataColumn[] {
  7863. new DataColumn(){ ColumnName = "city"},
  7864. new DataColumn(){ ColumnName = "curr"},
  7865. new DataColumn(){ ColumnName = "criterion"},
  7866. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7867. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7868. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7869. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7870. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7871. });
  7872. dtdac1.TableName = "tb1";
  7873. dtdac2.TableName = "tb2";
  7874. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7875. foreach (var item in dac1)
  7876. {
  7877. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7878. if (place.Contains(item.Place))
  7879. {
  7880. continue;
  7881. }
  7882. DataRow row = dtdac1.NewRow();
  7883. row["city"] = item.Place;
  7884. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7885. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7886. row["curr"] = currency;
  7887. row["rate"] = rate.ToString("#0.0000");
  7888. row["criterion"] = item.Cost.ToString("#0.00");
  7889. row["number"] = 1;
  7890. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7891. //row["costRMB"] = rbmPrice;
  7892. dtdac1.Rows.Add(row);
  7893. place.Add(item.Place);
  7894. }
  7895. place = new List<string>();
  7896. foreach (var item in dac2)
  7897. {
  7898. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7899. if (place.Contains(item.Place))
  7900. {
  7901. continue;
  7902. }
  7903. DataRow row = dtdac2.NewRow();
  7904. row["city"] = item.Place;
  7905. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7906. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7907. row["curr"] = currency;
  7908. row["rate"] = rate.ToString("#0.0000");
  7909. row["criterion"] = item.Cost.ToString("#0.00");
  7910. row["number"] = 1;
  7911. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7912. //row["cost"] = item.SubTotal;
  7913. //row["costRMB"] = rbmPrice;
  7914. dtdac2.Rows.Add(row);
  7915. place.Add(item.Place);
  7916. //dac2totalPrice += rbmPrice;
  7917. }
  7918. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7919. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7920. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7921. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7922. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7923. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7924. string cell4Str1 = string.Empty;
  7925. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7926. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7927. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7928. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7929. string cellStr = $" 5.其他费用(";
  7930. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7931. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7932. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7933. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7934. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7935. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7936. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7937. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7938. foreach (var otherInfo in dac5)
  7939. {
  7940. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7941. }
  7942. #endregion
  7943. if (cellStr.Length > 8)
  7944. {
  7945. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7946. }
  7947. cellStr += ")";
  7948. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7949. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7950. decimal pxFee = dac4.Sum(it => it.Cost);
  7951. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7952. string celllastStr1 = "";
  7953. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7954. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7955. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7956. celllastStr1 += $",国际旅费 元";
  7957. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7958. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7959. designer.SetDataSource("cell4Str", cell4Str);
  7960. designer.SetDataSource("cellStr", cellStr);
  7961. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7962. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7963. designer.SetDataSource("celllastStr", celllastStr);
  7964. Workbook wb = designer.Workbook;
  7965. var sheet = wb.Worksheets[0];
  7966. //绑定datatable数据集
  7967. designer.SetDataSource(dtdac1);
  7968. designer.SetDataSource(dtdac2);
  7969. designer.Process();
  7970. var rowStart = dtdac1.Rows.Count;
  7971. while (rowStart > 0)
  7972. {
  7973. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7974. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7975. startIndex++;
  7976. rowStart--;
  7977. }
  7978. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7979. startIndex += 1; //总计行
  7980. rowStart = dtdac2.Rows.Count;
  7981. while (rowStart > 0)
  7982. {
  7983. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7984. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7985. startIndex++;
  7986. rowStart--;
  7987. }
  7988. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7989. wb.CalculateFormula(true);
  7990. //模板文件名
  7991. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7992. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7993. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7994. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7995. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7996. }
  7997. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7998. {
  7999. //获取模板
  8000. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8001. //载入模板
  8002. Document doc = new Document(tempPath);
  8003. DocumentBuilder builder = new DocumentBuilder(doc);
  8004. Dictionary<string, string> dic = new Dictionary<string, string>();
  8005. dic.Add("GroupName", "-");
  8006. dic.Add("ClientUnit", "-");
  8007. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8008. //string missionLeaderJob = "";//负责人job
  8009. //int groupNumber = 0; //团人数
  8010. dic.Add("MissionLeader", "-"); //团负责人
  8011. dic.Add("MissionLeaderJob", "-"); //团负责人job
  8012. dic.Add("GroupNumber", "0"); //团人数
  8013. dic.Add("Day", "0");
  8014. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8015. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8016. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8017. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8018. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8019. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8020. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8021. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8022. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8023. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8024. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8025. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8026. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8027. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  8028. //其他费用
  8029. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8030. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8031. //其他费用合计
  8032. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8033. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  8034. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  8035. //公务舱合计
  8036. //国际旅费
  8037. //string outsideJJ = "";
  8038. //string allPriceJJ = "";
  8039. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8040. {
  8041. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8042. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8043. }
  8044. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8045. {
  8046. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  8047. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8048. }
  8049. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  8050. {
  8051. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  8052. dic.Add("AirFeeTotal", airFeeTotalStr);
  8053. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  8054. dic.Add("FeeTotal", feeTotalStr);
  8055. }
  8056. foreach (var key in dic.Keys)
  8057. {
  8058. builder.MoveToBookmark(key);
  8059. builder.Write(dic[key]);
  8060. }
  8061. //模板文件名
  8062. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  8063. strFileName = CommonFun.ValidFileName(strFileName);
  8064. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8065. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8066. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8067. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8068. }
  8069. }
  8070. else if (dto.ExportType == 2) //表格
  8071. {
  8072. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8073. }
  8074. else if (dto.ExportType == 3)
  8075. {
  8076. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  8077. }
  8078. return Ok(JsonView(400, "只可导出明细表!", ""));
  8079. }
  8080. catch (Exception ex)
  8081. {
  8082. return Ok(JsonView(400, ex.Message, ""));
  8083. }
  8084. }
  8085. /// <summary>
  8086. /// 获取三公费用标准city
  8087. /// </summary>
  8088. /// <param name="placeData"></param>
  8089. /// <param name="nationalTravelFeeId"></param>
  8090. /// <returns></returns>
  8091. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8092. {
  8093. string _city = string.Empty;
  8094. if (!placeData.Any()) return _city;
  8095. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8096. if (data == null) return _city;
  8097. string country = data.Country;
  8098. string city = data.City;
  8099. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8100. else _city = city;
  8101. return _city;
  8102. }
  8103. /// <summary>
  8104. /// 团组模块 - 出入境费用-草稿 - 一键清空
  8105. /// </summary>
  8106. /// <returns></returns>
  8107. [HttpPost]
  8108. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8110. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  8111. {
  8112. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8113. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8114. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  8115. if (_view.Code == 0)
  8116. {
  8117. return Ok(JsonView(true, "操作成功"));
  8118. }
  8119. return Ok(JsonView(false, "操作失败"));
  8120. }
  8121. /// <summary>
  8122. /// 团组模块 - 出入境费用-草稿 - 子项删除
  8123. /// </summary>
  8124. /// <returns></returns>
  8125. [HttpPost]
  8126. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8128. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  8129. {
  8130. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  8131. if (data.Code != 0)
  8132. {
  8133. return Ok(JsonView(false, data.Msg));
  8134. }
  8135. return Ok(JsonView(true, "操作成功!", data.Data));
  8136. }
  8137. /// <summary>
  8138. /// 三公其他费用草稿 删除
  8139. /// </summary>
  8140. /// <param name="dto"></param>
  8141. /// <returns></returns>
  8142. [HttpPost]
  8143. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  8144. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  8145. {
  8146. var jw = JsonView(false, "删除失败!");
  8147. var data = new Grp_DayOtherPriceDraft()
  8148. {
  8149. Id = dto.Id,
  8150. IsDel = 1,
  8151. DeleteUserId = dto.DeleteUserId,
  8152. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8153. };
  8154. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8155. if (del > 0)
  8156. {
  8157. jw.Code = 200;
  8158. jw.Msg = "删除成功!";
  8159. }
  8160. return Ok(jw);
  8161. }
  8162. /// <summary>
  8163. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  8164. /// </summary>
  8165. /// <returns></returns>
  8166. [HttpPost]
  8167. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  8168. {
  8169. var jw = JsonView(false);
  8170. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  8171. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  8172. jw.Code = StatusCodes.Status200OK;
  8173. jw.Msg = "操作成功!";
  8174. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  8175. return Ok(jw);
  8176. }
  8177. /// <summary>
  8178. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  8179. /// </summary>
  8180. /// <param name="dto"></param>
  8181. /// <returns></returns>
  8182. [HttpPost]
  8183. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  8184. {
  8185. int userId = dto.UserId,
  8186. portId = dto.PortType,
  8187. groupId = dto.GroupId,
  8188. draftId = dto.DraftId;
  8189. _portTypeData.Add(1);
  8190. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8191. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  8192. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  8193. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  8194. _sqlSugar.BeginTran();
  8195. try
  8196. {
  8197. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  8198. if (draftDatas == null)
  8199. {
  8200. _sqlSugar.RollbackTran();
  8201. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  8202. }
  8203. //验证可覆盖已有数据 两边创建人需为同一人;
  8204. int draftCreateUserId = draftDatas.CreateUserId,
  8205. formalCreateUserId = 0;
  8206. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8207. if (formalData != null)
  8208. {
  8209. formalCreateUserId = formalData.CreateUserId;
  8210. if (draftCreateUserId != formalCreateUserId)
  8211. {
  8212. _sqlSugar.RollbackTran();
  8213. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  8214. }
  8215. }
  8216. //默认添加查看、编辑权限(创建人、自己)
  8217. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  8218. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8219. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  8220. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  8221. newExterData.DiId = groupId;
  8222. newExterData.CreateUserId = userId;
  8223. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  8224. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  8225. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  8226. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  8227. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  8228. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  8229. //数据如果存在执行删除
  8230. if (enterExitCostInfo != null)
  8231. {
  8232. _sqlSugar.Updateable<Grp_EnterExitCost>()
  8233. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  8234. .Where(x => x.Id == enterExitCostInfo.Id)
  8235. .ExecuteCommand();
  8236. _sqlSugar.Updateable<Grp_DayAndCost>()
  8237. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8238. .Where(x => x.DiId == groupId)
  8239. .ExecuteCommand();
  8240. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8241. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8242. .Where(x => x.Diid == groupId)
  8243. .ExecuteCommand();
  8244. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  8245. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  8246. .Where(x => x.GroupId == groupId)
  8247. .ExecuteCommand();
  8248. }
  8249. //执行insert
  8250. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  8251. if (insertId < 1)
  8252. {
  8253. _sqlSugar.RollbackTran();
  8254. return Ok(JsonView(false, "草稿数据导入失败!"));
  8255. }
  8256. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  8257. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  8258. #region 默认添加权限
  8259. #endregion
  8260. _sqlSugar.CommitTran();
  8261. //执行操作之后
  8262. //生成默认文件pdf并且通知人员
  8263. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8264. {
  8265. DiId = groupId,
  8266. ExportType = 1,
  8267. SubTypeId = 1005
  8268. }, "pdf");
  8269. //发送通知
  8270. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8271. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  8272. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  8273. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  8274. //汇率信息记录
  8275. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  8276. return Ok(JsonView(true));
  8277. }
  8278. catch (Exception ex)
  8279. {
  8280. _sqlSugar.RollbackTran();
  8281. return Ok(JsonView(false, ex.Message));
  8282. }
  8283. }
  8284. #endregion
  8285. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  8286. /// <summary>
  8287. /// 获取币种基础数据(含逻辑处理)
  8288. /// </summary>
  8289. /// <returns></returns>
  8290. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  8291. {
  8292. return await GeneralMethod.EnterExitCostInitRate();
  8293. }
  8294. /// <summary>
  8295. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  8296. /// </summary>
  8297. /// <returns></returns>
  8298. [HttpPost]
  8299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8300. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  8301. {
  8302. //验证城市归属并给默认值
  8303. int provinceId = dto.ProvinceId;
  8304. if (provinceId < 1) provinceId = 122;
  8305. var dataSource = await _sqlSugar
  8306. .Queryable<Sys_SetData>()
  8307. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  8308. .ToListAsync();
  8309. var fileTypes = new List<EecSetDataInfoView>();
  8310. //三公费用-Word明细类型
  8311. var wordTypeData = dataSource
  8312. .Where(it => it.STid == 72)
  8313. .Select(x => new EecSetDataInfoView
  8314. {
  8315. ParentId = 1,
  8316. Id = x.Id,
  8317. Name = x.Name
  8318. })
  8319. .ToArray();
  8320. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  8321. var excelTypeData = dataSource
  8322. .Where(it => it.STid == 73)
  8323. .Select(x => new EecSetDataInfoView
  8324. {
  8325. ParentId = 2,
  8326. Id = x.Id,
  8327. Name = x.Name
  8328. })
  8329. .ToArray();
  8330. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  8331. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  8332. fileTypes.Add(groupNameList);
  8333. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  8334. //默认币种显示
  8335. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  8336. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  8337. return Ok(JsonView(true, "查询成功!", new
  8338. {
  8339. FileTypeData = fileTypes,
  8340. CurrencyInit = _currencyInfos,
  8341. viewPermissionData = viewPermissionData
  8342. }));
  8343. }
  8344. /// <summary>
  8345. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  8346. /// </summary>
  8347. /// <returns></returns>
  8348. [HttpPost]
  8349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8350. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  8351. {
  8352. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8353. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8354. RefAsync<int> total = 0;
  8355. int diId = 0;
  8356. var status = int.TryParse(dto.GroupName, out diId);
  8357. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  8358. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  8359. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  8360. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  8361. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  8362. .OrderByDescending(x => x.VisitStartDate)
  8363. .Select(x => new EnterExitCostMobileGroupView()
  8364. {
  8365. Id = x.Id,
  8366. GroupName = x.TeamName,
  8367. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  8368. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  8369. ProvinceId = x.CityId
  8370. })
  8371. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8372. //处理省份Id
  8373. if (data.Any())
  8374. {
  8375. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  8376. if (provCityDatas.Any())
  8377. {
  8378. foreach (var item in data)
  8379. {
  8380. var provinceId = item.ProvinceId;
  8381. var isDefualtVal = true;
  8382. if (provinceId > 0)
  8383. {
  8384. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  8385. if (parentId != null)
  8386. {
  8387. isDefualtVal = false;
  8388. item.ProvinceId = (int)parentId;
  8389. }
  8390. }
  8391. if (isDefualtVal)
  8392. {
  8393. item.ProvinceId = 122; //默认四川
  8394. }
  8395. }
  8396. }
  8397. }
  8398. //处理是否显示
  8399. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  8400. {
  8401. foreach (var item in data)
  8402. {
  8403. item.IsView = true;
  8404. }
  8405. }
  8406. return Ok(JsonView(true, "查询成功!", data, total));
  8407. }
  8408. /// <summary>
  8409. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  8410. /// </summary>
  8411. /// <returns></returns>
  8412. [HttpPost]
  8413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8414. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  8415. {
  8416. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8417. RefAsync<int> total = 0;
  8418. var data = await _sqlSugar.Queryable<Sys_SetData>()
  8419. .Where(x => x.IsDel == 0 && x.STid == 66)
  8420. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  8421. .Select(x => new
  8422. {
  8423. id = x.Id,
  8424. name = x.Name,
  8425. remark = x.Remark,
  8426. })
  8427. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8428. return Ok(JsonView(true, "查询成功!", data, total));
  8429. }
  8430. /// <summary>
  8431. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  8432. /// </summary>
  8433. /// <returns></returns>
  8434. [HttpPost]
  8435. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8436. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  8437. {
  8438. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8439. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8440. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  8441. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  8442. var groupOtherRateData = groupRateData.TeamRates;
  8443. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8444. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  8445. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  8446. groupOtherRateData = groupOtherRateData
  8447. .Select(x => new TeamRateDescAddCurrencyIdView
  8448. {
  8449. CurrencyId = x.CurrencyId,
  8450. CurrencyName = x.CurrencyName,
  8451. CurrencyCode = x.CurrencyCode,
  8452. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  8453. }).ToList();
  8454. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  8455. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  8456. }
  8457. /// <summary>
  8458. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  8459. /// </summary>
  8460. /// <returns></returns>
  8461. [HttpPost]
  8462. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8463. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  8464. {
  8465. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8466. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8467. var tipsData = new List<int>() { 1, 2, 3 };
  8468. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  8469. if (dto.TipsType == 1)
  8470. {
  8471. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  8472. }
  8473. else if (dto.TipsType == 2)
  8474. {
  8475. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  8476. return Ok(JsonView(true, "查询成功!", visaData.Data));
  8477. }
  8478. else if (dto.TipsType == 3)
  8479. {
  8480. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  8481. return Ok(JsonView(true, "查询成功!", airData.Data));
  8482. }
  8483. return Ok(JsonView(false));
  8484. }
  8485. /// <summary>
  8486. /// 团组模块 - 出入境国家费用标准-移动端 List
  8487. /// </summary>
  8488. /// <returns></returns>
  8489. [HttpPost]
  8490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8491. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  8492. {
  8493. Stopwatch sw = new Stopwatch();
  8494. sw.Start();
  8495. int provinceId = dto.ProvinceId;
  8496. if (provinceId < 1) provinceId = 122; // 默认四川
  8497. RefAsync<int> total = 0;
  8498. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8499. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  8500. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  8501. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  8502. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  8503. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  8504. .Select((ntf, sd, u, sd1) => new
  8505. {
  8506. Id = ntf.Id,
  8507. Area = $"{ntf.Country}-{ntf.City}",
  8508. Currency = ntf.Currency,
  8509. CurrencyCode = sd.Name,
  8510. CurrencyName = sd.Remark,
  8511. RoomCost = ntf.RoomCost,
  8512. FoodCost = ntf.FoodCost,
  8513. PublicCost = ntf.PublicCost,
  8514. TrainCost = ntf.TrainCost,
  8515. LastUpdateUserId = ntf.LastUpdateUserId,
  8516. LastUpdateUserName = u.CnName,
  8517. LastUpdateTime = ntf.LastUpdateTime
  8518. })
  8519. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8520. sw.Stop();
  8521. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  8522. }
  8523. /// <summary>
  8524. /// 团组模块 - 出入境费用-移动端 - Info
  8525. /// </summary>
  8526. /// <returns></returns>
  8527. [HttpPost]
  8528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8529. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  8530. {
  8531. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8532. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8533. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  8534. return Ok(data);
  8535. }
  8536. /// <summary>
  8537. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  8538. /// </summary>
  8539. /// <returns></returns>
  8540. [HttpPost]
  8541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8542. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8543. {
  8544. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8545. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8546. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8547. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8548. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8549. mobileInfo.DiId = dto.DiId;
  8550. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8551. if (eecInfo == null) return Ok(mobileInfo);
  8552. //验证查看权限
  8553. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  8554. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  8555. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8556. mobileInfo.IsAssignPerm = isSet;
  8557. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8558. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8559. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8560. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8561. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8562. {
  8563. SubId = dac.Id,
  8564. DiId = dac.DiId,
  8565. Type = dac.Type,
  8566. Days = dac.Days,
  8567. NationalTravelFeeId = dac.NationalTravelFeeId,
  8568. Arae = $"{ntf.Country}-{ntf.City}",
  8569. Cost = dac.Cost,
  8570. Currency = dac.Currency,
  8571. CurrencyName = sd.Name,
  8572. SubTotal = dac.SubTotal,
  8573. })
  8574. .ToList();
  8575. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8576. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8577. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8578. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8579. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8580. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8581. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8582. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8583. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8584. //其他款项
  8585. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8586. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8587. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8588. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8589. .OrderBy((dop, sd1, sd2) => dop.Index)
  8590. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8591. {
  8592. SubId = dop.Id,
  8593. DiId = dop.Diid,
  8594. Index = dop.Index,
  8595. SetDataId = dop.SetDataId,
  8596. SetDataName = sd1.Name,
  8597. Cost = dop.Cost,
  8598. Currency = dop.Currency,
  8599. CurrencyName = sd2.Remark,
  8600. SubTotal = dop.SubTotal,
  8601. Remark = dop.Remark,
  8602. })
  8603. .ToArray();
  8604. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8605. return Ok(mobileInfo);
  8606. }
  8607. /// <summary>
  8608. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8609. /// </summary>
  8610. /// <returns></returns>
  8611. [HttpPost]
  8612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8613. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8614. {
  8615. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8616. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8617. //验证查看权限
  8618. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  8619. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  8620. var userIds = await _sqlSugar
  8621. .Queryable<Grp_EnterExitCostPermission>()
  8622. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8623. .Select(x => x.UserId)
  8624. .ToArrayAsync();
  8625. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  8626. var perUsersView = new List<dynamic>();
  8627. foreach (var item in perUsers)
  8628. {
  8629. bool isView1 = false;
  8630. if (userIds.Any(x => x == item.Id)) isView1 = true;
  8631. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  8632. }
  8633. return Ok(JsonView(perUsersView));
  8634. }
  8635. /// <summary>
  8636. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8637. /// </summary>
  8638. /// <returns></returns>
  8639. [HttpPost]
  8640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8641. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8642. {
  8643. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8644. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8645. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8646. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8647. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8648. //验证查看权限
  8649. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8650. //if (!isView) return Ok(JsonView(false, msg));
  8651. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8652. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8653. var subType = dto.SubType;
  8654. if (subType == 1) //1:境内费用
  8655. {
  8656. var oneData = new ChoiceOneMobileSubInfoView()
  8657. {
  8658. Id = eecInfo.Id,
  8659. ChoiceOne = eecInfo.ChoiceOne,
  8660. ChoiceOneTotalCost = eecInfo.InsidePay,
  8661. Visa = eecInfo.Visa,
  8662. VisaRemark = eecInfo.VisaRemark,
  8663. YiMiao = eecInfo.YiMiao,
  8664. HeSuan = eecInfo.HeSuan,
  8665. Service = eecInfo.Service,
  8666. Ticket = eecInfo.Ticket,
  8667. Safe = eecInfo.Safe,
  8668. FirstItemRemark = eecInfo.FirstItemRemark
  8669. };
  8670. return Ok(JsonView(oneData));
  8671. }
  8672. else if (subType == 2) //2:国际旅费
  8673. {
  8674. var twoData = new ChoiceTwoMobileSubInfoView()
  8675. {
  8676. Id = eecInfo.Id,
  8677. ChoiceTwoJJ = eecInfo.SumJJC,
  8678. OutsideJJPay = eecInfo.OutsideJJPay,
  8679. ChoiceTwoGW = eecInfo.SumGWC,
  8680. OutsideGWPay = eecInfo.OutsideGWPay,
  8681. ChoiceTwoTD = eecInfo.SumTDC,
  8682. OutsideTDPay = eecInfo.OutsideTDPay,
  8683. AirJJ = eecInfo.AirJJ,
  8684. AirGW = eecInfo.AirGW,
  8685. AirTD = eecInfo.AirTD,
  8686. CityTranffic = eecInfo.CityTranffic,
  8687. TwoItemRemark = eecInfo.TwoItemRemark
  8688. };
  8689. return Ok(JsonView(twoData));
  8690. }
  8691. else if (subType == 3) //3:住宿费
  8692. {
  8693. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8694. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8695. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8696. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8697. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8698. {
  8699. SubId = dac.Id,
  8700. DiId = dac.DiId,
  8701. Type = dac.Type,
  8702. Days = dac.Days,
  8703. NationalTravelFeeId = dac.NationalTravelFeeId,
  8704. Arae = $"{ntf.Country}-{ntf.City}",
  8705. Cost = dac.Cost,
  8706. Currency = dac.Currency,
  8707. CurrencyName = sd.Name,
  8708. SubTotal = dac.SubTotal,
  8709. })
  8710. .ToArray();
  8711. var data = new ChoiceMobileSubInfo3To6View()
  8712. {
  8713. ParentId = eecInfo.Id,
  8714. Choice = eecInfo.ChoiceThree,
  8715. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8716. Details = dayAndCostDatas
  8717. };
  8718. return Ok(JsonView(data));
  8719. }
  8720. else if (subType == 4) //4:伙食费
  8721. {
  8722. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8723. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8724. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8725. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8726. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8727. {
  8728. SubId = dac.Id,
  8729. DiId = dac.DiId,
  8730. Type = dac.Type,
  8731. Days = dac.Days,
  8732. NationalTravelFeeId = dac.NationalTravelFeeId,
  8733. Arae = $"{ntf.Country}-{ntf.City}",
  8734. Cost = dac.Cost,
  8735. Currency = dac.Currency,
  8736. CurrencyName = sd.Name,
  8737. SubTotal = dac.SubTotal,
  8738. })
  8739. .ToArray();
  8740. var data = new ChoiceMobileSubInfo3To6View()
  8741. {
  8742. ParentId = eecInfo.Id,
  8743. Choice = eecInfo.ChoiceFour,
  8744. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8745. Details = dayAndCostDatas
  8746. };
  8747. return Ok(JsonView(data));
  8748. }
  8749. else if (subType == 5) //5:公杂费
  8750. {
  8751. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8752. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8753. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8754. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8755. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8756. {
  8757. SubId = dac.Id,
  8758. DiId = dac.DiId,
  8759. Type = dac.Type,
  8760. Days = dac.Days,
  8761. NationalTravelFeeId = dac.NationalTravelFeeId,
  8762. Arae = $"{ntf.Country}-{ntf.City}",
  8763. Cost = dac.Cost,
  8764. Currency = dac.Currency,
  8765. CurrencyName = sd.Name,
  8766. SubTotal = dac.SubTotal,
  8767. })
  8768. .ToArray();
  8769. var data = new ChoiceMobileSubInfo3To6View()
  8770. {
  8771. ParentId = eecInfo.Id,
  8772. Choice = eecInfo.ChoiceFive,
  8773. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8774. Details = dayAndCostDatas
  8775. };
  8776. return Ok(JsonView(data));
  8777. }
  8778. else if (subType == 6) //6:培训费
  8779. {
  8780. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8781. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8782. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8783. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8784. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8785. {
  8786. SubId = dac.Id,
  8787. DiId = dac.DiId,
  8788. Type = dac.Type,
  8789. Days = dac.Days,
  8790. NationalTravelFeeId = dac.NationalTravelFeeId,
  8791. Arae = $"{ntf.Country}-{ntf.City}",
  8792. Cost = dac.Cost,
  8793. Currency = dac.Currency,
  8794. CurrencyName = sd.Name,
  8795. SubTotal = dac.SubTotal,
  8796. })
  8797. .ToArray();
  8798. var data = new ChoiceMobileSubInfo3To6View()
  8799. {
  8800. ParentId = eecInfo.Id,
  8801. Choice = eecInfo.ChoiceSix,
  8802. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8803. Details = dayAndCostDatas
  8804. };
  8805. return Ok(JsonView(data));
  8806. }
  8807. else if (subType == 7) //7:其他
  8808. {
  8809. //其他款项
  8810. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8811. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8812. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8813. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8814. .OrderBy((dop, sd1, sd2) => dop.Index)
  8815. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8816. {
  8817. SubId = dop.Id,
  8818. DiId = dop.Diid,
  8819. Index = dop.Index,
  8820. SetDataId = dop.SetDataId,
  8821. SetDataName = sd1.Name,
  8822. Cost = dop.Cost,
  8823. Currency = dop.Currency,
  8824. CurrencyName = sd2.Name,
  8825. SubTotal = dop.SubTotal,
  8826. Remark = dop.Remark,
  8827. })
  8828. .ToArray();
  8829. var data = new ChoiceSevenMobileSubInfoView()
  8830. {
  8831. ParentId = eecInfo.Id,
  8832. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8833. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8834. Details = otherData
  8835. };
  8836. return Ok(JsonView(data));
  8837. }
  8838. return Ok(JsonView(false));
  8839. }
  8840. #region op
  8841. /// <summary>
  8842. /// 移动端更新费用消息通知
  8843. /// </summary>
  8844. /// <param name="diid"></param>
  8845. /// <param name="id"></param>
  8846. /// <param name="currUserId"></param>
  8847. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8848. {
  8849. try
  8850. {
  8851. ////生成默认文件pdf并且通知人员
  8852. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8853. //{
  8854. // DiId = diid,
  8855. // ExportType = 1,
  8856. // SubTypeId = 1005
  8857. //}, "pdf");
  8858. ////发送通知
  8859. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8860. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8861. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8862. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8863. ////汇率信息记录
  8864. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8865. }
  8866. catch (Exception ex)
  8867. {
  8868. //记录日志
  8869. throw;
  8870. }
  8871. }
  8872. /// <summary>
  8873. /// 验证出入境费用数据是否存在
  8874. /// 不存在添加
  8875. /// </summary>
  8876. /// <param name="diId"></param>
  8877. /// <param name="currUserId"></param>
  8878. /// <returns></returns>
  8879. /// <exception cref="CustomException"></exception>
  8880. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8881. {
  8882. var parentId = 0;
  8883. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8884. if (info != null)
  8885. {
  8886. parentId = info.Id;
  8887. }
  8888. else
  8889. {
  8890. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8891. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8892. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8893. parentId = addId;
  8894. }
  8895. return parentId;
  8896. }
  8897. /// <summary>
  8898. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8899. /// </summary>
  8900. /// <returns></returns>
  8901. [HttpPost]
  8902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8903. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8904. {
  8905. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8906. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8907. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8908. //验证编辑权限
  8909. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8910. //if (!isEdit) return Ok(JsonView(false, msg));
  8911. var permissions = new List<Grp_EnterExitCostPermission>();
  8912. foreach (var userId in dto.UserIds)
  8913. {
  8914. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8915. }
  8916. if (permissions.Any())
  8917. {
  8918. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  8919. {
  8920. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  8921. }
  8922. _sqlSugar.BeginTran();
  8923. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8924. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8925. if (result < 1)
  8926. {
  8927. _sqlSugar.RollbackTran();
  8928. return Ok(JsonView(false));
  8929. }
  8930. _sqlSugar.CommitTran();
  8931. return Ok(JsonView(true));
  8932. }
  8933. return Ok(JsonView(false));
  8934. }
  8935. /// <summary>
  8936. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8937. /// </summary>
  8938. /// <returns></returns>
  8939. [HttpPost]
  8940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8941. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8942. {
  8943. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8944. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8945. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8946. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8947. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8948. int id = dto.Id;
  8949. if (id <= 0) //add
  8950. {
  8951. //int provinceId = dto.ProvinceId;
  8952. int groupId = dto.DiId;
  8953. //if (provinceId < 1) provinceId = 122;
  8954. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  8955. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  8956. if (add < 1) return Ok(JsonView(false));
  8957. id = add;
  8958. }
  8959. else //update
  8960. {
  8961. ////验证编辑权限
  8962. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8963. //if (!isEdit) return Ok(JsonView(false, msg));
  8964. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8965. if (upd < 1) return Ok(JsonView(false));
  8966. }
  8967. #region 汇率变更时更改币种相关费用
  8968. var opDayCosts = new List<Grp_DayAndCost>();
  8969. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8970. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8971. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8972. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  8973. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8974. .Select((dac, sd) => new
  8975. {
  8976. dac.Id,
  8977. dac.DiId,
  8978. CurrencyCode = sd.Name,
  8979. dac.Cost
  8980. })
  8981. .ToList();
  8982. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8983. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8984. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8985. .Select((dop, sd) => new
  8986. {
  8987. dop.Id,
  8988. dop.Diid,
  8989. CurrencyCode = sd.Name,
  8990. dop.Cost
  8991. })
  8992. .ToList();
  8993. if (dayCosts.Count > 0)
  8994. {
  8995. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8996. foreach (var dc in new_dayCosts)
  8997. {
  8998. var thisCurrency = dc.Key.ToUpper();
  8999. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9000. if (thisRate == 0.00M) continue;
  9001. foreach (var dcSub in dc)
  9002. {
  9003. opDayCosts.Add(new Grp_DayAndCost()
  9004. {
  9005. Id = dcSub.Id,
  9006. DiId = dcSub.DiId,
  9007. Cost = dcSub.Cost,
  9008. SubTotal = dcSub.Cost * thisRate,
  9009. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9010. });
  9011. }
  9012. }
  9013. if (opDayCosts.Count > 0)
  9014. {
  9015. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9016. }
  9017. }
  9018. if (dayOtherCosts.Count > 0)
  9019. {
  9020. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9021. foreach (var dc in new_dayOtherCosts)
  9022. {
  9023. var thisCurrency = dc.Key.ToUpper();
  9024. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9025. if (thisRate == 0.00M) continue;
  9026. foreach (var dcSub in dc)
  9027. {
  9028. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  9029. {
  9030. Id = dcSub.Id,
  9031. Diid = dcSub.Diid,
  9032. Cost = dcSub.Cost,
  9033. SubTotal = dcSub.Cost * thisRate,
  9034. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9035. });
  9036. }
  9037. }
  9038. if (opDayOtherCosts.Count > 0)
  9039. {
  9040. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9041. }
  9042. }
  9043. #endregion
  9044. //消息通知
  9045. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9046. //汇率信息记录
  9047. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9048. return Ok(JsonView(new { parentId = id }));
  9049. }
  9050. /// <summary>
  9051. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  9052. /// </summary>
  9053. /// <returns></returns>
  9054. [HttpPost]
  9055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9056. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  9057. {
  9058. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9059. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9060. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9061. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9062. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  9063. int id = dto.Id;
  9064. if (id <= 0) //add
  9065. {
  9066. checkboxInfo.CreateUserId = dto.CurrUserId;
  9067. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9068. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9069. if (add < 1) return Ok(JsonView(false));
  9070. }
  9071. else //update
  9072. {
  9073. ////验证编辑权限
  9074. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9075. //if (!isEdit) return Ok(JsonView(false, msg));
  9076. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9077. .UpdateColumns(x => new
  9078. {
  9079. x.ChoiceOne,
  9080. x.ChoiceTwo,
  9081. x.SumJJC,
  9082. x.SumGWC,
  9083. x.SumTDC,
  9084. x.ChoiceThree,
  9085. x.ChoiceFour,
  9086. x.ChoiceFive,
  9087. x.ChoiceSix,
  9088. x.OtherExpenses_Checked
  9089. })
  9090. .Where(x => x.Id == id)
  9091. .ExecuteCommandAsync();
  9092. if (upd < 1) return Ok(JsonView(false));
  9093. }
  9094. return Ok(JsonView(new { parentId = id }));
  9095. }
  9096. /// <summary>
  9097. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  9098. /// </summary>
  9099. /// <returns></returns>
  9100. [HttpPost]
  9101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9102. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  9103. {
  9104. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  9105. // if (provinceId < 1) provinceId = 122;
  9106. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9107. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9108. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9109. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9110. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9111. var checkboxInfo = new Grp_EnterExitCost()
  9112. {
  9113. Id = id,
  9114. //ProvinceId = provinceId,
  9115. DiId = diId,
  9116. CreateUserId = currUserId
  9117. };
  9118. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9119. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9120. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9121. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9122. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9123. if (id <= 0) //add
  9124. {
  9125. checkboxInfo.CreateUserId = dto.CurrUserId;
  9126. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9127. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9128. if (add < 1) return Ok(JsonView(false));
  9129. }
  9130. else //update
  9131. {
  9132. ////验证编辑权限
  9133. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9134. //if (!isEdit) return Ok(JsonView(false, msg));
  9135. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  9136. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9137. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9138. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9139. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9140. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9141. .Where(x => x.Id == id)
  9142. .ExecuteCommandAsync();
  9143. if (upd < 1) return Ok(JsonView(false));
  9144. }
  9145. return Ok(JsonView(new { parentId = id }));
  9146. }
  9147. /// <summary>
  9148. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  9149. /// </summary>
  9150. /// <returns></returns>
  9151. [HttpPost]
  9152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9153. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  9154. {
  9155. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9156. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9157. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9158. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9159. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9160. info.FirstItemRemark = dto.FirstItemRemark;
  9161. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9162. int id = dto.Id;
  9163. if (id <= 0) //add
  9164. {
  9165. info.CreateUserId = dto.CurrUserId;
  9166. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9167. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9168. if (add < 1) return Ok(JsonView(false));
  9169. id = add;
  9170. }
  9171. else //update
  9172. {
  9173. ////验证编辑权限
  9174. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9175. //if (!isEdit) return Ok(JsonView(false, msg));
  9176. var upd = await _sqlSugar.Updateable(info)
  9177. .UpdateColumns(x => new
  9178. {
  9179. x.ChoiceOne,
  9180. x.InsidePay,
  9181. x.VisaRemark,
  9182. x.Visa,
  9183. x.Service,
  9184. x.Safe,
  9185. x.Ticket,
  9186. x.HeSuan,
  9187. x.YiMiao,
  9188. x.FirstItemRemark
  9189. })
  9190. .Where(x => x.Id == id)
  9191. .ExecuteCommandAsync();
  9192. if (upd < 1) return Ok(JsonView(false));
  9193. }
  9194. //消息通知
  9195. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9196. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9197. }
  9198. /// <summary>
  9199. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  9200. /// </summary>
  9201. /// <returns></returns>
  9202. [HttpPost]
  9203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9204. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  9205. {
  9206. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9207. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9208. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9209. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9210. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9211. info.DiId = dto.DiId;
  9212. //info.ProvinceId = dto.ProvinceId;
  9213. info.OutsideJJPay = dto.OutsideJJPay;
  9214. info.OutsideGWPay = dto.OutsideGWPay;
  9215. info.OutsideTDPay = dto.OutsideTDPay;
  9216. info.AirJJ = dto.AirJJ;
  9217. info.AirGW = dto.AirGW;
  9218. info.AirTD = dto.AirTD;
  9219. info.CityTranffic = dto.CityTranffic;
  9220. info.TwoItemRemark = dto.TwoItemRemark;
  9221. info.SumJJC = dto.ChoiceTwoJJ;
  9222. info.SumGWC = dto.ChoiceTwoGW;
  9223. info.SumTDC = dto.ChoiceTwoTD;
  9224. int id = dto.Id;
  9225. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9226. if (id <= 0) //add
  9227. {
  9228. info.CreateUserId = dto.CurrUserId;
  9229. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9230. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9231. if (addId <= 0) return Ok(JsonView(false));
  9232. id = addId;
  9233. }
  9234. else //update
  9235. {
  9236. ////验证编辑权限
  9237. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9238. //if (!isEdit) return Ok(JsonView(false, msg));
  9239. var upd = await _sqlSugar.Updateable(info)
  9240. .UpdateColumns(x => new
  9241. {
  9242. x.SumJJC,
  9243. x.OutsideJJPay,
  9244. x.SumGWC,
  9245. x.OutsideGWPay,
  9246. x.SumTDC,
  9247. x.OutsideTDPay,
  9248. x.AirJJ,
  9249. x.AirGW,
  9250. x.AirTD,
  9251. x.CityTranffic,
  9252. x.TwoItemRemark
  9253. })
  9254. .Where(x => x.Id == id)
  9255. .ExecuteCommandAsync();
  9256. if (upd < 1) return Ok(JsonView(false));
  9257. }
  9258. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9259. gwcItemTotal = info.AirGW + info.CityTranffic;
  9260. tdcItemTotal = info.AirTD + info.CityTranffic;
  9261. //消息通知
  9262. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9263. return Ok(JsonView(new
  9264. {
  9265. parentId = id,
  9266. choiceTwoJJ = dto.ChoiceTwoJJ,
  9267. jjcItemTotal = jjcItemTotal,
  9268. choiceTwoGW = dto.ChoiceTwoGW,
  9269. gwcItemTotal = gwcItemTotal,
  9270. choiceTwoTD = dto.ChoiceTwoTD,
  9271. tdcItemTotal = tdcItemTotal
  9272. }));
  9273. }
  9274. /// <summary>
  9275. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9276. /// </summary>
  9277. /// <returns></returns>
  9278. [HttpPost]
  9279. [ApiExplorerSettings(IgnoreApi = true)]
  9280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9281. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  9282. {
  9283. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9284. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9285. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9286. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9287. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9288. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9289. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  9290. var infos = infos1.Select(x => new Grp_DayAndCost
  9291. {
  9292. Id = x.Id,
  9293. DiId = dto.DiId,
  9294. Type = dto.FeeType,
  9295. Days = x.Days,
  9296. NationalTravelFeeId = x.NationalTravelFeeId,
  9297. Cost = x.Cost,
  9298. Currency = x.Currency,
  9299. SubTotal = x.SubTotal,
  9300. CreateUserId = dto.CurrUserId
  9301. })
  9302. .ToList();
  9303. var adds = infos.Where(x => x.Id <= 0).ToList();
  9304. var upds = infos.Where(x => x.Id > 0).ToList();
  9305. if (adds.Count > 0)
  9306. {
  9307. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9308. if (add < 1) return Ok(JsonView(false));
  9309. }
  9310. if (upds.Count > 0)
  9311. {
  9312. var upd = await _sqlSugar.Updateable(adds)
  9313. .UpdateColumns(x => new
  9314. {
  9315. x.Days,
  9316. x.NationalTravelFeeId,
  9317. x.Cost,
  9318. x.Currency,
  9319. x.SubTotal
  9320. })
  9321. .WhereColumns(x => new { x.Id })
  9322. .ExecuteCommandAsync();
  9323. if (upd < 1) return Ok(JsonView(false));
  9324. }
  9325. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9326. //消息通知
  9327. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  9328. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9329. return Ok(JsonView(new { itemTotal = itemTotal }));
  9330. }
  9331. /// <summary>
  9332. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9333. /// </summary>
  9334. /// <returns></returns>
  9335. [HttpPost]
  9336. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9337. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  9338. {
  9339. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9340. int subId = dto.SubId, feeType = dto.FeeType;
  9341. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9342. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9343. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9344. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9345. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  9346. subInfo.Id = subId;
  9347. subInfo.DiId = dto.DiId;
  9348. if (feeType == 3) subInfo.Type = 1;
  9349. else if (feeType == 4) subInfo.Type = 2;
  9350. else if (feeType == 5) subInfo.Type = 3;
  9351. else if (feeType == 6) subInfo.Type = 4;
  9352. subInfo.CreateUserId = dto.CurrUserId;
  9353. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  9354. if (parentId < 1) return Ok(JsonView(false));
  9355. //子表op
  9356. if (subId < 1)
  9357. {
  9358. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9359. if (subAdd < 1) return Ok(JsonView(false));
  9360. }
  9361. else
  9362. {
  9363. ////验证编辑权限
  9364. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9365. //if (!isEdit) return Ok(JsonView(false, msg));
  9366. var subUpd = await _sqlSugar.Updateable(subInfo)
  9367. .UpdateColumns(x => new
  9368. {
  9369. x.Days,
  9370. x.NationalTravelFeeId,
  9371. x.Cost,
  9372. x.Currency,
  9373. x.SubTotal
  9374. })
  9375. .WhereColumns(x => new { x.Id })
  9376. .ExecuteCommandAsync();
  9377. if (subUpd < 1) return Ok(JsonView(false));
  9378. }
  9379. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  9380. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  9381. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9382. }
  9383. /// <summary>
  9384. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  9385. /// </summary>
  9386. /// <returns></returns>
  9387. [HttpPost]
  9388. [ApiExplorerSettings(IgnoreApi = true)]
  9389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9390. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  9391. {
  9392. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9393. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9394. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9395. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  9396. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  9397. {
  9398. Id = x.Id,
  9399. Diid = dto.DiId,
  9400. SetDataId = x.SetDataId,
  9401. Index = x.Index,
  9402. Cost = x.Cost,
  9403. Currency = x.Currency,
  9404. SubTotal = x.SubTotal,
  9405. CreateUserId = dto.CurrUserId,
  9406. Remark = x.Remark
  9407. }).ToList();
  9408. var adds = infos.Where(x => x.Id <= 0).ToList();
  9409. var upds = infos.Where(x => x.Id > 0).ToList();
  9410. if (adds.Count > 0)
  9411. {
  9412. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9413. if (add < 1) return Ok(JsonView(false));
  9414. }
  9415. if (upds.Count > 0)
  9416. {
  9417. var upd = await _sqlSugar.Updateable(adds)
  9418. .UpdateColumns(x => new
  9419. {
  9420. x.Index,
  9421. x.SetDataId,
  9422. x.Cost,
  9423. x.Currency,
  9424. x.SubTotal,
  9425. x.Remark
  9426. })
  9427. .WhereColumns(x => new { x.Id })
  9428. .ExecuteCommandAsync();
  9429. if (upd < 1) return Ok(JsonView(false));
  9430. }
  9431. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  9432. //消息通知
  9433. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  9434. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9435. return Ok(JsonView(new { itemTotal = itemTotal }));
  9436. }
  9437. /// <summary>
  9438. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  9439. /// </summary>
  9440. /// <returns></returns>
  9441. [HttpPost]
  9442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9443. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  9444. {
  9445. int subId = dto.SubId;
  9446. int diId = dto.Diid;
  9447. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9448. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9449. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9450. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  9451. subInfo.Id = subId;
  9452. subInfo.Diid = dto.Diid;
  9453. subInfo.CreateUserId = dto.CurrUserId;
  9454. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  9455. if (parentId < 1) return Ok(JsonView(false));
  9456. #region 子表op
  9457. if (subId < 1)//add
  9458. {
  9459. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9460. if (subAdd < 1) return Ok(JsonView(false));
  9461. }
  9462. else //upd
  9463. {
  9464. ////验证编辑权限
  9465. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  9466. //if (!isEdit) return Ok(JsonView(false, msg));
  9467. var subUpd = await _sqlSugar.Updateable(subInfo)
  9468. .UpdateColumns(x => new
  9469. {
  9470. x.Index,
  9471. x.SetDataId,
  9472. x.Cost,
  9473. x.Currency,
  9474. x.SubTotal,
  9475. x.Remark
  9476. })
  9477. .WhereColumns(x => new { x.Id })
  9478. .ExecuteCommandAsync();
  9479. if (subUpd < 1) return Ok(JsonView(false));
  9480. }
  9481. #endregion
  9482. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  9483. //消息通知
  9484. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  9485. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9486. }
  9487. /// <summary>
  9488. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  9489. /// </summary>
  9490. /// <returns></returns>
  9491. [HttpPost]
  9492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9493. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  9494. {
  9495. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  9496. if (data.Code != 0)
  9497. {
  9498. return Ok(JsonView(false, data.Msg));
  9499. }
  9500. return Ok(JsonView(true, "操作成功!", data.Data));
  9501. }
  9502. /// <summary>
  9503. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  9504. /// </summary>
  9505. /// <param name="dto"></param>
  9506. /// <returns></returns>
  9507. [HttpPost]
  9508. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  9509. {
  9510. var data = new Grp_DayOtherPrice()
  9511. {
  9512. Id = dto.Id,
  9513. IsDel = 1,
  9514. DeleteUserId = dto.DeleteUserId,
  9515. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9516. };
  9517. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9518. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  9519. return Ok(JsonView(false, "删除失败!"));
  9520. }
  9521. #endregion
  9522. #endregion
  9523. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  9524. /// <summary>
  9525. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  9526. /// </summary>
  9527. /// <returns></returns>
  9528. [HttpGet]
  9529. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9530. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  9531. {
  9532. var provData = await _groupRepository.ProvinceBasicSource();
  9533. return Ok(JsonView(true, "查询成功!", provData));
  9534. }
  9535. /// <summary>
  9536. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  9537. /// </summary>
  9538. /// <returns></returns>
  9539. [HttpPost]
  9540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9541. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  9542. {
  9543. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9544. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9545. RefAsync<int> total = 0;
  9546. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  9547. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  9548. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  9549. .Select(x => new
  9550. {
  9551. Id = x.Id,
  9552. DraftName = x.DraftName,
  9553. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  9554. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  9555. .Any()
  9556. })
  9557. .OrderByDescending(x => x.Id)
  9558. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9559. return Ok(JsonView(true, "查询成功!", data, total));
  9560. }
  9561. /// <summary>
  9562. /// 出入境费用-草稿 移动端
  9563. /// 获取币种基础数据(含逻辑处理)
  9564. /// </summary>
  9565. /// <returns></returns>
  9566. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  9567. {
  9568. return await GeneralMethod.EnterExitCostInitRate();
  9569. }
  9570. /// <summary>
  9571. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9572. /// </summary>
  9573. /// <returns></returns>
  9574. [HttpPost]
  9575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9576. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  9577. {
  9578. //验证城市归属并给默认值
  9579. int provinceId = dto.ProvinceId;
  9580. if (provinceId < 1) provinceId = 122;
  9581. var dataSource = await _sqlSugar
  9582. .Queryable<Sys_SetData>()
  9583. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9584. .ToListAsync();
  9585. //三公费用-Word明细类型
  9586. var wordTypeData = dataSource.Where(it => it.STid == 72)
  9587. .Select(x => new SetDataInfoView
  9588. {
  9589. Id = x.Id,
  9590. Name = x.Name,
  9591. Remark = x.Remark
  9592. })
  9593. .ToList();
  9594. //三公费用-Excel明细类型
  9595. var excelTypeData = dataSource.Where(it => it.STid == 73)
  9596. .Select(x => new SetDataInfoView
  9597. {
  9598. Id = x.Id,
  9599. Name = x.Name,
  9600. Remark = x.Remark
  9601. })
  9602. .ToList();
  9603. //默认币种显示
  9604. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9605. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9606. return Ok(JsonView(true, "查询成功!", new
  9607. {
  9608. WordTypeData = wordTypeData,
  9609. ExcelTypeData = excelTypeData,
  9610. CurrencyInit = _currencyInfos,
  9611. viewPermissionData = viewPermissionData
  9612. }));
  9613. }
  9614. /// <summary>
  9615. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9616. /// </summary>
  9617. /// <returns></returns>
  9618. [HttpPost]
  9619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9620. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9621. {
  9622. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9623. RefAsync<int> total = 0;
  9624. int diId = 0;
  9625. var status = int.TryParse(dto.GroupName, out diId);
  9626. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9627. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9628. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9629. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9630. .OrderByDescending(x => x.VisitStartDate)
  9631. .Select(x => new
  9632. {
  9633. Id = x.Id,
  9634. GroupName = x.TeamName
  9635. })
  9636. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9637. return Ok(JsonView(true, "查询成功!", data, total));
  9638. }
  9639. /// <summary>
  9640. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9641. /// </summary>
  9642. /// <returns></returns>
  9643. [HttpPost]
  9644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9645. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9646. {
  9647. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9648. RefAsync<int> total = 0;
  9649. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9650. .Where(x => x.IsDel == 0 && x.STid == 66)
  9651. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9652. .Select(x => new
  9653. {
  9654. id = x.Id,
  9655. name = x.Name,
  9656. remark = x.Remark,
  9657. })
  9658. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9659. return Ok(JsonView(true, "查询成功!", data, total));
  9660. }
  9661. /// <summary>
  9662. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9663. /// </summary>
  9664. /// <returns></returns>
  9665. [HttpPost]
  9666. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9667. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9668. {
  9669. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9670. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9671. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  9672. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9673. var groupOtherRateData = groupRateData.TeamRates;
  9674. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9675. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9676. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9677. groupOtherRateData = groupOtherRateData
  9678. .Select(x => new TeamRateDescAddCurrencyIdView
  9679. {
  9680. CurrencyId = x.CurrencyId,
  9681. CurrencyName = x.CurrencyName,
  9682. CurrencyCode = x.CurrencyCode,
  9683. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9684. }).ToList();
  9685. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9686. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9687. }
  9688. /// <summary>
  9689. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9690. /// </summary>
  9691. /// <returns></returns>
  9692. [HttpPost]
  9693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9694. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9695. {
  9696. int portType = dto.PortType;
  9697. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9698. var tipsData = new List<int>() { 1, 2, 3 };
  9699. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9700. if (dto.TipsType == 1)
  9701. {
  9702. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9703. }
  9704. else if (dto.TipsType == 2)
  9705. {
  9706. if (portType == 2)
  9707. {
  9708. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9709. }
  9710. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9711. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9712. .Select(x => x.NationalTravelFeeId)
  9713. .Distinct()
  9714. .ToListAsync();
  9715. if (portType == 2)
  9716. {
  9717. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9718. }
  9719. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9720. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9721. .Select(x => x.Country)
  9722. .Distinct()
  9723. .ToArrayAsync();
  9724. if (portType == 2)
  9725. {
  9726. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9727. }
  9728. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9729. return Ok(JsonView(true, "查询成功!", new
  9730. {
  9731. totalAmt = totalAmt,
  9732. remark = remark
  9733. }));
  9734. }
  9735. else if (dto.TipsType == 3)
  9736. {
  9737. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  9738. }
  9739. return Ok(JsonView(false));
  9740. }
  9741. /// <summary>
  9742. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  9743. /// </summary>
  9744. /// <returns></returns>
  9745. [HttpPost]
  9746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9747. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  9748. {
  9749. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  9750. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9751. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9752. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  9753. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  9754. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  9755. var info = new Grp_EnterExitCostDraft()
  9756. {
  9757. ProvinceId = dto.ProvinceId,
  9758. DraftName = dto.DraftName,
  9759. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  9760. CreateUserId = dto.CurrUserId
  9761. };
  9762. _sqlSugar.BeginTran();
  9763. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9764. if (draftId < 1)
  9765. {
  9766. _sqlSugar.RollbackTran();
  9767. return Ok(JsonView(false, "草稿创建失败!"));
  9768. }
  9769. //添加默认权限
  9770. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  9771. _sqlSugar.CommitTran();
  9772. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  9773. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9774. mobileInfo.Id = draftId;
  9775. mobileInfo.DraftName = dto.DraftName;
  9776. mobileInfo.Currencys = rateInfos;
  9777. mobileInfo.IsAssignPerm = assignPerm;
  9778. return Ok(JsonView(mobileInfo));
  9779. }
  9780. /// <summary>
  9781. /// 出入境费用-草稿-移动端 查看编辑提示消息
  9782. /// </summary>
  9783. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  9784. /// <summary>
  9785. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9786. /// </summary>
  9787. /// <returns></returns>
  9788. [HttpPost]
  9789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9790. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9791. {
  9792. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9793. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9794. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9795. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9796. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9797. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  9798. //验证查看编辑权限
  9799. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9800. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9801. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9802. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  9803. mobileInfo.IsAssignPerm = assignPerm;
  9804. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9805. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9806. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9807. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9808. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9809. {
  9810. ParentId = dac.ParentId,
  9811. SubId = dac.Id,
  9812. Type = dac.Type,
  9813. Days = dac.Days,
  9814. NationalTravelFeeId = dac.NationalTravelFeeId,
  9815. Arae = $"{ntf.Country}-{ntf.City}",
  9816. Cost = dac.Cost,
  9817. Currency = dac.Currency,
  9818. CurrencyName = sd.Name,
  9819. SubTotal = dac.SubTotal,
  9820. })
  9821. .ToList();
  9822. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9823. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9824. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9825. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9826. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9827. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9828. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9829. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9830. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9831. //其他款项
  9832. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9833. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9834. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9835. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9836. .OrderBy((dop, sd1, sd2) => dop.Index)
  9837. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9838. {
  9839. ParentId = dop.ParentId,
  9840. SubId = dop.Id,
  9841. Index = dop.Index,
  9842. SetDataId = dop.SetDataId,
  9843. SetDataName = sd1.Name,
  9844. Cost = dop.Cost,
  9845. Currency = dop.Currency,
  9846. CurrencyName = sd2.Remark,
  9847. SubTotal = dop.SubTotal,
  9848. Remark = dop.Remark,
  9849. })
  9850. .ToArray();
  9851. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9852. return Ok(mobileInfo);
  9853. }
  9854. /// <summary>
  9855. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9856. /// </summary>
  9857. /// <returns></returns>
  9858. [HttpPost]
  9859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9860. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9861. {
  9862. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9863. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9864. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9865. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9866. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9867. //验证查看编辑权限
  9868. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9869. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9870. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9871. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9872. var subType = dto.SubType;
  9873. if (subType == 1) //1:境内费用
  9874. {
  9875. var oneData = new ChoiceOneMobileSubInfoView()
  9876. {
  9877. Id = eecInfo.Id,
  9878. ChoiceOne = eecInfo.ChoiceOne,
  9879. ChoiceOneTotalCost = eecInfo.InsidePay,
  9880. Visa = eecInfo.Visa,
  9881. VisaRemark = eecInfo.VisaRemark,
  9882. YiMiao = eecInfo.YiMiao,
  9883. HeSuan = eecInfo.HeSuan,
  9884. Service = eecInfo.Service,
  9885. Ticket = eecInfo.Ticket,
  9886. Safe = eecInfo.Safe,
  9887. FirstItemRemark = eecInfo.FirstItemRemark
  9888. };
  9889. return Ok(JsonView(oneData));
  9890. }
  9891. else if (subType == 2) //2:国际旅费
  9892. {
  9893. var twoData = new ChoiceTwoMobileSubInfoView()
  9894. {
  9895. Id = eecInfo.Id,
  9896. ChoiceTwoJJ = eecInfo.SumJJC,
  9897. OutsideJJPay = eecInfo.OutsideJJPay,
  9898. ChoiceTwoGW = eecInfo.SumGWC,
  9899. OutsideGWPay = eecInfo.OutsideGWPay,
  9900. ChoiceTwoTD = eecInfo.SumTDC,
  9901. OutsideTDPay = eecInfo.OutsideTDPay,
  9902. AirJJ = eecInfo.AirJJ,
  9903. AirGW = eecInfo.AirGW,
  9904. AirTD = eecInfo.AirTD,
  9905. CityTranffic = eecInfo.CityTranffic,
  9906. TwoItemRemark = eecInfo.TwoItemRemark
  9907. };
  9908. return Ok(JsonView(twoData));
  9909. }
  9910. else if (subType == 3) //3:住宿费
  9911. {
  9912. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9913. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9914. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9915. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9916. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9917. {
  9918. ParentId = dac.ParentId,
  9919. SubId = dac.Id,
  9920. Type = dac.Type,
  9921. Days = dac.Days,
  9922. NationalTravelFeeId = dac.NationalTravelFeeId,
  9923. Arae = $"{ntf.Country}-{ntf.City}",
  9924. Cost = dac.Cost,
  9925. Currency = dac.Currency,
  9926. CurrencyName = sd.Name,
  9927. SubTotal = dac.SubTotal,
  9928. })
  9929. .ToArray();
  9930. var data = new ChoiceDraftMobileSubInfo3To6View()
  9931. {
  9932. ParentId = eecInfo.Id,
  9933. Choice = eecInfo.ChoiceThree,
  9934. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9935. Details = dayAndCostDatas
  9936. };
  9937. return Ok(JsonView(data));
  9938. }
  9939. else if (subType == 4) //4:伙食费
  9940. {
  9941. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9942. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9943. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9944. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9945. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9946. {
  9947. ParentId = dac.ParentId,
  9948. SubId = dac.Id,
  9949. Type = dac.Type,
  9950. Days = dac.Days,
  9951. NationalTravelFeeId = dac.NationalTravelFeeId,
  9952. Arae = $"{ntf.Country}-{ntf.City}",
  9953. Cost = dac.Cost,
  9954. Currency = dac.Currency,
  9955. CurrencyName = sd.Name,
  9956. SubTotal = dac.SubTotal,
  9957. })
  9958. .ToArray();
  9959. var data = new ChoiceDraftMobileSubInfo3To6View()
  9960. {
  9961. ParentId = eecInfo.Id,
  9962. Choice = eecInfo.ChoiceFour,
  9963. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9964. Details = dayAndCostDatas
  9965. };
  9966. return Ok(JsonView(data));
  9967. }
  9968. else if (subType == 5) //5:公杂费
  9969. {
  9970. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9971. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9972. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9973. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9974. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9975. {
  9976. ParentId = dac.ParentId,
  9977. SubId = dac.Id,
  9978. Type = dac.Type,
  9979. Days = dac.Days,
  9980. NationalTravelFeeId = dac.NationalTravelFeeId,
  9981. Arae = $"{ntf.Country}-{ntf.City}",
  9982. Cost = dac.Cost,
  9983. Currency = dac.Currency,
  9984. CurrencyName = sd.Name,
  9985. SubTotal = dac.SubTotal,
  9986. })
  9987. .ToArray();
  9988. var data = new ChoiceDraftMobileSubInfo3To6View()
  9989. {
  9990. ParentId = eecInfo.Id,
  9991. Choice = eecInfo.ChoiceFive,
  9992. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9993. Details = dayAndCostDatas
  9994. };
  9995. return Ok(JsonView(data));
  9996. }
  9997. else if (subType == 6) //6:培训费
  9998. {
  9999. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10000. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10001. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10002. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  10003. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10004. {
  10005. ParentId = dac.ParentId,
  10006. SubId = dac.Id,
  10007. Type = dac.Type,
  10008. Days = dac.Days,
  10009. NationalTravelFeeId = dac.NationalTravelFeeId,
  10010. Arae = $"{ntf.Country}-{ntf.City}",
  10011. Cost = dac.Cost,
  10012. Currency = dac.Currency,
  10013. CurrencyName = sd.Name,
  10014. SubTotal = dac.SubTotal,
  10015. })
  10016. .ToArray();
  10017. var data = new ChoiceDraftMobileSubInfo3To6View()
  10018. {
  10019. ParentId = eecInfo.Id,
  10020. Choice = eecInfo.ChoiceSix,
  10021. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10022. Details = dayAndCostDatas
  10023. };
  10024. return Ok(JsonView(data));
  10025. }
  10026. else if (subType == 7) //7:其他
  10027. {
  10028. //其他款项
  10029. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10030. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10031. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10032. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10033. .OrderBy((dop, sd1, sd2) => dop.Index)
  10034. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10035. {
  10036. ParentId = dop.ParentId,
  10037. SubId = dop.Id,
  10038. Index = dop.Index,
  10039. SetDataId = dop.SetDataId,
  10040. SetDataName = sd1.Name,
  10041. Cost = dop.Cost,
  10042. Currency = dop.Currency,
  10043. CurrencyName = sd2.Name,
  10044. SubTotal = dop.SubTotal,
  10045. Remark = dop.Remark,
  10046. })
  10047. .ToArray();
  10048. var data = new ChoiceSevenDraftMobileSubInfoView()
  10049. {
  10050. ParentId = eecInfo.Id,
  10051. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10052. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10053. Details = otherData
  10054. };
  10055. return Ok(JsonView(data));
  10056. }
  10057. return Ok(JsonView(false));
  10058. }
  10059. #region op
  10060. /// <summary>
  10061. /// 移动端更新费用消息通知
  10062. /// </summary>
  10063. /// <param name="draftId"></param>
  10064. /// <param name="id"></param>
  10065. /// <param name="currUserId"></param>
  10066. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  10067. {
  10068. try
  10069. {
  10070. ////生成默认文件pdf并且通知人员
  10071. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10072. //{
  10073. // DiId = draftId,
  10074. // ExportType = 1,
  10075. // SubTypeId = 1005
  10076. //}, "pdf");
  10077. ////发送通知
  10078. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10079. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  10080. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  10081. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  10082. ////汇率信息记录
  10083. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  10084. }
  10085. catch (Exception ex)
  10086. {
  10087. //记录日志
  10088. throw;
  10089. }
  10090. }
  10091. /// <summary>
  10092. /// 验证出入境费用数据是否存在
  10093. /// 不存在添加
  10094. /// </summary>
  10095. /// <param name="draftId"></param>
  10096. /// <param name="currUserId"></param>
  10097. /// <returns></returns>
  10098. /// <exception cref="CustomException"></exception>
  10099. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  10100. {
  10101. var parentId = 0;
  10102. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  10103. if (info != null) parentId = info.Id;
  10104. else
  10105. {
  10106. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  10107. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  10108. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  10109. parentId = addId;
  10110. }
  10111. return parentId;
  10112. }
  10113. /// <summary>
  10114. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  10115. /// </summary>
  10116. /// <returns></returns>
  10117. [HttpPost]
  10118. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10119. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  10120. {
  10121. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10122. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10123. //验证查看权限
  10124. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10125. if (!isView) return Ok(JsonView(false, _viewPermStr));
  10126. var userIds = await _sqlSugar
  10127. .Queryable<Grp_EnterExitCostDraftPermission>()
  10128. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  10129. .Select(x => x.UserId)
  10130. .ToArrayAsync();
  10131. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  10132. var perUsersView = new List<dynamic>();
  10133. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  10134. var viewPermissionData = new List<PermissionViewUserview>();
  10135. if (feeBasePerm.Any())
  10136. {
  10137. foreach (var item in feeBasePerm)
  10138. {
  10139. if (item.Users.Any())
  10140. {
  10141. viewPermissionData.AddRange(item.Users);
  10142. }
  10143. }
  10144. }
  10145. foreach (var item in perUsers)
  10146. {
  10147. bool isView1 = false;
  10148. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10149. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  10150. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10151. }
  10152. return Ok(JsonView(perUsersView));
  10153. }
  10154. /// <summary>
  10155. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  10156. /// </summary>
  10157. /// <returns></returns>
  10158. [HttpPost]
  10159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10160. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  10161. {
  10162. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10163. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10164. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  10165. //验证查看编辑权限
  10166. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10167. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10168. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  10169. foreach (var userId in dto.UserIds)
  10170. {
  10171. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  10172. }
  10173. if (permissions.Any())
  10174. {
  10175. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  10176. {
  10177. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  10178. }
  10179. _sqlSugar.BeginTran();
  10180. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  10181. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  10182. if (result < 1)
  10183. {
  10184. _sqlSugar.RollbackTran();
  10185. return Ok(JsonView(false));
  10186. }
  10187. _sqlSugar.CommitTran();
  10188. return Ok(JsonView(true));
  10189. }
  10190. return Ok(JsonView(false));
  10191. }
  10192. /// <summary>
  10193. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  10194. /// </summary>
  10195. /// <returns></returns>
  10196. [HttpPost]
  10197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10198. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  10199. {
  10200. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10201. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10202. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10203. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  10204. int id = dto.DraftId;
  10205. if (id <= 0) //add
  10206. {
  10207. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10208. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10209. if (add < 1) return Ok(JsonView(false));
  10210. id = add;
  10211. }
  10212. else //update
  10213. {
  10214. //验证查看编辑权限
  10215. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10216. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10217. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10218. if (upd < 1) return Ok(JsonView(false));
  10219. }
  10220. return Ok(JsonView(new { parentId = id }));
  10221. }
  10222. /// <summary>
  10223. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  10224. /// </summary>
  10225. /// <returns></returns>
  10226. [HttpPost]
  10227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10228. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto 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.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  10234. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  10235. int id = dto.DraftId;
  10236. if (id <= 0) //add
  10237. {
  10238. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10239. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  10240. if (add < 1) return Ok(JsonView(false));
  10241. id = add;
  10242. }
  10243. else //update
  10244. {
  10245. //验证查看编辑权限
  10246. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10247. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10248. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  10249. if (upd < 1) return Ok(JsonView(false));
  10250. }
  10251. #region 汇率变更时更改币种相关费用
  10252. var opDayCosts = new List<Grp_DayAndCostDraft>();
  10253. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  10254. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  10255. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10256. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  10257. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10258. .Select((dac, sd) => new
  10259. {
  10260. dac.Id,
  10261. dac.ParentId,
  10262. CurrencyCode = sd.Name,
  10263. dac.Cost
  10264. })
  10265. .ToList();
  10266. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10267. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  10268. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10269. .Select((dop, sd) => new
  10270. {
  10271. dop.Id,
  10272. dop.ParentId,
  10273. CurrencyCode = sd.Name,
  10274. dop.Cost
  10275. })
  10276. .ToList();
  10277. if (dayCosts.Count > 0)
  10278. {
  10279. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10280. foreach (var dc in new_dayCosts)
  10281. {
  10282. var thisCurrency = dc.Key.ToUpper();
  10283. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10284. if (thisRate == 0.00M) continue;
  10285. foreach (var dcSub in dc)
  10286. {
  10287. opDayCosts.Add(new Grp_DayAndCostDraft()
  10288. {
  10289. Id = dcSub.Id,
  10290. ParentId = dcSub.ParentId,
  10291. Cost = dcSub.Cost,
  10292. SubTotal = dcSub.Cost * thisRate,
  10293. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  10294. });
  10295. }
  10296. }
  10297. if (opDayCosts.Count > 0)
  10298. {
  10299. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10300. }
  10301. }
  10302. if (dayOtherCosts.Count > 0)
  10303. {
  10304. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  10305. foreach (var dc in new_dayOtherCosts)
  10306. {
  10307. var thisCurrency = dc.Key.ToUpper();
  10308. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  10309. if (thisRate == 0.00M) continue;
  10310. foreach (var dcSub in dc)
  10311. {
  10312. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  10313. {
  10314. Id = dcSub.Id,
  10315. ParentId = dcSub.ParentId,
  10316. Cost = dcSub.Cost,
  10317. SubTotal = dcSub.Cost * thisRate,
  10318. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10319. });
  10320. }
  10321. }
  10322. if (opDayOtherCosts.Count > 0)
  10323. {
  10324. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10325. }
  10326. }
  10327. #endregion
  10328. ////消息通知
  10329. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10330. ////汇率信息记录
  10331. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10332. return Ok(JsonView(new { parentId = id }));
  10333. }
  10334. /// <summary>
  10335. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  10336. /// </summary>
  10337. /// <returns></returns>
  10338. [HttpPost]
  10339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10340. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  10341. {
  10342. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10343. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10344. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10345. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  10346. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10347. int id = dto.DraftId;
  10348. if (id <= 0) //add
  10349. {
  10350. checkboxInfo.ProvinceId = dto.ProvinceId;
  10351. checkboxInfo.CreateUserId = dto.CurrUserId;
  10352. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  10353. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10354. if (add < 1) return Ok(JsonView(false));
  10355. }
  10356. else //update
  10357. {
  10358. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10359. .UpdateColumns(x => new
  10360. {
  10361. x.ChoiceOne,
  10362. x.ChoiceTwo,
  10363. x.SumJJC,
  10364. x.SumGWC,
  10365. x.SumTDC,
  10366. x.ChoiceThree,
  10367. x.ChoiceFour,
  10368. x.ChoiceFive,
  10369. x.ChoiceSix,
  10370. x.OtherExpenses_Checked
  10371. })
  10372. .Where(x => x.Id == id)
  10373. .ExecuteCommandAsync();
  10374. if (upd < 1) return Ok(JsonView(false));
  10375. }
  10376. return Ok(JsonView(new { parentId = id }));
  10377. }
  10378. /// <summary>
  10379. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  10380. /// </summary>
  10381. /// <returns></returns>
  10382. [HttpPost]
  10383. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10384. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  10385. {
  10386. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  10387. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10388. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10389. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10390. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10391. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10392. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10393. var checkboxInfo = new Grp_EnterExitCostDraft()
  10394. {
  10395. Id = draftId,
  10396. ProvinceId = dto.ProvinceId,
  10397. CreateUserId = currUserId
  10398. };
  10399. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10400. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10401. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10402. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10403. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10404. if (draftId <= 0) //add
  10405. {
  10406. checkboxInfo.CreateUserId = dto.CurrUserId;
  10407. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10408. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10409. if (add < 1) return Ok(JsonView(false));
  10410. }
  10411. else //update
  10412. {
  10413. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  10414. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10415. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10416. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10417. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10418. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10419. .Where(x => x.Id == draftId)
  10420. .ExecuteCommandAsync();
  10421. if (upd < 1) return Ok(JsonView(false));
  10422. }
  10423. return Ok(JsonView(new { parentId = draftId }));
  10424. }
  10425. /// <summary>
  10426. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  10427. /// </summary>
  10428. /// <returns></returns>
  10429. [HttpPost]
  10430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10431. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  10432. {
  10433. int id = dto.DraftId, currUserId = dto.CurrUserId;
  10434. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10435. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  10436. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10437. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10438. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  10439. info.ProvinceId = dto.ProvinceId;
  10440. info.FirstItemRemark = dto.FirstItemRemark;
  10441. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10442. if (id <= 0) //add
  10443. {
  10444. info.CreateUserId = dto.CurrUserId;
  10445. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10446. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10447. if (add < 1) return Ok(JsonView(false));
  10448. id = add;
  10449. }
  10450. else //update
  10451. {
  10452. var upd = await _sqlSugar.Updateable(info)
  10453. .UpdateColumns(x => new
  10454. {
  10455. x.ChoiceOne,
  10456. x.InsidePay,
  10457. x.VisaRemark,
  10458. x.Visa,
  10459. x.Service,
  10460. x.Safe,
  10461. x.Ticket,
  10462. x.HeSuan,
  10463. x.YiMiao,
  10464. x.FirstItemRemark
  10465. })
  10466. .Where(x => x.Id == id)
  10467. .ExecuteCommandAsync();
  10468. if (upd < 1) return Ok(JsonView(false));
  10469. }
  10470. ////消息通知
  10471. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10472. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10473. }
  10474. /// <summary>
  10475. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  10476. /// </summary>
  10477. /// <returns></returns>
  10478. [HttpPost]
  10479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10480. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  10481. {
  10482. int id = dto.DraftId;
  10483. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10484. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  10485. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10486. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10487. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  10488. info.ProvinceId = dto.ProvinceId;
  10489. info.OutsideJJPay = dto.OutsideJJPay;
  10490. info.OutsideGWPay = dto.OutsideGWPay;
  10491. info.OutsideTDPay = dto.OutsideTDPay;
  10492. info.AirJJ = dto.AirJJ;
  10493. info.AirGW = dto.AirGW;
  10494. info.AirTD = dto.AirTD;
  10495. info.CityTranffic = dto.CityTranffic;
  10496. info.TwoItemRemark = dto.TwoItemRemark;
  10497. info.SumJJC = dto.ChoiceTwoJJ;
  10498. info.SumGWC = dto.ChoiceTwoGW;
  10499. info.SumTDC = dto.ChoiceTwoTD;
  10500. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10501. if (id <= 0) //add
  10502. {
  10503. info.CreateUserId = dto.CurrUserId;
  10504. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10505. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10506. if (addId <= 0) return Ok(JsonView(false));
  10507. id = addId;
  10508. }
  10509. else //update
  10510. {
  10511. var upd = await _sqlSugar.Updateable(info)
  10512. .UpdateColumns(x => new
  10513. {
  10514. x.SumJJC,
  10515. x.OutsideJJPay,
  10516. x.SumGWC,
  10517. x.OutsideGWPay,
  10518. x.SumTDC,
  10519. x.OutsideTDPay,
  10520. x.AirJJ,
  10521. x.AirGW,
  10522. x.AirTD,
  10523. x.CityTranffic,
  10524. x.TwoItemRemark
  10525. })
  10526. .Where(x => x.Id == id)
  10527. .ExecuteCommandAsync();
  10528. if (upd < 1) return Ok(JsonView(false));
  10529. }
  10530. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10531. gwcItemTotal = info.AirGW + info.CityTranffic;
  10532. tdcItemTotal = info.AirTD + info.CityTranffic;
  10533. ////消息通知
  10534. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10535. return Ok(JsonView(new
  10536. {
  10537. parentId = id,
  10538. choiceTwoJJ = dto.ChoiceTwoJJ,
  10539. jjcItemTotal = jjcItemTotal,
  10540. choiceTwoGW = dto.ChoiceTwoGW,
  10541. gwcItemTotal = gwcItemTotal,
  10542. choiceTwoTD = dto.ChoiceTwoTD,
  10543. tdcItemTotal = tdcItemTotal
  10544. }));
  10545. }
  10546. /// <summary>
  10547. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10548. /// </summary>
  10549. /// <returns></returns>
  10550. [HttpPost]
  10551. [ApiExplorerSettings(IgnoreApi = true)]
  10552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10553. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  10554. {
  10555. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10556. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10557. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10558. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10559. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10560. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10561. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  10562. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  10563. {
  10564. Id = x.Id,
  10565. ParentId = dto.DraftId,
  10566. Type = dto.FeeType,
  10567. Days = x.Days,
  10568. NationalTravelFeeId = x.NationalTravelFeeId,
  10569. Cost = x.Cost,
  10570. Currency = x.Currency,
  10571. SubTotal = x.SubTotal,
  10572. CreateUserId = dto.CurrUserId
  10573. })
  10574. .ToList();
  10575. var adds = infos.Where(x => x.Id <= 0).ToList();
  10576. var upds = infos.Where(x => x.Id > 0).ToList();
  10577. if (adds.Count > 0)
  10578. {
  10579. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10580. if (add < 1) return Ok(JsonView(false));
  10581. }
  10582. if (upds.Count > 0)
  10583. {
  10584. var upd = await _sqlSugar.Updateable(adds)
  10585. .UpdateColumns(x => new
  10586. {
  10587. x.Days,
  10588. x.NationalTravelFeeId,
  10589. x.Cost,
  10590. x.Currency,
  10591. x.SubTotal
  10592. })
  10593. .WhereColumns(x => new { x.Id })
  10594. .ExecuteCommandAsync();
  10595. if (upd < 1) return Ok(JsonView(false));
  10596. }
  10597. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10598. ////消息通知
  10599. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  10600. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10601. return Ok(JsonView(new { itemTotal = itemTotal }));
  10602. }
  10603. /// <summary>
  10604. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10605. /// </summary>
  10606. /// <returns></returns>
  10607. [HttpPost]
  10608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10609. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  10610. {
  10611. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10612. int subId = dto.SubId, feeType = dto.FeeType;
  10613. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10614. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10615. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10616. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10617. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  10618. subInfo.Id = subId;
  10619. subInfo.ParentId = dto.DraftId;
  10620. if (feeType == 3) subInfo.Type = 1;
  10621. else if (feeType == 4) subInfo.Type = 2;
  10622. else if (feeType == 5) subInfo.Type = 3;
  10623. else if (feeType == 6) subInfo.Type = 4;
  10624. subInfo.CreateUserId = dto.CurrUserId;
  10625. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  10626. if (parentId < 1) return Ok(JsonView(false));
  10627. //子表op
  10628. if (subId < 1)
  10629. {
  10630. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10631. if (subAdd < 1) return Ok(JsonView(false));
  10632. }
  10633. else
  10634. {
  10635. var subUpd = await _sqlSugar.Updateable(subInfo)
  10636. .UpdateColumns(x => new
  10637. {
  10638. x.Days,
  10639. x.NationalTravelFeeId,
  10640. x.Cost,
  10641. x.Currency,
  10642. x.SubTotal
  10643. })
  10644. .WhereColumns(x => new { x.Id })
  10645. .ExecuteCommandAsync();
  10646. if (subUpd < 1) return Ok(JsonView(false));
  10647. }
  10648. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  10649. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10650. }
  10651. /// <summary>
  10652. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  10653. /// </summary>
  10654. /// <returns></returns>
  10655. [HttpPost]
  10656. [ApiExplorerSettings(IgnoreApi = true)]
  10657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10658. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  10659. {
  10660. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10661. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10662. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10663. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  10664. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  10665. {
  10666. Id = x.Id,
  10667. ParentId = dto.DraftId,
  10668. SetDataId = x.SetDataId,
  10669. Index = x.Index,
  10670. Cost = x.Cost,
  10671. Currency = x.Currency,
  10672. SubTotal = x.SubTotal,
  10673. CreateUserId = dto.CurrUserId,
  10674. Remark = x.Remark
  10675. }).ToList();
  10676. var adds = infos.Where(x => x.Id <= 0).ToList();
  10677. var upds = infos.Where(x => x.Id > 0).ToList();
  10678. if (adds.Count > 0)
  10679. {
  10680. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10681. if (add < 1) return Ok(JsonView(false));
  10682. }
  10683. if (upds.Count > 0)
  10684. {
  10685. var upd = await _sqlSugar.Updateable(adds)
  10686. .UpdateColumns(x => new
  10687. {
  10688. x.Index,
  10689. x.SetDataId,
  10690. x.Cost,
  10691. x.Currency,
  10692. x.SubTotal,
  10693. x.Remark
  10694. })
  10695. .WhereColumns(x => new { x.Id })
  10696. .ExecuteCommandAsync();
  10697. if (upd < 1) return Ok(JsonView(false));
  10698. }
  10699. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  10700. //消息通知
  10701. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  10702. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10703. return Ok(JsonView(new { itemTotal = itemTotal }));
  10704. }
  10705. /// <summary>
  10706. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  10707. /// </summary>
  10708. /// <returns></returns>
  10709. [HttpPost]
  10710. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10711. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  10712. {
  10713. int subId = dto.SubId, id = dto.DraftId;
  10714. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10715. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  10716. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10717. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  10718. subInfo.Id = subId;
  10719. subInfo.ParentId = id;
  10720. subInfo.CreateUserId = dto.CurrUserId;
  10721. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  10722. if (parentId < 1) return Ok(JsonView(false));
  10723. #region 子表op
  10724. if (subId < 1)//add
  10725. {
  10726. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10727. if (subAdd < 1) return Ok(JsonView(false));
  10728. }
  10729. else //upd
  10730. {
  10731. var subUpd = await _sqlSugar.Updateable(subInfo)
  10732. .UpdateColumns(x => new
  10733. {
  10734. x.Index,
  10735. x.SetDataId,
  10736. x.Cost,
  10737. x.Currency,
  10738. x.SubTotal,
  10739. x.Remark
  10740. })
  10741. .WhereColumns(x => new { x.Id })
  10742. .ExecuteCommandAsync();
  10743. if (subUpd < 1) return Ok(JsonView(false));
  10744. }
  10745. #endregion
  10746. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10747. ////消息通知
  10748. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10749. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10750. }
  10751. /// <summary>
  10752. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10753. /// </summary>
  10754. /// <returns></returns>
  10755. [HttpPost]
  10756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10757. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10758. {
  10759. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10760. if (data.Code != 0)
  10761. {
  10762. return Ok(JsonView(false, data.Msg));
  10763. }
  10764. return Ok(JsonView(true, "操作成功!", data.Data));
  10765. }
  10766. /// <summary>
  10767. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10768. /// </summary>
  10769. /// <param name="dto"></param>
  10770. /// <returns></returns>
  10771. [HttpPost]
  10772. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10773. {
  10774. var data = new Grp_DayOtherPriceDraft()
  10775. {
  10776. Id = dto.Id,
  10777. IsDel = 1,
  10778. DeleteUserId = dto.DeleteUserId,
  10779. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10780. };
  10781. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10782. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10783. return Ok(JsonView(false, "删除失败!"));
  10784. }
  10785. #endregion
  10786. #endregion
  10787. #region 团组经理模块 出入境费用报价表
  10788. /// <summary>
  10789. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  10790. /// </summary>
  10791. /// <returns></returns>
  10792. [HttpPost]
  10793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10794. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  10795. {
  10796. var initRates = await GeneralMethod.EnterExitCostInitRate();
  10797. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  10798. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  10799. initRates.Insert(0, cnyInfo);
  10800. liveRates.Insert(0, cnyInfo);
  10801. return Ok(JsonView(true, "查询成功!", new
  10802. {
  10803. InitRates = initRates,
  10804. LiveRates = liveRates
  10805. }));
  10806. }
  10807. /// <summary>
  10808. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  10809. /// </summary>
  10810. /// <returns></returns>
  10811. [HttpPost]
  10812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10813. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  10814. {
  10815. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  10816. }
  10817. /// <summary>
  10818. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  10819. /// </summary>
  10820. /// <returns></returns>
  10821. [HttpPost]
  10822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10823. public async Task<IActionResult> EnterExitCostQuoteGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  10824. {
  10825. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  10826. }
  10827. /// <summary>
  10828. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  10829. /// </summary>
  10830. /// <returns></returns>
  10831. [HttpPost]
  10832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10833. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  10834. {
  10835. int groupId = dto.DiId,
  10836. currUserId = dto.CurrUserId;
  10837. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  10838. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  10839. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10840. if (info.Code != StatusCodes.Status200OK) return Ok(info);
  10841. var infoView = info.Data as EnterExitCostInfoView;
  10842. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  10843. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  10844. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  10845. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  10846. var eecRates = infoView.Currencys;
  10847. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  10848. int pplNum = 1;
  10849. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  10850. var views = new List<QuoteSubItemInfo>();
  10851. #region 数据填充
  10852. var intTravelCosts = new List<QuoteSubItemInfo>();
  10853. #region 机票费用 1354
  10854. int intTravelIndex = 1;
  10855. if (infoView.SumJJC == 1)
  10856. {
  10857. intTravelCosts.Add(new QuoteSubItemInfo
  10858. {
  10859. ItemId = 1354,
  10860. Index = intTravelIndex,
  10861. FeeName = "经济舱",
  10862. UnitPrice = infoView.AirJJ,
  10863. Currency = "CNY",
  10864. Quantity = 1,
  10865. PplNum = 1,
  10866. TotalAmt = infoView.AirJJ,
  10867. Remark = "",
  10868. });
  10869. intTravelIndex++;
  10870. }
  10871. if (infoView.SumGWC == 1)
  10872. {
  10873. intTravelCosts.Add(new QuoteSubItemInfo
  10874. {
  10875. ItemId = 1354,
  10876. Index = intTravelIndex,
  10877. FeeName = "公务舱",
  10878. UnitPrice = infoView.AirGW,
  10879. Currency = "CNY",
  10880. Quantity = 1,
  10881. PplNum = 1,
  10882. TotalAmt = infoView.AirGW,
  10883. Remark = "",
  10884. });
  10885. intTravelIndex++;
  10886. }
  10887. if (infoView.SumTDC == 1)
  10888. {
  10889. intTravelCosts.Add(new QuoteSubItemInfo
  10890. {
  10891. ItemId = 1354,
  10892. Index = intTravelIndex,
  10893. FeeName = "头等舱",
  10894. UnitPrice = infoView.AirTD,
  10895. Currency = "CNY",
  10896. Quantity = 1,
  10897. PplNum = 1,
  10898. TotalAmt = infoView.AirTD,
  10899. Remark = "",
  10900. });
  10901. intTravelIndex++;
  10902. }
  10903. intTravelCosts.Add(new QuoteSubItemInfo
  10904. {
  10905. ItemId = 1354,
  10906. Index = intTravelIndex,
  10907. FeeName = "城市间交通费用",
  10908. UnitPrice = infoView.CityTranffic,
  10909. Currency = "CNY",
  10910. Quantity = 1,
  10911. PplNum = pplNum,
  10912. TotalAmt = infoView.CityTranffic * pplNum,
  10913. Remark = "",
  10914. });
  10915. views.AddRange(intTravelCosts);
  10916. #endregion
  10917. var accomCosts = new List<QuoteSubItemInfo>();
  10918. #region 住宿费 1355
  10919. if (infoView.QuarterageData.Any())
  10920. {
  10921. int accomIndex = 1;
  10922. int accomItemTypeId = 1355;
  10923. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  10924. foreach (var item in groupData)
  10925. {
  10926. string feeName = string.Empty;
  10927. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10928. if (countryInfo != null)
  10929. {
  10930. feeName = countryInfo.Country;
  10931. var city = countryInfo.City;
  10932. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10933. {
  10934. feeName += $"-{city}";
  10935. }
  10936. }
  10937. var hotelInfo = item.FirstOrDefault();
  10938. if (hotelInfo == null) continue;
  10939. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  10940. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10941. int quantity = item.ToList().Count;
  10942. accomCosts.Add(new QuoteSubItemInfo
  10943. {
  10944. ItemId = accomItemTypeId,
  10945. Index = accomIndex,
  10946. FeeName = feeName,
  10947. UnitPrice = hotelInfo.Cost,
  10948. Currency = thisCurrency,
  10949. Quantity = quantity,
  10950. PplNum = pplNum,
  10951. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  10952. Remark = "",
  10953. });
  10954. accomIndex++;
  10955. }
  10956. views.AddRange(accomCosts);
  10957. }
  10958. #endregion
  10959. var mealCosts = new List<QuoteSubItemInfo>();
  10960. #region 餐饮费 1356
  10961. if (infoView.BoardWagesData.Any())
  10962. {
  10963. var mealIndex = 1;
  10964. int mealItemTypeId = 1356;
  10965. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  10966. foreach (var item in groupData)
  10967. {
  10968. string feeName = string.Empty;
  10969. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10970. if (countryInfo != null)
  10971. {
  10972. feeName = countryInfo.Country;
  10973. var city = countryInfo.City;
  10974. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10975. {
  10976. feeName += $"-{city}";
  10977. }
  10978. }
  10979. var mealInfo = item.FirstOrDefault();
  10980. if (mealInfo == null) continue;
  10981. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  10982. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10983. int quantity = item.ToList().Count;
  10984. mealCosts.Add(new QuoteSubItemInfo
  10985. {
  10986. ItemId = mealItemTypeId,
  10987. Index = mealIndex,
  10988. FeeName = feeName,
  10989. UnitPrice = mealInfo.Cost,
  10990. Currency = thisCurrency,
  10991. Quantity = quantity,
  10992. PplNum = pplNum,
  10993. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  10994. Remark = "",
  10995. });
  10996. mealIndex++;
  10997. }
  10998. views.AddRange(mealCosts);
  10999. }
  11000. #endregion
  11001. var miscCosts = new List<QuoteSubItemInfo>();
  11002. #region 公杂费 1364
  11003. if (infoView.MiscellaneousFeeData.Any())
  11004. {
  11005. var miscIndex = 1;
  11006. int miscItemTypeId = 1364;
  11007. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  11008. foreach (var item in groupData)
  11009. {
  11010. string feeName = string.Empty;
  11011. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11012. if (countryInfo != null)
  11013. {
  11014. feeName = countryInfo.Country;
  11015. var city = countryInfo.City;
  11016. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11017. {
  11018. feeName += $"-{city}";
  11019. }
  11020. }
  11021. var miscInfo = item.FirstOrDefault();
  11022. if (miscInfo == null) continue;
  11023. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  11024. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11025. int quantity = item.ToList().Count;
  11026. mealCosts.Add(new QuoteSubItemInfo
  11027. {
  11028. ItemId = miscItemTypeId,
  11029. Index = miscIndex,
  11030. FeeName = feeName,
  11031. UnitPrice = miscInfo.Cost,
  11032. Currency = thisCurrency,
  11033. Quantity = quantity,
  11034. PplNum = pplNum,
  11035. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  11036. Remark = "",
  11037. });
  11038. miscIndex++;
  11039. }
  11040. views.AddRange(mealCosts);
  11041. }
  11042. #endregion
  11043. #region 签证+保险 1362
  11044. int visaInsIndex = 1;
  11045. int visaInsItemTypeId = 1362;
  11046. if (infoView.Visa > 0)
  11047. {
  11048. views.Add(new QuoteSubItemInfo()
  11049. {
  11050. ItemId = visaInsItemTypeId,
  11051. Index = visaInsIndex,
  11052. FeeName = $"签证",
  11053. UnitPrice = infoView.Visa,
  11054. Currency = $"CNY",
  11055. Quantity = 1,
  11056. PplNum = pplNum,
  11057. TotalAmt = infoView.Visa * pplNum,
  11058. Remark = "",
  11059. });
  11060. visaInsIndex++;
  11061. }
  11062. if (infoView.Safe > 0)
  11063. {
  11064. views.Add(new QuoteSubItemInfo()
  11065. {
  11066. ItemId = visaInsItemTypeId,
  11067. Index = visaInsIndex,
  11068. FeeName = $"保险",
  11069. UnitPrice = infoView.Safe,
  11070. Currency = $"CNY",
  11071. Quantity = 1,
  11072. PplNum = pplNum,
  11073. TotalAmt = infoView.Safe * pplNum,
  11074. Remark = "",
  11075. });
  11076. }
  11077. #endregion
  11078. #region 服务费 1363
  11079. int serviceFeeIndex = 1;
  11080. int serviceFeeItemTypeId = 1363;
  11081. if (infoView.Service > 0)
  11082. {
  11083. views.Add(new QuoteSubItemInfo()
  11084. {
  11085. ItemId = serviceFeeItemTypeId,
  11086. Index = serviceFeeIndex,
  11087. FeeName = $"服务费",
  11088. UnitPrice = infoView.Service,
  11089. Currency = $"CNY",
  11090. Quantity = 1,
  11091. PplNum = pplNum,
  11092. TotalAmt = infoView.Service * pplNum,
  11093. Remark = "",
  11094. });
  11095. }
  11096. #endregion
  11097. #endregion
  11098. var result = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { });
  11099. result.Rates = eecRates.ToArray();
  11100. if (result.FeeItems.Any())
  11101. {
  11102. result.FeeItems.Select(x =>
  11103. {
  11104. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  11105. if (feeInfos.Any()) x.Infos = feeInfos;
  11106. return x;
  11107. }
  11108. )
  11109. .OrderBy(x => x.Index)
  11110. .ToList();
  11111. }
  11112. return Ok(JsonView(result));
  11113. }
  11114. /// <summary>
  11115. /// 团组模块 - 出入境费用报价表 - Info
  11116. /// </summary>
  11117. /// <returns></returns>
  11118. [HttpPost]
  11119. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11120. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  11121. {
  11122. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  11123. if (!info.Rates.Any())
  11124. {
  11125. var rates = await GeneralMethod.EnterExitCostInitRate();
  11126. info.Rates = rates.ToArray();
  11127. }
  11128. return Ok(JsonView(info));
  11129. }
  11130. /// <summary>
  11131. /// 团组模块 - 出入境费用报价表 - OP
  11132. /// </summary>
  11133. /// <returns></returns>
  11134. [HttpPost]
  11135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11136. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  11137. {
  11138. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  11139. }
  11140. /// <summary>
  11141. /// 团组模块 - 出入境费用报价表 - 删除 项
  11142. /// </summary>
  11143. /// <returns></returns>
  11144. [HttpPost]
  11145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11146. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  11147. {
  11148. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11149. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11150. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  11151. }
  11152. /// <summary>
  11153. /// 团组模块 - 出入境费用报价表 - 导出
  11154. /// </summary>
  11155. /// <returns></returns>
  11156. [HttpPost]
  11157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11158. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  11159. {
  11160. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  11161. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11162. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  11163. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  11164. var rates = info.Rates;
  11165. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  11166. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  11167. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  11168. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  11169. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  11170. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  11171. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1560); //邀请函发放时间
  11172. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1561); //公务活动
  11173. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1562); //签证+保险
  11174. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1563); //服务费
  11175. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1564); //公杂费
  11176. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1565); //税费
  11177. //获取模板
  11178. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  11179. var designer = new WorkbookDesigner();
  11180. designer.Workbook = new Workbook(tempPath);
  11181. designer.SetDataSource("QuoteName", info.Name);
  11182. designer.SetDataSource("CompanyTitle", "公司名称");
  11183. designer.SetDataSource("CompanyLabel", "");
  11184. #region 国际旅费
  11185. designer.SetDataSource("IntTravelTitle", intTravelCosts.ItemName);
  11186. if (intTravelCosts.Infos.Any())
  11187. {
  11188. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  11189. StringBuilder label = new StringBuilder();
  11190. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  11191. if (infos.Any())
  11192. {
  11193. label.Append(infos.Sum(x => x.PplNum));
  11194. label.Append("人全程机票:");
  11195. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  11196. label.AppendLine("元");
  11197. }
  11198. foreach (var item in intTravelCosts.Infos)
  11199. {
  11200. label.Append(item.FeeName);
  11201. label.Append(":");
  11202. label.Append(item.UnitPrice.TruncDecimals(2));
  11203. label.Append("元/人*");
  11204. label.Append(item.PplNum);
  11205. label.AppendLine("人");
  11206. }
  11207. if (label.HasValue())
  11208. {
  11209. label.Append("\r\n以上小计:");
  11210. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  11211. label.Append("元");
  11212. }
  11213. designer.SetDataSource("IntTravelLabel", label.ToString());
  11214. }
  11215. #endregion
  11216. #region 住宿费
  11217. designer.SetDataSource("AccomTitle", accomCosts.ItemName);
  11218. if (accomCosts.Infos.Any())
  11219. {
  11220. string currencyName = string.Empty;
  11221. decimal rate = 1.0000M;
  11222. StringBuilder label = new StringBuilder();
  11223. label.AppendLine("全程五星酒店,每人1间房");
  11224. foreach (var item in accomCosts.Infos)
  11225. {
  11226. string hotelName = string.Empty;
  11227. if (item.FeeName.Contains("-"))
  11228. {
  11229. var feeName = item.FeeName.Split('-');
  11230. hotelName = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  11231. }
  11232. else hotelName = $"\r\n{item.FeeName}:";
  11233. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  11234. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  11235. rate = rateInfo?.Rate ?? 1.0000M;
  11236. label.Append(hotelName);
  11237. label.Append(item.UnitPrice.TruncDecimals(2));
  11238. label.Append(currencyName);
  11239. label.Append("/间/晚*");
  11240. label.Append(item.Quantity.ToString("#0"));
  11241. label.AppendLine("人");
  11242. }
  11243. if (label.HasValue())
  11244. {
  11245. label.Append("\r\n以上小计:");
  11246. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  11247. label.Append("元(");
  11248. label.Append(currencyName);
  11249. label.Append("汇率:");
  11250. label.Append(rate.TruncDecimals(4));
  11251. label.Append(")");
  11252. }
  11253. designer.SetDataSource("AccomLabel", label.ToString());
  11254. }
  11255. #endregion
  11256. #region 餐饮费
  11257. designer.SetDataSource("MealTitle", mealCosts.ItemName);
  11258. if (mealCosts.Infos.Any())
  11259. {
  11260. string currencyName = string.Empty;
  11261. decimal rate = 1.0000M;
  11262. StringBuilder label = new StringBuilder();
  11263. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  11264. foreach (var item in mealCosts.Infos)
  11265. {
  11266. string name = string.Empty;
  11267. if (item.FeeName.Contains("-"))
  11268. {
  11269. var feeName = item.FeeName.Split('-');
  11270. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  11271. }
  11272. else name = $"\r\n{item.FeeName}:";
  11273. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  11274. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  11275. rate = rateInfo?.Rate ?? 1.0000M;
  11276. label.Append(name);
  11277. label.Append(item.UnitPrice.TruncDecimals(2));
  11278. label.Append(currencyName);
  11279. label.Append("/天*");
  11280. label.Append(item.Quantity.ToString("#0"));
  11281. label.Append("*");
  11282. label.Append(item.PplNum);
  11283. label.Append("人\r\n");
  11284. }
  11285. if (label.HasValue())
  11286. {
  11287. label.Append("\r\n以上小计:");
  11288. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  11289. label.Append("元\r\n(");
  11290. label.Append("汇率:");
  11291. label.Append(rate.TruncDecimals(4));
  11292. label.Append(")");
  11293. }
  11294. designer.SetDataSource("MealLabel", label.ToString());
  11295. }
  11296. #endregion
  11297. #region 车辆安排
  11298. designer.SetDataSource("VehArrangeTitle", vehArranges.ItemName);
  11299. if (vehArranges.Infos.Any())
  11300. {
  11301. string currencyName = string.Empty;
  11302. //decimal rate = 1.0000M;
  11303. StringBuilder label = new StringBuilder();
  11304. foreach (var item in vehArranges.Infos)
  11305. {
  11306. label.Append(item.Remark);
  11307. label.AppendLine();
  11308. label.AppendLine();
  11309. label.Append(item.FeeName);
  11310. label.Append("\r\n\r\n费用:");
  11311. label.Append(item.FeeName);
  11312. label.Append(item.TotalAmt.TruncDecimals(2));
  11313. }
  11314. designer.SetDataSource("VehArrangeLabel", label.ToString());
  11315. }
  11316. #endregion
  11317. #region 邀请函发放对象
  11318. designer.SetDataSource("InviteToTitle", inviteTo.ItemName);
  11319. #endregion
  11320. designer.Process();
  11321. //文件名
  11322. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  11323. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  11324. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  11325. return Ok(JsonView(true, "成功", url));
  11326. }
  11327. #endregion
  11328. #region 签证费用录入
  11329. /// <summary>
  11330. /// 根据diid查询签证费用列表
  11331. /// </summary>
  11332. /// <param name="dto"></param>
  11333. /// <returns></returns>
  11334. [HttpPost]
  11335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11336. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  11337. {
  11338. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  11339. if (groupData.Code != 0)
  11340. {
  11341. return Ok(JsonView(false, groupData.Msg));
  11342. }
  11343. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11344. }
  11345. /// <summary>
  11346. /// 根据签证费用Id查询单条数据及c表数据
  11347. /// </summary>
  11348. /// <param name="dto"></param>
  11349. /// <returns></returns>
  11350. [HttpPost]
  11351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11352. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  11353. {
  11354. Result groupData = await _visaPriceRep.PostVisaById(dto);
  11355. if (groupData.Code != 0)
  11356. {
  11357. return Ok(JsonView(false, groupData.Msg));
  11358. }
  11359. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11360. }
  11361. /// <summary>
  11362. /// 签证费用删除
  11363. /// </summary>
  11364. /// <param name="dto"></param>
  11365. /// <returns></returns>
  11366. [HttpPost]
  11367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11368. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  11369. {
  11370. _sqlSugar.BeginTran();
  11371. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  11372. if (!res)
  11373. {
  11374. _sqlSugar.RollbackTran();
  11375. return Ok(JsonView(false, "删除失败"));
  11376. }
  11377. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  11378. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  11379. .SetColumns(a => new Grp_CreditCardPayment()
  11380. {
  11381. IsDel = 1,
  11382. DeleteUserId = dto.DeleteUserId,
  11383. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11384. })
  11385. .ExecuteCommand();
  11386. if (resSub < 1)
  11387. {
  11388. _sqlSugar.RollbackTran();
  11389. return Ok(JsonView(false, "删除失败"));
  11390. }
  11391. _sqlSugar.CommitTran();
  11392. return Ok(JsonView(true, "删除成功!"));
  11393. }
  11394. /// <summary>
  11395. /// 签证费用录入下拉框初始化
  11396. /// </summary>
  11397. /// <returns></returns>
  11398. [HttpPost]
  11399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11400. public async Task<IActionResult> VisaPriceAddSelect()
  11401. {
  11402. //支付方式
  11403. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  11404. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  11405. //币种
  11406. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  11407. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  11408. //乘客类型
  11409. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  11410. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  11411. //卡类型
  11412. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  11413. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  11414. //代办费类型
  11415. var agencyFeeTypeData = new List<dynamic>() {
  11416. new { id = 0 , Text = "未选择" },
  11417. new { id = 1 , Text = "小公务" },
  11418. new { id = 2 , Text = "大公务" },
  11419. };
  11420. //签证费用标准国家Data
  11421. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  11422. var data = new
  11423. {
  11424. Payment = _Payment,
  11425. CurrencyList = _CurrencyList,
  11426. PassengerType = _PassengerType,
  11427. BankCard = _BankCard,
  11428. AgencyFeeType = agencyFeeTypeData,
  11429. CountryFeeData = visaCountryFeeData
  11430. };
  11431. return Ok(JsonView(true, "查询成功!", data));
  11432. }
  11433. /// <summary>
  11434. /// 签证费用录入操作(Status:1.新增,2.修改)
  11435. /// </summary>
  11436. /// <param name="dto"></param>
  11437. /// <returns></returns>
  11438. [HttpPost]
  11439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11440. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  11441. {
  11442. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  11443. if (groupData.Code != 0)
  11444. {
  11445. return Ok(JsonView(false, groupData.Msg));
  11446. }
  11447. #region 应用推送
  11448. try
  11449. {
  11450. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11451. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11452. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11453. //2024-10-21 新增LZ UID
  11454. var userIds = new List<int>() { 21 };
  11455. string title = $"系统通知";
  11456. string content = "";
  11457. var diId = dto.DiId;
  11458. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11459. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11460. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  11461. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  11462. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11463. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  11464. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  11465. }
  11466. catch (Exception ex)
  11467. {
  11468. }
  11469. #endregion
  11470. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11471. }
  11472. #endregion
  11473. #region 签证提成录入
  11474. /// <summary>
  11475. /// 签证提成录入
  11476. /// 基础数据
  11477. /// </summary>
  11478. /// <returns></returns>
  11479. [HttpGet]
  11480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11481. public async Task<IActionResult> VisaCommissionInit()
  11482. {
  11483. return Ok(await _visaCommissionRep.Init());
  11484. }
  11485. /// <summary>
  11486. /// 签证提成录入
  11487. /// Item
  11488. /// </summary>
  11489. /// <param name="_dto"></param>
  11490. /// <returns></returns>
  11491. [HttpPost]
  11492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11493. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  11494. {
  11495. var validator = new VisaCommissionItemDtoValidator();
  11496. var validatorRes = await validator.ValidateAsync(_dto);
  11497. if (!validatorRes.IsValid)
  11498. {
  11499. StringBuilder sb = new StringBuilder();
  11500. foreach (var item in validatorRes.Errors)
  11501. {
  11502. sb.AppendLine(item.ErrorMessage);
  11503. }
  11504. return Ok(JsonView(false, sb.ToString()));
  11505. }
  11506. return Ok(await _visaCommissionRep.Item(_dto));
  11507. }
  11508. /// <summary>
  11509. /// 签证提成录入
  11510. /// Save
  11511. /// </summary>
  11512. /// <param name="_dto"></param>
  11513. /// <returns></returns>
  11514. [HttpPost]
  11515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11516. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  11517. {
  11518. //参数验证
  11519. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  11520. foreach (var item in _dto.Items)
  11521. {
  11522. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  11523. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  11524. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  11525. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  11526. }
  11527. return Ok(await _visaCommissionRep.Save(_dto));
  11528. }
  11529. /// <summary>
  11530. /// 签证提成录入
  11531. /// Create
  11532. /// </summary>
  11533. /// <param name="_dto"></param>
  11534. /// <returns></returns>
  11535. [HttpPost]
  11536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11537. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  11538. {
  11539. var validator = new VisaCommissionCreateDtoValidator();
  11540. var validatorRes = await validator.ValidateAsync(_dto);
  11541. if (!validatorRes.IsValid)
  11542. {
  11543. StringBuilder sb = new StringBuilder();
  11544. foreach (var item in validatorRes.Errors)
  11545. {
  11546. sb.AppendLine(item.ErrorMessage);
  11547. }
  11548. return Ok(JsonView(false, sb.ToString()));
  11549. }
  11550. return Ok(await _visaCommissionRep.Create(_dto));
  11551. }
  11552. /// <summary>
  11553. /// 签证提成录入
  11554. /// Put(编辑)
  11555. /// </summary>
  11556. /// <param name="id"></param>
  11557. /// <param name="_dto"></param>
  11558. /// <returns></returns>
  11559. [HttpPut]
  11560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11561. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  11562. {
  11563. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  11564. var validator = new VisaCommissionCreateDtoValidator();
  11565. var validatorRes = await validator.ValidateAsync(_dto);
  11566. if (!validatorRes.IsValid)
  11567. {
  11568. StringBuilder sb = new StringBuilder();
  11569. foreach (var item in validatorRes.Errors)
  11570. {
  11571. sb.AppendLine(item.ErrorMessage);
  11572. }
  11573. return Ok(JsonView(false, sb.ToString()));
  11574. }
  11575. return Ok(await _visaCommissionRep.Edit(id, _dto));
  11576. }
  11577. /// <summary>
  11578. /// 签证提成录入
  11579. /// Del
  11580. /// </summary>
  11581. /// <param name="id"></param>
  11582. /// <param name="currUserId"></param>
  11583. /// <returns></returns>
  11584. [HttpPost]
  11585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11586. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  11587. {
  11588. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  11589. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  11590. return Ok(await _visaCommissionRep.Del(id, currUserId));
  11591. }
  11592. #endregion
  11593. #region op费用录入
  11594. /// <summary>
  11595. /// 根据diid查询op费用列表
  11596. /// </summary>
  11597. /// <param name="dto"></param>
  11598. /// <returns></returns>
  11599. [HttpPost]
  11600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11601. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  11602. {
  11603. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  11604. if (groupData.Code != 0)
  11605. {
  11606. return Ok(JsonView(false, groupData.Msg));
  11607. }
  11608. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11609. }
  11610. /// <summary>
  11611. /// 根据op费用Id查询单条数据及c表数据
  11612. /// </summary>
  11613. /// <param name="dto"></param>
  11614. /// <returns></returns>
  11615. [HttpPost]
  11616. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11617. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  11618. {
  11619. try
  11620. {
  11621. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  11622. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  11623. var data = new
  11624. {
  11625. CarTouristGuideGround = _groupData,
  11626. CreditCardPayment = _creditCardPayment
  11627. };
  11628. return Ok(JsonView(true, "查询成功!", data));
  11629. }
  11630. catch (Exception ex)
  11631. {
  11632. return Ok(JsonView(false, "程序错误!"));
  11633. }
  11634. }
  11635. /// <summary>
  11636. /// op费用删除
  11637. /// </summary>
  11638. /// <param name="dto"></param>
  11639. /// <returns></returns>
  11640. [HttpPost]
  11641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11642. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  11643. {
  11644. try
  11645. {
  11646. _sqlSugar.BeginTran();
  11647. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  11648. if (!res)
  11649. {
  11650. return Ok(JsonView(false, "删除失败"));
  11651. }
  11652. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  11653. {
  11654. IsDel = 1,
  11655. DeleteUserId = dto.DeleteUserId,
  11656. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11657. }).ExecuteCommandAsync();
  11658. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  11659. {
  11660. IsDel = 1,
  11661. DeleteUserId = dto.DeleteUserId,
  11662. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11663. }).ExecuteCommandAsync();
  11664. #region 删除超支相关数据
  11665. //删除导入的超支数据
  11666. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  11667. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  11668. {
  11669. IsDel = 1,
  11670. DeleteUserId = dto.DeleteUserId,
  11671. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11672. }).ExecuteCommand();
  11673. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  11674. {
  11675. IsDel = 1,
  11676. DeleteUserId = dto.DeleteUserId,
  11677. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11678. }).ExecuteCommand();
  11679. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  11680. {
  11681. IsDel = 1,
  11682. DeleteUserId = dto.DeleteUserId,
  11683. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11684. }).ExecuteCommand();
  11685. #endregion
  11686. _sqlSugar.CommitTran();
  11687. return Ok(JsonView(true, "删除成功!"));
  11688. }
  11689. catch (Exception ex)
  11690. {
  11691. _sqlSugar.RollbackTran();
  11692. return Ok(JsonView(false, "程序错误!" + ex.Message));
  11693. }
  11694. }
  11695. /// <summary>
  11696. /// op费用录入操作(Status:1.新增,2.修改)
  11697. /// </summary>
  11698. /// <param name="dto"></param>
  11699. /// <returns></returns>
  11700. [HttpPost]
  11701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11702. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  11703. {
  11704. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  11705. if (groupData.Code != 0)
  11706. {
  11707. return Ok(JsonView(false, groupData.Msg));
  11708. }
  11709. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11710. }
  11711. /// <summary>
  11712. /// 填写费用详细页面初始化绑定
  11713. /// </summary>
  11714. /// <param name="dto"></param>
  11715. /// <returns></returns>
  11716. [HttpPost]
  11717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11718. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  11719. {
  11720. try
  11721. {
  11722. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  11723. if (groupData.Code != 0)
  11724. {
  11725. return Ok(JsonView(false, groupData.Msg));
  11726. }
  11727. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11728. }
  11729. catch (Exception ex)
  11730. {
  11731. return Ok(JsonView(false, ex.Message));
  11732. }
  11733. }
  11734. /// <summary>
  11735. /// 根据op费用Id查询详细数据
  11736. /// </summary>
  11737. /// <param name="dto"></param>
  11738. /// <returns></returns>
  11739. [HttpPost]
  11740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11741. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  11742. {
  11743. try
  11744. {
  11745. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  11746. if (groupData.Code != 0)
  11747. {
  11748. return Ok(JsonView(false, groupData.Msg));
  11749. }
  11750. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11751. }
  11752. catch (Exception ex)
  11753. {
  11754. return Ok(JsonView(false, ex.Message));
  11755. }
  11756. }
  11757. /// <summary>
  11758. /// OP费用录入填写详情
  11759. /// </summary>
  11760. /// <param name="dto"></param>
  11761. /// <returns></returns>
  11762. [HttpPost]
  11763. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11764. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  11765. {
  11766. try
  11767. {
  11768. #region 参数校验
  11769. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  11770. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  11771. if (di == null) return Ok(JsonView(false, "团组错误!"));
  11772. #endregion
  11773. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  11774. if (groupData.Code != 0)
  11775. {
  11776. return Ok(JsonView(false, groupData.Msg));
  11777. }
  11778. //自动审核
  11779. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  11780. #region 应用推送
  11781. try
  11782. {
  11783. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11784. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11785. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11786. //2024-10-21 新增LZ UID
  11787. var userIds = new List<int>() { 21 };
  11788. string title = $"系统通知";
  11789. var diId = dto.DiId;
  11790. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11791. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11792. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  11793. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11794. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  11795. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  11796. }
  11797. catch (Exception ex)
  11798. {
  11799. }
  11800. #endregion
  11801. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11802. }
  11803. catch (Exception ex)
  11804. {
  11805. return Ok(JsonView(false, ex.Message));
  11806. }
  11807. }
  11808. /// <summary>
  11809. /// 获取三公详细所有城市
  11810. /// </summary>
  11811. /// <returns></returns>
  11812. [HttpGet]
  11813. public IActionResult OpCarCityResult()
  11814. {
  11815. var jw = JsonView(false);
  11816. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  11817. {
  11818. x.Id,
  11819. x.Country,
  11820. x.City,
  11821. }).ToList();
  11822. if (data.Count > 0)
  11823. {
  11824. jw = JsonView(true, "获取成功!", data);
  11825. }
  11826. else
  11827. {
  11828. jw.Msg = "城市数据为空!";
  11829. jw.Data = new string[0];
  11830. }
  11831. return Ok(jw);
  11832. }
  11833. /// <summary>
  11834. /// 导出地接费用明细
  11835. /// </summary>
  11836. /// <param name="dto"></param>
  11837. /// <returns></returns>
  11838. [HttpPost]
  11839. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  11840. {
  11841. var jw = JsonView(false);
  11842. if (dto.Diid < 1)
  11843. {
  11844. jw.Msg = "请输入正确的diid!";
  11845. return Ok(jw);
  11846. }
  11847. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11848. if (group == null)
  11849. {
  11850. jw.Msg = "未找到团组信息!";
  11851. return Ok(jw);
  11852. }
  11853. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11854. if (localGuideArr.Count == 0)
  11855. {
  11856. jw.Msg = "该团组暂无地接信息!";
  11857. return Ok(jw);
  11858. }
  11859. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  11860. var overspendSoure = new Dictionary<int, int>
  11861. {
  11862. { 91, 982 }, //车
  11863. { 92 , 1059} ,//导游
  11864. { 994 , 1073}, //翻译
  11865. { 988 , 1074 }, //早餐
  11866. { 93 , 1075 }, //午餐
  11867. { 989 , 1076 }, //晚餐
  11868. };
  11869. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  11870. foreach (var groupArr in localGroup)
  11871. {
  11872. var keyValue = groupArr.Key;
  11873. if (int.TryParse(keyValue, out int cityid))
  11874. {
  11875. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  11876. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  11877. }
  11878. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  11879. foreach (var item in groupArr)
  11880. {
  11881. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  11882. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  11883. new Grp_CarTouristGuideGroundReservationsContentExtend
  11884. {
  11885. Count = a.Count,
  11886. CreateTime = a.CreateTime,
  11887. CreateUserId = a.CreateUserId,
  11888. CTGGRId = a.CTGGRId,
  11889. Currency = a.Currency,
  11890. DatePrice = a.DatePrice,
  11891. DeleteTime = a.DeleteTime,
  11892. DeleteUserId = a.DeleteUserId,
  11893. DiId = a.DiId,
  11894. Id = a.Id,
  11895. IsDel = a.IsDel,
  11896. Price = a.Price,
  11897. PriceContent = a.PriceContent,
  11898. Remark = a.Remark,
  11899. SId = a.SId,
  11900. SidName = b.Name,
  11901. Units = a.Units,
  11902. }
  11903. ).ToList();
  11904. if (content.Count > 0)
  11905. {
  11906. contentArr.Add(content);
  11907. }
  11908. }
  11909. //open excel
  11910. //set excel
  11911. //save excel
  11912. try
  11913. {
  11914. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  11915. IWorkbook workbook;
  11916. if (Path.GetExtension(filePath).ToLower() == ".xls")
  11917. {
  11918. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11919. }
  11920. else
  11921. {
  11922. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11923. }
  11924. ISheet sheet = workbook.GetSheetAt(0);
  11925. var rowStartIndex = 2;
  11926. var clounmCount = 10;
  11927. var initStyleRow = sheet.GetRow(2);
  11928. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  11929. //var overspendArrDetail =
  11930. var existsId = new List<CarCompare>();
  11931. var lastElem = arr.Last();
  11932. var thisSid = -1;
  11933. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  11934. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  11935. {
  11936. Name = "未知币种!",
  11937. Remark = "未知币种!",
  11938. };
  11939. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  11940. Action cloneRowFn = () =>
  11941. {
  11942. rowStartIndex++;
  11943. var cloneRow = sheet.CreateRow(rowStartIndex);
  11944. // 复制样式
  11945. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  11946. {
  11947. ICell sourceCell = initStyleRow.GetCell(i);
  11948. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  11949. // 确保单元格存在样式
  11950. if (sourceCell.CellStyle != null)
  11951. {
  11952. targetCell.CellStyle = sourceCell.CellStyle;
  11953. }
  11954. }
  11955. };
  11956. var mergeRow = () =>
  11957. {
  11958. for (int i = 2; i < sheet.LastRowNum; i++)
  11959. {
  11960. var row = sheet.GetRow(i);
  11961. var cellFirst = row.GetCell(0);
  11962. var thisIndex = i + 1;
  11963. while (thisIndex < sheet.LastRowNum)
  11964. {
  11965. var nextRow = sheet.GetRow(thisIndex);
  11966. var nextCellFirst = nextRow.GetCell(0);
  11967. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  11968. {
  11969. thisIndex++;
  11970. }
  11971. else
  11972. {
  11973. break;
  11974. }
  11975. }
  11976. thisIndex--;
  11977. if (thisIndex != i)
  11978. {
  11979. //合并row
  11980. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11981. i, // 起始行索引(0-based)
  11982. thisIndex, // 结束行索引(0-based)
  11983. 0, // 起始列索引(0-based)
  11984. 0 // 结束列索引(0-based)
  11985. );
  11986. sheet.AddMergedRegion(cellRangeAddress);
  11987. i = thisIndex;
  11988. }
  11989. }
  11990. };
  11991. var chaoshiNumber = 0;
  11992. var totalNumber = 0.00M;
  11993. string lastStr = "";
  11994. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  11995. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  11996. {
  11997. b.IsAuditGM,
  11998. x.Id,
  11999. x.Area,
  12000. b.PayPercentage,
  12001. b.PayMoney,
  12002. }).ToList();
  12003. string yesPayment = "", noPayment = "";
  12004. foreach (var item in queryCarArrByCityAndDiid)
  12005. {
  12006. if (item.IsAuditGM == 1)
  12007. {
  12008. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12009. }
  12010. else
  12011. {
  12012. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  12013. }
  12014. }
  12015. lastStr = yesPayment + noPayment;
  12016. foreach (var item in arr)
  12017. {
  12018. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  12019. {
  12020. if (thisSid != item.SId)
  12021. {
  12022. if (thisSid == -1)
  12023. {
  12024. thisSid = item.SId;
  12025. }
  12026. else
  12027. {
  12028. //合并小计行
  12029. //创建合并区域的实例
  12030. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12031. rowStartIndex, // 起始行索引(0-based)
  12032. rowStartIndex, // 结束行索引(0-based)
  12033. 0, // 起始列索引(0-based)
  12034. 3 // 结束列索引(0-based)
  12035. );
  12036. sheet.AddMergedRegion(cellRangeAddress);
  12037. var CellStyle = workbook.CreateCellStyle();
  12038. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12039. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  12040. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  12041. for (int i = 0; i <= clounmCount; i++)
  12042. {
  12043. if (i > 6)
  12044. {
  12045. var CellStyle1 = workbook.CreateCellStyle();
  12046. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12047. IFont Font = workbook.CreateFont(); // 创建字体
  12048. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  12049. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12050. CellStyle1.SetFont(Font);
  12051. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  12052. }
  12053. else
  12054. {
  12055. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  12056. }
  12057. }
  12058. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  12059. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  12060. //超时合计
  12061. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  12062. //超时数
  12063. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  12064. //超时合计费用
  12065. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  12066. thisSid = item.SId;
  12067. cloneRowFn();
  12068. chaoshiNumber = 0;
  12069. totalNumber = 0;
  12070. }
  12071. }
  12072. IRow row = sheet.GetRow(rowStartIndex);
  12073. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12074. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  12075. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  12076. if (isOpenOverspendSoure)
  12077. {
  12078. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12079. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  12080. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  12081. }
  12082. for (int i = 0; i <= clounmCount; i++)
  12083. {
  12084. var cell = row.GetCell(i);
  12085. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  12086. if (cell == null)
  12087. {
  12088. cell = row.CreateCell(i);
  12089. }
  12090. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  12091. fontRed.CloneStyleFrom(cell.CellStyle);
  12092. IFont Font = workbook.CreateFont(); // 创建字体
  12093. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  12094. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12095. fontRed.SetFont(Font);
  12096. byte[] rgb = new byte[3] { 255, 242, 204 };
  12097. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  12098. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  12099. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  12100. if (workbook is XSSFWorkbook)
  12101. {
  12102. BackgroundColor255_242_204.FillForegroundColor = 0;
  12103. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  12104. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  12105. }
  12106. else
  12107. {
  12108. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  12109. }
  12110. if (i == 1 || i > 6)
  12111. {
  12112. if (i > 6)
  12113. {
  12114. fontRed.FillForegroundColor = 0;
  12115. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  12116. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  12117. }
  12118. cell.CellStyle = fontRed;
  12119. }
  12120. if (i > 2 && i < 7)
  12121. {
  12122. cell.CellStyle = BackgroundColor255_242_204;
  12123. }
  12124. cell.SetCellValue(setCellValue); //写入单元格
  12125. }
  12126. if (overspendSoure.ContainsKey(thisSid))
  12127. {
  12128. var overspendId = overspendSoure[thisSid];
  12129. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  12130. }
  12131. cloneRowFn();
  12132. existsId.Add(new CarCompare
  12133. {
  12134. DataPrice = item.DatePrice.ObjToDate(),
  12135. Sid = item.SId
  12136. });
  12137. }
  12138. if (item.Equals(lastElem))
  12139. {
  12140. //合并小计行
  12141. //创建合并区域的实例
  12142. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  12143. rowStartIndex, // 起始行索引(0-based)
  12144. rowStartIndex, // 结束行索引(0-based)
  12145. 0, // 起始列索引(0-based)
  12146. 3 // 结束列索引(0-based)
  12147. );
  12148. sheet.AddMergedRegion(cellRangeAddress);
  12149. var CellStyle = workbook.CreateCellStyle();
  12150. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12151. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  12152. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  12153. for (int i = 0; i <= clounmCount; i++)
  12154. {
  12155. if (i > 6)
  12156. {
  12157. var CellStyle1 = workbook.CreateCellStyle();
  12158. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  12159. IFont Font = workbook.CreateFont(); // 创建字体
  12160. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  12161. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  12162. CellStyle1.SetFont(Font);
  12163. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  12164. }
  12165. else
  12166. {
  12167. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  12168. }
  12169. }
  12170. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  12171. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  12172. //超时合计
  12173. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  12174. //超时数
  12175. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  12176. //超时合计费用
  12177. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  12178. cloneRowFn();
  12179. // 创建合并区域的实例
  12180. cellRangeAddress = new CellRangeAddress(
  12181. rowStartIndex, // 起始行索引(0-based)
  12182. rowStartIndex, // 结束行索引(0-based)
  12183. 0, // 起始列索引(0-based)
  12184. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  12185. );
  12186. // 添加合并区域
  12187. sheet.AddMergedRegion(cellRangeAddress);
  12188. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  12189. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  12190. }
  12191. }
  12192. mergeRow();
  12193. // 保存修改后的Excel文件到新文件
  12194. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  12195. // new FileStream(newFilePath, FileMode.CreateNew)
  12196. using (var stream = new MemoryStream())
  12197. {
  12198. workbook.Write(stream, true);
  12199. stream.Flush();
  12200. stream.Seek(0, SeekOrigin.Begin);
  12201. MemoryStream memoryStream = new MemoryStream();
  12202. stream.CopyTo(memoryStream);
  12203. memoryStream.Seek(0, SeekOrigin.Begin);
  12204. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  12205. }
  12206. workbook.Close();
  12207. workbook.Dispose();
  12208. }
  12209. catch (Exception ex)
  12210. {
  12211. jw.Msg = "出现异常!" + ex.Message;
  12212. return Ok(jw);
  12213. }
  12214. }
  12215. if (Zips.Count > 0)
  12216. {
  12217. IOOperatorHelper io = new IOOperatorHelper();
  12218. var byts = io.ConvertZipStream(Zips);
  12219. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  12220. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  12221. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  12222. }
  12223. else
  12224. {
  12225. jw.Msg = "暂无生成文件!";
  12226. }
  12227. return Ok(jw);
  12228. }
  12229. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  12230. {
  12231. string outStr = string.Empty;
  12232. switch (i)
  12233. {
  12234. case 0:
  12235. outStr = arr[0].SidName;
  12236. break;
  12237. case 1:
  12238. outStr = arr[0].DataPriceStr;
  12239. break;
  12240. case 2:
  12241. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  12242. break;
  12243. case 4:
  12244. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  12245. break;
  12246. case 7:
  12247. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12248. {
  12249. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  12250. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  12251. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  12252. }
  12253. break;
  12254. case 8:
  12255. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12256. {
  12257. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  12258. }
  12259. break;
  12260. case 9:
  12261. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12262. {
  12263. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  12264. }
  12265. break;
  12266. case 10:
  12267. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  12268. {
  12269. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  12270. }
  12271. break;
  12272. }
  12273. return outStr;
  12274. }
  12275. #region OP行程单
  12276. /// <summary>
  12277. /// OP行程单初始化
  12278. /// </summary>
  12279. /// <param name="dto"></param>
  12280. /// <returns></returns>
  12281. [HttpPost]
  12282. public IActionResult InitOpTravel(InitOpTravelDto dto)
  12283. {
  12284. var jw = JsonView(false);
  12285. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  12286. var group = groupList.First();
  12287. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  12288. if (group == null)
  12289. {
  12290. jw.Msg = "暂无团组!";
  12291. return Ok(jw);
  12292. }
  12293. group = groupList.Find(x => x.Id == diid);
  12294. if (group == null)
  12295. {
  12296. jw.Msg = "请输入正确的团组ID!";
  12297. return Ok(jw);
  12298. }
  12299. string city = string.Empty;
  12300. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  12301. if (blackCode.Count > 0)
  12302. {
  12303. var black = blackCode.First();
  12304. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  12305. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  12306. if (blackSp.Length > 0)
  12307. {
  12308. try
  12309. {
  12310. var cityArrCode = new List<string>(20);
  12311. foreach (var item in blackSp)
  12312. {
  12313. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  12314. var IndexSelect = itemSp[2];
  12315. var cityArrCodeLength = cityArrCode.Count - 1;
  12316. var startCity = IndexSelect.Substring(0, 3);
  12317. if (cityArrCodeLength > 0)
  12318. {
  12319. var arrEndCity = cityArrCode[cityArrCodeLength];
  12320. if (arrEndCity != startCity)
  12321. {
  12322. cityArrCode.Add(startCity.ToUpper());
  12323. }
  12324. }
  12325. else
  12326. {
  12327. cityArrCode.Add(startCity.ToUpper());
  12328. }
  12329. var endCity = IndexSelect.Substring(3, 3);
  12330. cityArrCode.Add(endCity.ToUpper());
  12331. }
  12332. var cityThree = string.Empty;
  12333. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  12334. cityThree = cityThree.TrimEnd(',');
  12335. if (string.IsNullOrWhiteSpace(cityThree))
  12336. {
  12337. throw new
  12338. Exception("error");
  12339. }
  12340. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  12341. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  12342. foreach (var item in cityArrCode)
  12343. {
  12344. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  12345. if (find != null)
  12346. {
  12347. city += find.City + "/";
  12348. }
  12349. else
  12350. {
  12351. city += item + "三字码未收入/";
  12352. }
  12353. }
  12354. city = city.TrimEnd('/');
  12355. }
  12356. catch (Exception e)
  12357. {
  12358. city = "黑屏代码格式不正确!";
  12359. }
  12360. }
  12361. }
  12362. else
  12363. {
  12364. city = "未录入黑屏代码";
  12365. }
  12366. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  12367. {
  12368. Date = x.Date,
  12369. Days = x.Days,
  12370. Diffgroup = x.Diffgroup,
  12371. Diid = x.Diid,
  12372. Traffic_First = x.Traffic_First,
  12373. Traffic_Second = x.Traffic_Second,
  12374. Trip = x.Trip,
  12375. WeekDay = x.WeekDay,
  12376. Id = x.Id
  12377. }).ToList();
  12378. jw.Data = new
  12379. {
  12380. groupList = groupList.Select(x => new
  12381. {
  12382. x.Id,
  12383. x.TeamName,
  12384. x.TourCode
  12385. }).ToList(),
  12386. groupInfo = new
  12387. {
  12388. group.VisitDays,
  12389. group.TourCode,
  12390. group.VisitPNumber,
  12391. group.TeamName,
  12392. city
  12393. },
  12394. OpTravelList
  12395. };
  12396. jw.Code = 200;
  12397. jw.Msg = "操作成功!";
  12398. return Ok(jw);
  12399. }
  12400. /// <summary>
  12401. /// 删除团组行程单
  12402. /// </summary>
  12403. /// <returns></returns>
  12404. [HttpPost]
  12405. public IActionResult DelTravel(DelOpTravelDto dto)
  12406. {
  12407. var jw = JsonView(false);
  12408. if (dto.UserId <= 0 || dto.Diid <= 0)
  12409. {
  12410. jw.Msg = "请输入正确的参数!";
  12411. return Ok(jw);
  12412. }
  12413. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  12414. .SetColumns(x => new Grp_TravelList
  12415. {
  12416. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  12417. DeleteUserId = dto.UserId,
  12418. IsDel = 1,
  12419. }).ExecuteCommand();
  12420. jw = JsonView(true);
  12421. return Ok(jw);
  12422. }
  12423. /// <summary>
  12424. /// 行程单保存
  12425. /// </summary>
  12426. /// <returns></returns>
  12427. [HttpPost]
  12428. public IActionResult TravelSave(TravelSaveDto dto)
  12429. {
  12430. var jw = JsonView(false);
  12431. if (dto.Arr.Count > 0)
  12432. {
  12433. try
  12434. {
  12435. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  12436. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  12437. .ToList();
  12438. _sqlSugar.BeginTran();
  12439. foreach (var item in dto.Arr)
  12440. {
  12441. if (item.Id == 0)
  12442. {
  12443. throw new Exception("请传入正确的Id");
  12444. }
  12445. //比较上一次的差异
  12446. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  12447. if (findTravel != null)
  12448. {
  12449. item.Trip = item.Trip.Replace("[++]", string.Empty);
  12450. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  12451. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  12452. }
  12453. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  12454. .SetColumns(x => new Grp_TravelList
  12455. {
  12456. Trip = item.Trip
  12457. }).ExecuteCommand();
  12458. }
  12459. _sqlSugar.CommitTran();
  12460. jw = JsonView(true);
  12461. }
  12462. catch (Exception ex)
  12463. {
  12464. _sqlSugar.RollbackTran();
  12465. jw.Msg = "程序异常!" + ex.Message;
  12466. }
  12467. }
  12468. else
  12469. {
  12470. jw.Msg = "请传入正确的参数!";
  12471. }
  12472. return Ok(jw);
  12473. }
  12474. private string CheckStr(string original, string changed)
  12475. {
  12476. // 创建diff_match_patch对象
  12477. var dmp = new diff_match_patch();
  12478. // 计算差异
  12479. List<Diff> diffs = dmp.diff_main(original, changed);
  12480. // 清理和合并差异
  12481. dmp.diff_cleanupSemantic(diffs);
  12482. // 使用StringBuilder构建最终的字符串
  12483. StringBuilder finalString = new StringBuilder();
  12484. // 输出差异结果,并构建变动后的字符串
  12485. foreach (Diff diff in diffs)
  12486. {
  12487. switch (diff.operation)
  12488. {
  12489. case Operation.EQUAL:
  12490. // 相等的部分,直接添加到最终字符串
  12491. finalString.Append(diff.text);
  12492. break;
  12493. case Operation.INSERT:
  12494. // 插入的部分,添加标记并添加到最终字符串
  12495. finalString.Append("[++]" + diff.text + "[++]");
  12496. break;
  12497. case Operation.DELETE:
  12498. // 删除的部分,不添加到最终字符串
  12499. //finalString.Append("[++]" + diff.text + "[++]");
  12500. break;
  12501. }
  12502. }
  12503. // 输出变动后的字符串
  12504. return finalString.ToString();
  12505. }
  12506. private class tagContent
  12507. {
  12508. public DateTime Date { get; set; }
  12509. public string StartTag { get; set; }
  12510. public string EndTag { get; set; }
  12511. public string Content { get; set; }
  12512. public static int tagLength { get { return 3; } }
  12513. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  12514. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  12515. public bool IsFinally { get; set; }
  12516. }
  12517. private List<string> ExtractContentBetweenTags(string input, string tag)
  12518. {
  12519. List<string> results = new List<string>();
  12520. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  12521. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  12522. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  12523. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  12524. string[] strValueArr = new string[1];
  12525. foreach (System.Text.RegularExpressions.Match match in matches)
  12526. {
  12527. var strValue = match.Groups[1].Value;
  12528. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  12529. }
  12530. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  12531. return results;
  12532. }
  12533. /// <summary>
  12534. /// 导出行程单
  12535. /// </summary>
  12536. /// <param name="dto"></param>
  12537. /// <returns></returns>
  12538. [HttpPost]
  12539. public IActionResult ExportTravel(ExportTravelDto dto)
  12540. {
  12541. var jw = JsonView(false);
  12542. jw.Data = "";
  12543. int diid = 0;
  12544. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  12545. if (Find == null)
  12546. {
  12547. jw.Msg = "请选择正确的团组!";
  12548. return Ok(jw);
  12549. }
  12550. else
  12551. {
  12552. diid = Find.Id;
  12553. }
  12554. //数据源
  12555. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  12556. DataTable dtBlack = null;
  12557. try
  12558. {
  12559. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  12560. }
  12561. catch (Exception)
  12562. {
  12563. jw.Msg = "机票黑屏代码有误!";
  12564. return Ok(jw);
  12565. }
  12566. string CityStr = string.Empty;
  12567. if (dtBlack.Rows.Count == 0)
  12568. {
  12569. jw.Msg = "机票黑屏代码有误!";
  12570. return Ok(jw);
  12571. }
  12572. else
  12573. {
  12574. foreach (DataRow row in dtBlack.Rows)
  12575. {
  12576. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12577. {
  12578. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  12579. return Ok(jw);
  12580. }
  12581. }
  12582. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  12583. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  12584. }
  12585. // 指定的文字
  12586. var targetTextDic = new Dictionary<string, List<string>>();
  12587. //创建数据源Table
  12588. DataTable dtSource = new DataTable();
  12589. dtSource.Columns.Add("Days", typeof(string));
  12590. dtSource.Columns.Add("Date", typeof(string));
  12591. dtSource.Columns.Add("Week", typeof(string));
  12592. dtSource.Columns.Add("Traffic", typeof(string));
  12593. dtSource.Columns.Add("Trip", typeof(string));
  12594. //获取数据,放到datatable
  12595. foreach (var item in _travelList)
  12596. {
  12597. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  12598. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  12599. .Replace(tagContent.TagFormat.Item2, string.Empty)
  12600. .Replace("[++]", string.Empty);
  12601. DataRow dr = dtSource.NewRow();
  12602. dr["Days"] = item.Days;
  12603. dr["Date"] = item.Date;
  12604. dr["Week"] = item.WeekDay;
  12605. dr["Traffic"] = item.Traffic_First
  12606. + "\r\n"
  12607. + item.Traffic_Second;
  12608. dr["Trip"] = item.Trip;
  12609. dtSource.Rows.Add(dr);
  12610. }
  12611. Dictionary<string, string> dic = new Dictionary<string, string>();
  12612. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  12613. dic.Add("City", CityStr);
  12614. dic.Add("Days", Find.VisitDays.ToString());
  12615. dic.Add("DeleCode", Find.TourCode);
  12616. dic.Add("Pnum", Find.VisitPNumber.ToString());
  12617. //模板路径
  12618. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  12619. //载入模板
  12620. Document doc = null;
  12621. DocumentBuilder builder = null;
  12622. try
  12623. {
  12624. //载入模板
  12625. doc = new Document(tempPath);
  12626. builder = new DocumentBuilder(doc);
  12627. }
  12628. catch (Exception)
  12629. {
  12630. jw.Msg = "模板位置不存在!";
  12631. return Ok(jw);
  12632. }
  12633. foreach (var key in dic.Keys)
  12634. {
  12635. Bookmark bookmark = doc.Range.Bookmarks[key];
  12636. if (bookmark != null)
  12637. {
  12638. builder.MoveToBookmark(key);
  12639. builder.Write(dic[key]);
  12640. }
  12641. }
  12642. //获取word里所有表格
  12643. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12644. //获取所填表格的序数
  12645. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12646. try
  12647. {
  12648. //循环赋值
  12649. for (int i = 0; i < dtSource.Rows.Count; i++)
  12650. {
  12651. builder.MoveToCell(0, i + 1, 0, 0);
  12652. builder.Write(dtSource.Rows[i]["Days"].ToString());
  12653. builder.MoveToCell(0, i + 1, 1, 0);
  12654. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  12655. builder.MoveToCell(0, i + 1, 2, 0);
  12656. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  12657. var trip = dtSource.Rows[i]["Trip"].ToString();
  12658. builder.MoveToCell(0, i + 1, 3, 0);
  12659. builder.Write(trip);
  12660. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  12661. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12662. // 获取特定索引的段落
  12663. Paragraph paragraph = (Paragraph)paragraphs[0];
  12664. Run run = paragraph.Runs[0];
  12665. Aspose.Words.Font font = run.Font;
  12666. font.Name = "黑体";
  12667. //设置双休红色
  12668. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  12669. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12670. paragraph = (Paragraph)paragraphs[1];
  12671. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  12672. {
  12673. run = paragraph.Runs[0];
  12674. font = run.Font;
  12675. font.Color = Color.Red;
  12676. }
  12677. }
  12678. }
  12679. catch (Exception ex)
  12680. {
  12681. }
  12682. //删除多余行
  12683. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  12684. {
  12685. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  12686. }
  12687. var targetTextList = new List<string>();
  12688. // 遍历文档中的表格
  12689. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  12690. {
  12691. foreach (Aspose.Words.Tables.Row row in table.Rows)
  12692. {
  12693. var cellIndex = 0;
  12694. foreach (Cell cell in row.Cells)
  12695. {
  12696. if (cellIndex == 1 && row.Cells.Count == 4)
  12697. {
  12698. foreach (var target in targetTextDic.Keys)
  12699. {
  12700. if (cell.GetText().Contains(target))
  12701. {
  12702. targetTextList = targetTextDic[target];
  12703. break;
  12704. }
  12705. }
  12706. }
  12707. // 遍历单元格中的所有段落
  12708. foreach (Paragraph paragraph in cell.Paragraphs)
  12709. {
  12710. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  12711. List<Run> runs = new List<Run>();
  12712. foreach (Run run in paragraph.Runs)
  12713. {
  12714. runs.Add(run);
  12715. }
  12716. foreach (Run run in runs)
  12717. {
  12718. foreach (var targetText in targetTextList)
  12719. {
  12720. // 检查文字是否包含指定文字
  12721. if (run.Text.Contains(targetText))
  12722. {
  12723. // 将包含的部分设置为红色
  12724. HighlightText(run, targetText, Color.Red);
  12725. }
  12726. }
  12727. }
  12728. }
  12729. cellIndex++;
  12730. }
  12731. }
  12732. }
  12733. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  12734. if (!Directory.Exists(savePath))
  12735. {
  12736. try
  12737. {
  12738. Directory.CreateDirectory(savePath);
  12739. }
  12740. catch
  12741. {
  12742. }
  12743. }
  12744. string path = savePath + Find.TeamName + "出访日程";
  12745. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  12746. try
  12747. {
  12748. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  12749. string postfix = ".docx";
  12750. if (dto.IsPDF == 1)
  12751. {
  12752. saveFormat = Aspose.Words.SaveFormat.Pdf;
  12753. postfix = ".pdf";
  12754. }
  12755. doc.Save(path + postfix, saveFormat);
  12756. jw = JsonView(true, "导出成功", ftpPath + postfix);
  12757. }
  12758. catch (Exception)
  12759. {
  12760. jw = JsonView(false);
  12761. }
  12762. return Ok(jw);
  12763. }
  12764. /// <summary>
  12765. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  12766. /// </summary>
  12767. /// <param name="num"></param>
  12768. /// <returns></returns>
  12769. string GetNum(string num)
  12770. {
  12771. string str = "";
  12772. switch (num)
  12773. {
  12774. case "1":
  12775. str = "一";
  12776. break;
  12777. case "2":
  12778. str = "二";
  12779. break;
  12780. case "3":
  12781. str = "三";
  12782. break;
  12783. case "4":
  12784. str = "四";
  12785. break;
  12786. case "5":
  12787. str = "五";
  12788. break;
  12789. case "6":
  12790. str = "六";
  12791. break;
  12792. case "7":
  12793. str = "七";
  12794. break;
  12795. case "8":
  12796. str = "八";
  12797. break;
  12798. case "9":
  12799. str = "九";
  12800. break;
  12801. case "10":
  12802. str = "十";
  12803. break;
  12804. case "11":
  12805. str = "十一";
  12806. break;
  12807. case "12":
  12808. str = "十二";
  12809. break;
  12810. case "一":
  12811. str = "1";
  12812. break;
  12813. case "二":
  12814. str = "2";
  12815. break;
  12816. case "三":
  12817. str = "3";
  12818. break;
  12819. case "四":
  12820. str = "4";
  12821. break;
  12822. case "五":
  12823. str = "5";
  12824. break;
  12825. case "六":
  12826. str = "6";
  12827. break;
  12828. case "七":
  12829. str = "7";
  12830. break;
  12831. case "八":
  12832. str = "8";
  12833. break;
  12834. case "九":
  12835. str = "9";
  12836. break;
  12837. case "十":
  12838. str = "10";
  12839. break;
  12840. case "十一":
  12841. str = "11";
  12842. break;
  12843. case "十二":
  12844. str = "12";
  12845. break;
  12846. }
  12847. return str;
  12848. }
  12849. // 高亮包含指定文字的部分
  12850. void HighlightText(Run run, string targetText, Color color)
  12851. {
  12852. string text = run.Text;
  12853. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  12854. if (startIndex >= 0)
  12855. {
  12856. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  12857. // 前部分
  12858. if (startIndex > 0)
  12859. {
  12860. Run beforeRun = (Run)run.Clone(true);
  12861. beforeRun.Text = text.Substring(0, startIndex);
  12862. parentParagraph.InsertBefore(beforeRun, run);
  12863. }
  12864. // 匹配部分
  12865. Run matchRun = (Run)run.Clone(true);
  12866. matchRun.Text = text.Substring(startIndex, targetText.Length);
  12867. matchRun.Font.Color = color;
  12868. parentParagraph.InsertBefore(matchRun, run);
  12869. // 后部分
  12870. if (startIndex + targetText.Length < text.Length)
  12871. {
  12872. Run afterRun = (Run)run.Clone(true);
  12873. afterRun.Text = text.Substring(startIndex + targetText.Length);
  12874. parentParagraph.InsertBefore(afterRun, run);
  12875. }
  12876. // 删除原始Run
  12877. run.Remove();
  12878. }
  12879. }
  12880. #endregion
  12881. #endregion
  12882. #region 团组成本
  12883. /// <summary>
  12884. /// 团组成本数据初始化
  12885. /// </summary>
  12886. /// <param name="dto"></param>
  12887. /// <returns></returns>
  12888. [HttpPost]
  12889. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  12890. {
  12891. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  12892. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  12893. WHEN COUNT(*) >= 0 THEN 'True'
  12894. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  12895. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  12896. ").ToList(); //团组列表
  12897. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  12898. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  12899. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  12900. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  12901. if (groupinfoValue != null)
  12902. {
  12903. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  12904. var spArr = new string[1] { countryArr };
  12905. if (countryArr.Contains("|"))
  12906. {
  12907. spArr = countryArr.Split("|");
  12908. }
  12909. else if (countryArr.Contains("、"))
  12910. {
  12911. spArr = countryArr.Split("、");
  12912. }
  12913. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  12914. {
  12915. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  12916. if (dbQueryCountry != null)
  12917. {
  12918. visaCountryInfoArr.Add(dbQueryCountry);
  12919. }
  12920. }
  12921. }
  12922. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  12923. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  12924. #region 屏蔽黑屏代码生成
  12925. //var create = _GroupCostRepository.
  12926. // CreateGroupCostByBlackCode(dto.Diid);
  12927. //if (groupCost.Count == 0 && create.Code == 0)
  12928. //{
  12929. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  12930. //}
  12931. #endregion
  12932. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  12933. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  12934. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  12935. groupCostMap = groupCostMap.Select(x =>
  12936. {
  12937. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  12938. {
  12939. x.Date = dataForamt.ToString("yyyy-MM-dd");
  12940. }
  12941. return x;
  12942. }).ToList();
  12943. //GroupCostParameter.Add(new
  12944. // Grp_GroupCostParameter());
  12945. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  12946. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  12947. return Ok(JsonView(new
  12948. {
  12949. groupList,
  12950. groupInfo,
  12951. groupChecks,
  12952. groupCost = groupCostMap,
  12953. hotelNumber,
  12954. GroupCostParameter = GroupCostParameterMap,
  12955. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  12956. {
  12957. x.VisaCountry,
  12958. x.VisaPrice,
  12959. x.Id,
  12960. }).ToList(),
  12961. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  12962. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x=>x.IsDel == 0 && x.DiId == diid).Any() , //create.Code == 0 ? true : false,
  12963. hotelIsTrue = hotelIsTrue,
  12964. }));
  12965. }
  12966. /// <summary>
  12967. /// 团组成本信息保存
  12968. /// </summary>
  12969. /// <param name="dto"></param>
  12970. /// <returns></returns>
  12971. [HttpPost]
  12972. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  12973. {
  12974. if (dto.Diid <= 0 || dto.Userid <= 0)
  12975. {
  12976. return Ok(JsonView(false));
  12977. }
  12978. JsonView jw = null;
  12979. bool isTrue = false;
  12980. #region 复制团组成本
  12981. //if (dto.Diid == 2581)
  12982. //{
  12983. // dto.Diid = 2599;
  12984. // dto.CheckBoxs.ForEach(x =>
  12985. // {
  12986. // x.Diid = 2599;
  12987. // });
  12988. // dto.GroupCosts.ForEach(x =>
  12989. // {
  12990. // x.Diid = 2599;
  12991. // });
  12992. // dto.CostTypeHotelNumbers.ForEach(x =>
  12993. // {
  12994. // x.Diid = 2599;
  12995. // });
  12996. // dto.GroupCostParameters.ForEach(x =>
  12997. // {
  12998. // x.DiId = 2599;
  12999. // });
  13000. //}
  13001. #endregion
  13002. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  13003. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  13004. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  13005. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  13006. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  13007. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  13008. try
  13009. {
  13010. _sqlSugar.BeginTran();
  13011. isTrue = await _GroupCostRepository.
  13012. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  13013. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  13014. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  13015. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  13016. _sqlSugar.CommitTran();
  13017. jw = JsonView(true, "保存成功!", isTrue);
  13018. }
  13019. catch (Exception)
  13020. {
  13021. _sqlSugar.RollbackTran();
  13022. jw = JsonView(false);
  13023. }
  13024. return Ok(jw);
  13025. }
  13026. /// <summary>
  13027. /// 司兼导数据
  13028. /// </summary>
  13029. /// <param name="dto"></param>
  13030. /// <returns></returns>
  13031. [HttpPost]
  13032. public IActionResult GetCarGuides(CarGuidesDto dto)
  13033. {
  13034. JsonView jw = null;
  13035. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  13036. jw = JsonView(true, "获取成功!", Data);
  13037. return Ok(jw);
  13038. }
  13039. /// <summary>
  13040. /// 导游数据
  13041. /// </summary>
  13042. /// <param name="dto"></param>
  13043. /// <returns></returns>
  13044. [HttpPost]
  13045. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  13046. {
  13047. JsonView jw = null;
  13048. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  13049. // 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
  13050. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  13051. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  13052. jw = JsonView(true, "获取成功!", Data);
  13053. return Ok(jw);
  13054. }
  13055. /// <summary>
  13056. /// 成本车数据
  13057. /// </summary>
  13058. /// <param name="dto"></param>
  13059. /// <returns></returns>
  13060. [HttpPost]
  13061. public IActionResult GetCarInfo(CarGuidesDto dto)
  13062. {
  13063. JsonView jw = null;
  13064. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  13065. jw = JsonView(true, "获取成功!", Data);
  13066. return Ok(jw);
  13067. }
  13068. /// <summary>
  13069. /// 景点数据
  13070. /// </summary>
  13071. /// <param name="dto"></param>
  13072. /// <returns></returns>
  13073. [HttpPost]
  13074. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  13075. {
  13076. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  13077. return Ok(JsonView(true, "获取成功!", Data));
  13078. }
  13079. /// <summary>
  13080. /// 成本通知
  13081. /// </summary>
  13082. /// <param name="dto"></param>
  13083. /// <returns></returns>
  13084. [HttpPost]
  13085. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  13086. {
  13087. if (dto.Diid < 0)
  13088. {
  13089. return Ok(JsonView(false));
  13090. }
  13091. JsonView jw = null;
  13092. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  13093. if (GroupCostParameter != null)
  13094. {
  13095. int IsShare = 0;
  13096. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  13097. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  13098. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  13099. string msg = string.Empty;
  13100. if (isTrue)
  13101. {
  13102. if (IsShare == 0)
  13103. {
  13104. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  13105. }
  13106. else
  13107. {
  13108. #region 企微通知对应岗位用户
  13109. try
  13110. {
  13111. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  13112. }
  13113. catch (Exception ex)
  13114. {
  13115. }
  13116. #endregion
  13117. msg = "通知成功,其他模块操作人员可见此成本信息!";
  13118. }
  13119. jw = JsonView(isTrue, msg, new { IsShare });
  13120. }
  13121. else
  13122. {
  13123. msg = "修改失败!";
  13124. jw = JsonView(isTrue, msg);
  13125. }
  13126. }
  13127. else
  13128. {
  13129. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  13130. }
  13131. return Ok(jw);
  13132. }
  13133. /// <summary>
  13134. /// 导出报价单
  13135. /// </summary>
  13136. /// <param name="dto"></param>
  13137. /// <returns></returns>
  13138. [HttpPost]
  13139. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  13140. {
  13141. if (dto.Diid == 0)
  13142. {
  13143. return Ok(JsonView(false, "请传递团组id"));
  13144. }
  13145. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13146. if (deleInfo.Code != 0)
  13147. {
  13148. return Ok(JsonView(false, "团组信息查询失败!"));
  13149. }
  13150. var di = deleInfo.Data as DelegationInfoWebView;
  13151. if (di != null)
  13152. {
  13153. di.TeamName = di.TeamName.Replace("|", "、");
  13154. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  13155. //文件名
  13156. string strFileName = di.TeamName + "-收款账单.doc";
  13157. //获取模板
  13158. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  13159. //载入模板
  13160. Document doc = new Document(tmppath);
  13161. decimal TotalPrice = 0.00M;
  13162. string itemStr = string.Empty;
  13163. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  13164. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  13165. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  13166. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  13167. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  13168. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  13169. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  13170. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  13171. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  13172. foreach (var cost in groupCostType)
  13173. {
  13174. var List = cost.ToList();
  13175. if (cost.Key == "A")
  13176. {
  13177. foreach (var ListItem in List)
  13178. {
  13179. if (ListItem.number > 0)
  13180. {
  13181. if (ListItem.code.Contains("TBR"))
  13182. {
  13183. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13184. }
  13185. else
  13186. {
  13187. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13188. }
  13189. TotalPrice += (ListItem.number * ListItem.price);
  13190. }
  13191. }
  13192. }
  13193. else
  13194. {
  13195. itemStr = itemStr.Insert(0, "A段\r\n");
  13196. itemStr += "B段\r\n";
  13197. foreach (var ListItem in List)
  13198. {
  13199. if (ListItem.number > 0)
  13200. {
  13201. if (ListItem.code.Contains("TBR"))
  13202. {
  13203. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13204. }
  13205. else
  13206. {
  13207. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  13208. }
  13209. TotalPrice += (ListItem.number * ListItem.price);
  13210. }
  13211. }
  13212. }
  13213. }
  13214. #region 替换Word模板书签内容
  13215. Dictionary<string, string> marks = new Dictionary<string, string>();
  13216. marks.Add("To", di.ClientUnit);//付款方
  13217. marks.Add("ToTel", di.TellPhone);//付款方电话
  13218. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  13219. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  13220. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  13221. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  13222. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  13223. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  13224. marks.Add("PayItemContent", itemStr);//详细信息
  13225. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  13226. #endregion
  13227. ////注
  13228. //if (doc.Range.Bookmarks["Attention"] != null)
  13229. //{
  13230. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  13231. // mark.Text = frList[0].Attention;
  13232. //}
  13233. foreach (var item in marks.Keys)
  13234. {
  13235. if (doc.Range.Bookmarks[item] != null)
  13236. {
  13237. Bookmark mark = doc.Range.Bookmarks[item];
  13238. mark.Text = marks[item];
  13239. }
  13240. }
  13241. byte[] bytes = null;
  13242. using (MemoryStream stream = new MemoryStream())
  13243. {
  13244. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13245. bytes = stream.ToArray();
  13246. }
  13247. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  13248. return Ok(JsonView(true, "", new
  13249. {
  13250. Data = bytes,
  13251. strFileName,
  13252. }));
  13253. }
  13254. else
  13255. {
  13256. return Ok(JsonView(false, "团组信息不存在!"));
  13257. }
  13258. }
  13259. /// <summary>
  13260. /// 导出团组成本
  13261. /// </summary>
  13262. /// <param name="dto"></param>
  13263. /// <returns></returns>
  13264. [HttpPost]
  13265. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  13266. {
  13267. var jw = JsonView(false);
  13268. if (dto.Diid == 0)
  13269. {
  13270. return Ok(JsonView(false, "请传递团组id"));
  13271. }
  13272. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13273. if (deleInfo.Code != 0)
  13274. {
  13275. return Ok(JsonView(false, "团组信息查询失败!"));
  13276. }
  13277. var di = deleInfo.Data as DelegationInfoWebView;
  13278. if (di == null)
  13279. {
  13280. return Ok(JsonView(false, "团组信息查询失败!"));
  13281. }
  13282. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  13283. WorkbookDesigner designer = new WorkbookDesigner();
  13284. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  13285. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  13286. for (int i = 0; i < List_GC.Count; i++)
  13287. {
  13288. GroupCost_Excel gc = new GroupCost_Excel();
  13289. gc.Id = List_GC[i].Id;
  13290. gc.Diid = List_GC[i].Diid.ToString();
  13291. gc.DAY = List_GC[i].DAY;
  13292. string week = "";
  13293. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  13294. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  13295. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  13296. gc.ITIN = List_GC[i].ITIN;
  13297. gc.CarType = List_GC[i].CarType;
  13298. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  13299. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  13300. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  13301. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  13302. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  13303. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  13304. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  13305. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  13306. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  13307. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  13308. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  13309. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  13310. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  13311. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  13312. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  13313. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  13314. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  13315. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  13316. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  13317. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  13318. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  13319. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  13320. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  13321. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  13322. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  13323. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  13324. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  13325. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  13326. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  13327. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  13328. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  13329. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  13330. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  13331. List_GC1.Add(gc);
  13332. }
  13333. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  13334. dt.TableName = "TB";
  13335. //报表标题等不用dt的值
  13336. designer.SetDataSource("TeamName", dto.title.TeamName);
  13337. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  13338. designer.SetDataSource("Tax", dto.title.Tax);
  13339. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  13340. designer.SetDataSource("Currency", dto.title.Currency);
  13341. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  13342. designer.SetDataSource("Rate", dto.title.Rate);
  13343. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  13344. var Aparams = hotels.Find(x => x.Type == "Default");
  13345. if (Aparams == null)
  13346. {
  13347. return Ok(jw);
  13348. }
  13349. //酒店数量
  13350. var txtSGRNumber = Aparams.SGR.ToString();
  13351. var txtTBRNumber = Aparams.TBR.ToString();
  13352. var txtJSESNumber = Aparams.JSES.ToString();
  13353. var txtSUITENumbe = Aparams.SUITE.ToString();
  13354. if (dto.costType == "B")
  13355. {
  13356. Aparams = hotels.Find(x => x.Type == "A");
  13357. var Bparams = hotels.Find(x => x.Type == "B");
  13358. if (Aparams == null || Bparams == null)
  13359. {
  13360. return Ok(jw);
  13361. }
  13362. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  13363. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  13364. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  13365. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  13366. }
  13367. designer.SetDataSource("SGRNumber", txtSGRNumber);
  13368. designer.SetDataSource("TBRNumber", txtTBRNumber);
  13369. designer.SetDataSource("JSESNumber", txtJSESNumber);
  13370. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  13371. var ws = designer.Workbook.Worksheets[0];
  13372. int Row = List_GC.Count;
  13373. int startIndex = 11;
  13374. int HideRows = 0;
  13375. List<int> hideRowsList = new List<int>();
  13376. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  13377. #region A段left数据
  13378. var left = dto.leftInfo.Find(x => x.Type == "A");
  13379. if (left == null)
  13380. {
  13381. return Ok(jw);
  13382. }
  13383. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  13384. if (leftBindData != null)
  13385. {
  13386. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  13387. designer.SetDataSource("VisaRS", leftBindData.rs);
  13388. designer.SetDataSource("VisaXS", leftBindData.xs);
  13389. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13390. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13391. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13392. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13393. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13394. }
  13395. else
  13396. {
  13397. hideRowsList.Add(Row + startIndex + HideRows);
  13398. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13399. }
  13400. HideRows += 2;
  13401. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  13402. if (leftBindData != null)
  13403. {
  13404. designer.SetDataSource("BXDRCB", leftBindData.cb);
  13405. designer.SetDataSource("BXRS", leftBindData.rs);
  13406. designer.SetDataSource("BXXS", leftBindData.xs);
  13407. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13408. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13409. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13410. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13411. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13412. }
  13413. else
  13414. {
  13415. hideRowsList.Add(Row + startIndex + HideRows);
  13416. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13417. }
  13418. HideRows += 2;
  13419. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  13420. if (leftBindData != null)
  13421. {
  13422. designer.SetDataSource("HSDRCB", leftBindData.cb);
  13423. designer.SetDataSource("HSRS", leftBindData.rs);
  13424. designer.SetDataSource("HSXS", leftBindData.xs);
  13425. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13426. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13427. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13428. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13429. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13430. }
  13431. else
  13432. {
  13433. hideRowsList.Add(Row + startIndex + HideRows);
  13434. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13435. }
  13436. HideRows += 2;
  13437. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  13438. if (leftBindData != null)
  13439. {
  13440. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  13441. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  13442. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  13443. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13444. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13445. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13446. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13447. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13448. }
  13449. else
  13450. {
  13451. hideRowsList.Add(Row + startIndex + HideRows);
  13452. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13453. }
  13454. HideRows += 2;
  13455. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  13456. if (leftBindData != null)
  13457. {
  13458. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  13459. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  13460. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  13461. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13462. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13463. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13464. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13465. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13466. }
  13467. else
  13468. {
  13469. hideRowsList.Add(Row + startIndex + HideRows);
  13470. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13471. }
  13472. HideRows += 2;
  13473. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  13474. if (leftBindData != null)
  13475. {
  13476. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  13477. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  13478. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  13479. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13480. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13481. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13482. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13483. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13484. }
  13485. else
  13486. {
  13487. hideRowsList.Add(Row + startIndex + HideRows);
  13488. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13489. }
  13490. HideRows += 2;
  13491. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  13492. if (leftBindData != null)
  13493. {
  13494. ////TBR
  13495. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  13496. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  13497. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  13498. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13499. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13500. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13501. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13502. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13503. }
  13504. else
  13505. {
  13506. hideRowsList.Add(Row + startIndex + HideRows);
  13507. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13508. }
  13509. HideRows += 2;
  13510. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  13511. if (leftBindData != null)
  13512. {
  13513. ////SGR
  13514. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  13515. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  13516. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  13517. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13518. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13519. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13520. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13521. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13522. }
  13523. else
  13524. {
  13525. hideRowsList.Add(Row + startIndex + HideRows);
  13526. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13527. }
  13528. HideRows += 2;
  13529. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  13530. if (leftBindData != null)
  13531. {
  13532. ////JS/ES
  13533. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  13534. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  13535. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  13536. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13537. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13538. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13539. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13540. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13541. }
  13542. else
  13543. {
  13544. hideRowsList.Add(Row + startIndex + HideRows);
  13545. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13546. }
  13547. HideRows += 2;
  13548. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  13549. if (leftBindData != null)
  13550. {
  13551. ////SUITE
  13552. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  13553. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  13554. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  13555. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13556. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13557. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13558. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13559. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13560. }
  13561. else
  13562. {
  13563. hideRowsList.Add(Row + startIndex + HideRows);
  13564. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13565. }
  13566. HideRows += 2;
  13567. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  13568. if (leftBindData != null)
  13569. {
  13570. designer.SetDataSource("DJDRCB", leftBindData.cb);
  13571. designer.SetDataSource("DJRS", leftBindData.rs);
  13572. designer.SetDataSource("DJXS", leftBindData.xs);
  13573. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13574. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13575. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13576. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13577. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13578. }
  13579. else
  13580. {
  13581. hideRowsList.Add(Row + startIndex + HideRows);
  13582. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13583. }
  13584. HideRows += 2;
  13585. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13586. if (leftBindData != null)
  13587. {
  13588. designer.SetDataSource("HCPCB", leftBindData.cb);
  13589. designer.SetDataSource("HCPRS", leftBindData.rs);
  13590. designer.SetDataSource("HCPXS", leftBindData.xs);
  13591. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13592. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13593. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13594. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13595. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13596. }
  13597. else
  13598. {
  13599. hideRowsList.Add(Row + startIndex + HideRows);
  13600. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13601. }
  13602. HideRows += 2;
  13603. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13604. if (leftBindData != null)
  13605. {
  13606. designer.SetDataSource("CPCB", leftBindData.cb);
  13607. designer.SetDataSource("CPRS", leftBindData.rs);
  13608. designer.SetDataSource("CPXS", leftBindData.xs);
  13609. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13610. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13611. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13612. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13613. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13614. }
  13615. else
  13616. {
  13617. hideRowsList.Add(Row + startIndex + HideRows);
  13618. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13619. }
  13620. HideRows += 2;
  13621. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13622. if (leftBindData != null)
  13623. {
  13624. designer.SetDataSource("GWDRCD", leftBindData.cb);
  13625. designer.SetDataSource("GWRS", leftBindData.rs);
  13626. designer.SetDataSource("GWXS", leftBindData.xs);
  13627. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13628. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13629. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13630. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13631. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13632. }
  13633. else
  13634. {
  13635. hideRowsList.Add(Row + startIndex + HideRows);
  13636. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13637. }
  13638. HideRows += 2;
  13639. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13640. if (leftBindData != null)
  13641. {
  13642. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  13643. designer.SetDataSource("LYJRS", leftBindData.rs);
  13644. designer.SetDataSource("LYJXS", leftBindData.xs);
  13645. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13646. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13647. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13648. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13649. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13650. }
  13651. else
  13652. {
  13653. hideRowsList.Add(Row + startIndex + HideRows);
  13654. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13655. }
  13656. #endregion
  13657. #region A段Right信息
  13658. var right = dto.rightInfo.Find(x => x.Type == "A");
  13659. if (right == null)
  13660. {
  13661. return Ok(jw);
  13662. }
  13663. HideRows += 4;
  13664. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13665. if (rightBindData != null)
  13666. {
  13667. //经济舱 + 双人间 TBR
  13668. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  13669. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  13670. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13671. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  13672. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13673. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13674. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13675. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13676. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13677. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13678. }
  13679. else
  13680. {
  13681. hideRowsList.Add(Row + startIndex + HideRows);
  13682. }
  13683. HideRows += 2;
  13684. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13685. if (rightBindData != null)
  13686. {
  13687. //经济舱 + 单人间 SGR
  13688. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  13689. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  13690. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13691. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  13692. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13693. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13694. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13695. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13696. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13697. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13698. }
  13699. else
  13700. {
  13701. hideRowsList.Add(Row + startIndex + HideRows);
  13702. }
  13703. HideRows += 2;
  13704. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13705. if (rightBindData != null)
  13706. {
  13707. //公务舱 + 单人间 SGR
  13708. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  13709. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  13710. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13711. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  13712. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13713. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13714. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13715. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13716. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13717. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13718. }
  13719. else
  13720. {
  13721. hideRowsList.Add(Row + startIndex + HideRows);
  13722. }
  13723. HideRows += 2;
  13724. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13725. if (rightBindData != null)
  13726. {
  13727. //公务舱 + 小套房 JSES
  13728. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  13729. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  13730. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13731. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  13732. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13733. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13734. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13735. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13736. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13737. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13738. }
  13739. else
  13740. {
  13741. hideRowsList.Add(Row + startIndex + HideRows);
  13742. }
  13743. HideRows += 2;
  13744. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13745. if (rightBindData != null)
  13746. {
  13747. //公务舱 + 小套房 JSES
  13748. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  13749. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  13750. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13751. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  13752. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13753. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13754. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13755. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13756. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13757. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13758. }
  13759. else
  13760. {
  13761. hideRowsList.Add(Row + startIndex + HideRows);
  13762. }
  13763. HideRows += 2;
  13764. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13765. if (rightBindData != null)
  13766. {
  13767. //经济舱 + 大套房
  13768. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  13769. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  13770. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13771. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  13772. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13773. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13774. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13775. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13776. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13777. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13778. }
  13779. else
  13780. {
  13781. hideRowsList.Add(Row + startIndex + HideRows);
  13782. }
  13783. HideRows += 2;
  13784. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13785. if (rightBindData != null)
  13786. {
  13787. //头等舱 + 小套房 JSES
  13788. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  13789. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  13790. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13791. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  13792. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13793. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13794. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13795. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13796. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13797. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13798. }
  13799. else
  13800. {
  13801. hideRowsList.Add(Row + startIndex + HideRows);
  13802. }
  13803. HideRows += 2;
  13804. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13805. if (rightBindData != null)
  13806. {
  13807. //头等舱 + 大套房
  13808. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  13809. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  13810. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13811. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  13812. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13813. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13814. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13815. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13816. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13817. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13818. }
  13819. else
  13820. {
  13821. hideRowsList.Add(Row + startIndex + HideRows);
  13822. }
  13823. #endregion
  13824. #region B段标题清空
  13825. designer.SetDataSource("CostBDRCB", "");
  13826. designer.SetDataSource("CostBRS", "");
  13827. designer.SetDataSource("CostBXS", "");
  13828. designer.SetDataSource("CostBZCB", "");
  13829. designer.SetDataSource("CostBDRBJ", "");
  13830. designer.SetDataSource("CostBZBJ", "");
  13831. designer.SetDataSource("CostBDRLR", "");
  13832. designer.SetDataSource("CostBZLR", "");
  13833. designer.SetDataSource("CostBDRCBOM", "");
  13834. designer.SetDataSource("CostBRSOM", "");
  13835. designer.SetDataSource("CostBZCBOM", "");
  13836. designer.SetDataSource("CostBDRBJOM", "");
  13837. designer.SetDataSource("CostBZBJOM", "");
  13838. designer.SetDataSource("CostBDRLROM", "");
  13839. designer.SetDataSource("CostBZLROM", "");
  13840. #endregion
  13841. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  13842. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  13843. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  13844. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  13845. designer.SetDataSource("DJName", "地接(CNY)");
  13846. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  13847. designer.SetDataSource("CPName", "地接-船票(CNY)");
  13848. designer.SetDataSource("GWName", "公务(CNY)");
  13849. designer.SetDataSource("YQHName", "邀请函(CNY)");
  13850. designer.SetDataSource("LYJName", "零用金(CNY)");
  13851. designer.SetDataSource("HSName", "核酸检测(CNY)");
  13852. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  13853. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  13854. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  13855. designer.SetDataSource("BXName", "保险(CNY)");
  13856. designer.SetDataSource("VisaName", "签证(CNY)");
  13857. #region B段基本数据
  13858. if (dto.costType == "B")
  13859. {
  13860. left = dto.leftInfo.Find(x => x.Type == "B");
  13861. if (left == null)
  13862. {
  13863. return Ok(jw);
  13864. }
  13865. #region B段left数据
  13866. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  13867. if (leftBindData != null)
  13868. {
  13869. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  13870. designer.SetDataSource("BHSRS", leftBindData.rs);
  13871. designer.SetDataSource("BHSXS", leftBindData.xs);
  13872. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13873. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13874. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13875. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13876. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13877. }
  13878. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  13879. if (leftBindData != null)
  13880. {
  13881. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  13882. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  13883. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  13884. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13885. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13886. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13887. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13888. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13889. }
  13890. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  13891. if (leftBindData != null)
  13892. {
  13893. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  13894. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  13895. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  13896. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13897. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13898. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13899. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13900. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13901. }
  13902. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  13903. if (leftBindData != null)
  13904. {
  13905. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  13906. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  13907. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  13908. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13909. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13910. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13911. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13912. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13913. }
  13914. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13915. if (leftBindData != null)
  13916. {
  13917. designer.SetDataSource("BHCPCB", leftBindData.cb);
  13918. designer.SetDataSource("BHCPRS", leftBindData.rs);
  13919. designer.SetDataSource("BHCPXS", leftBindData.xs);
  13920. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13921. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13922. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13923. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13924. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13925. }
  13926. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13927. if (leftBindData != null)
  13928. {
  13929. designer.SetDataSource("BCPCB", leftBindData.cb);
  13930. designer.SetDataSource("BCPRS", leftBindData.rs);
  13931. designer.SetDataSource("BCPXS", leftBindData.xs);
  13932. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13933. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13934. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13935. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13936. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13937. }
  13938. //TBR
  13939. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  13940. if (leftBindData != null)
  13941. {
  13942. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  13943. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  13944. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  13945. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13946. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13947. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13948. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13949. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13950. }
  13951. //SGR
  13952. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  13953. if (leftBindData != null)
  13954. {
  13955. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  13956. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  13957. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  13958. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13959. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13960. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13961. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13962. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13963. }
  13964. //JS/ES
  13965. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  13966. if (leftBindData != null)
  13967. {
  13968. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  13969. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  13970. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  13971. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13972. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13973. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13974. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13975. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13976. }
  13977. //SUITE
  13978. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  13979. if (leftBindData != null)
  13980. {
  13981. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  13982. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  13983. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  13984. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13985. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13986. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13987. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13988. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13989. }
  13990. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  13991. if (leftBindData != null)
  13992. {
  13993. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  13994. designer.SetDataSource("BDJRS", leftBindData.rs);
  13995. designer.SetDataSource("BDJXS", leftBindData.xs);
  13996. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13997. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13998. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13999. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14000. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14001. }
  14002. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14003. if (leftBindData != null)
  14004. {
  14005. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  14006. designer.SetDataSource("BGWRS", leftBindData.rs);
  14007. designer.SetDataSource("BGWXS", leftBindData.xs);
  14008. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14009. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14010. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14011. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14012. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14013. }
  14014. #region 优化方案
  14015. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  14016. //excelBind.Add("零用金", new {
  14017. //cb="",
  14018. //rs="",
  14019. //xs ="",
  14020. //zcb = "",
  14021. //});
  14022. #endregion
  14023. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14024. if (leftBindData != null)
  14025. {
  14026. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  14027. designer.SetDataSource("BLYJRS", leftBindData.rs);
  14028. designer.SetDataSource("BLYJXS", leftBindData.xs);
  14029. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14030. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14031. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14032. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14033. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14034. }
  14035. #endregion
  14036. #region B段Right信息
  14037. right = dto.rightInfo.Find(x => x.Type == "B");
  14038. if (right == null)
  14039. {
  14040. return Ok(jw);
  14041. }
  14042. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14043. if (rightBindData != null)
  14044. {
  14045. //经济舱 + 双人间 TBR
  14046. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  14047. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  14048. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14049. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  14050. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14051. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14052. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14053. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14054. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14055. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14056. }
  14057. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14058. if (rightBindData != null)
  14059. {
  14060. //经济舱 + 单人间 SGR
  14061. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  14062. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  14063. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14064. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  14065. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14066. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14067. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14068. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14069. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14070. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14071. }
  14072. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14073. if (rightBindData != null)
  14074. {
  14075. //公务舱 + 单人间 SGR
  14076. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  14077. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  14078. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14079. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  14080. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14081. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14082. designer.SetDataSource("BlblGWCSGRZLR", (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("公务舱 JS/ES"));
  14088. if (rightBindData != null)
  14089. {
  14090. //公务舱 + 小套房 JSES
  14091. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  14092. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  14093. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14094. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  14095. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14096. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14097. designer.SetDataSource("BlblGWCJSESZLR", (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("公务舱 SUITE"));
  14103. if (rightBindData != null)
  14104. {
  14105. //公务舱 + 小套房 JSES
  14106. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  14107. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  14108. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14109. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  14110. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14111. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14112. designer.SetDataSource("BlblGWCSUITEZLR", (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("经济舱 SUITE"));
  14118. if (rightBindData != null)
  14119. {
  14120. //经济舱 + 大套房
  14121. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  14122. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  14123. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14124. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  14125. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14126. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14127. designer.SetDataSource("BlblJJCSUITEZLR", (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("头等舱 JS/ES"));
  14133. if (rightBindData != null)
  14134. {
  14135. //头等舱 + 小套房 JSES
  14136. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  14137. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  14138. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14139. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  14140. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14141. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14142. designer.SetDataSource("BlblTDCJSESZLR", (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("BlblTDCSUITEDRCB", rightBindData.cb);
  14152. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  14153. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14154. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  14155. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14156. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14157. designer.SetDataSource("BlblTDCSUITEZLR", (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. #endregion
  14163. #region 标题
  14164. designer.SetDataSource("CostBDRCB", "单人成本");
  14165. designer.SetDataSource("CostBRS", "人数");
  14166. designer.SetDataSource("CostBXS", "系数");
  14167. designer.SetDataSource("CostBZCB", "总成本");
  14168. designer.SetDataSource("CostBDRBJ", "单人报价");
  14169. designer.SetDataSource("CostBZBJ", "总报价");
  14170. designer.SetDataSource("CostBDRLR", "单人利润");
  14171. designer.SetDataSource("CostBZLR", "总利润");
  14172. designer.SetDataSource("CostBDRCBOM", "单人成本");
  14173. designer.SetDataSource("CostBRSOM", "人数");
  14174. designer.SetDataSource("CostBZCBOM", "总成本");
  14175. designer.SetDataSource("CostBDRBJOM", "单人报价");
  14176. designer.SetDataSource("CostBZBJOM", "总报价");
  14177. designer.SetDataSource("CostBDRLROM", "单人利润");
  14178. designer.SetDataSource("CostBZLROM", "总利润");
  14179. #endregion
  14180. }
  14181. #endregion
  14182. designer.SetDataSource("TzZCB2", TzZCB2);
  14183. designer.SetDataSource("TzZBJ2", TzZBJ2);
  14184. designer.SetDataSource("TzZLR2", TzZLR2);
  14185. string[] dataSourceKeys = new string[]
  14186. {
  14187. "VF",
  14188. "TGS",
  14189. "TGOF",
  14190. "TGM",
  14191. "TGA",
  14192. "TGTF",
  14193. "TGEF",
  14194. "CFM",
  14195. "CFOF",
  14196. "B",
  14197. "L",
  14198. "D",
  14199. "TBR",
  14200. "SGR",
  14201. "JSES",
  14202. "Suite",
  14203. "TV",
  14204. "1L",
  14205. "IF",
  14206. "EF",
  14207. "BRF",
  14208. "TE",
  14209. "TGT",
  14210. "DRVT",
  14211. "PC",
  14212. "TLF",
  14213. "ECT"
  14214. };
  14215. foreach (var item in dataSourceKeys)
  14216. {
  14217. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  14218. if (find != null)
  14219. {
  14220. designer.SetDataSource(item, find.text);
  14221. }
  14222. else
  14223. {
  14224. designer.SetDataSource(item, 0);
  14225. }
  14226. }
  14227. designer.SetDataSource(dt);
  14228. //根据数据源处理生成报表内容
  14229. designer.Process();
  14230. designer.Workbook.Worksheets[0].Name = "清单";
  14231. Worksheet sheet = designer.Workbook.Worksheets[0];
  14232. foreach (var Rowindex in hideRowsList)
  14233. {
  14234. ws.Cells.HideRows(Rowindex, 2);
  14235. }
  14236. byte[] bytes = null;
  14237. string strFileName = di.TeamName + "-团组-成本.xls";
  14238. using (MemoryStream stream = new MemoryStream())
  14239. {
  14240. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  14241. bytes = stream.ToArray();
  14242. }
  14243. return Ok(JsonView(true, "", new
  14244. {
  14245. Data = bytes,
  14246. strFileName,
  14247. }));
  14248. }
  14249. /// <summary>
  14250. /// 导出客户报表
  14251. /// </summary>
  14252. /// <returns></returns>
  14253. [HttpPost]
  14254. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  14255. {
  14256. var jw = JsonView(false);
  14257. if (dto.Diid == 0)
  14258. {
  14259. return Ok(JsonView(false, "请传递团组id"));
  14260. }
  14261. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14262. if (deleInfo.Code != 0)
  14263. {
  14264. return Ok(JsonView(false, "团组信息查询失败!"));
  14265. }
  14266. var di = deleInfo.Data as DelegationInfoWebView;
  14267. if (di == null)
  14268. {
  14269. return Ok(JsonView(false, "团组信息查询失败!"));
  14270. }
  14271. //文件名
  14272. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  14273. //获取模板
  14274. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  14275. //载入模板
  14276. Document doc = new Document(tmppath);
  14277. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  14278. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  14279. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  14280. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  14281. var AParameter = ParameterList.Find(x => x.CostType == "A");
  14282. var BParameter = ParameterList.Find(x => x.CostType == "B");
  14283. if (AParameter == null)
  14284. {
  14285. return Ok(JsonView(false, "系数不存在!"));
  14286. }
  14287. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  14288. , TzAirDesc, TzZCost;
  14289. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  14290. = TzAirDesc = TzZCost = string.Empty;
  14291. TzNumber = AParameter.CostTypenumber.ToString();
  14292. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  14293. CarGuides1 = dto.CarGuides1;
  14294. Meal = dto.Meal;
  14295. SubsidizedMeals = dto.SubsidizedMeals;
  14296. NightRepair = dto.NightRepair;
  14297. AttractionsTickets = dto.AttractionsTickets;
  14298. MiscellaneousFees = dto.MiscellaneousFees;
  14299. ATip = dto.ATip;
  14300. TzHotelDesc = "";
  14301. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  14302. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  14303. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  14304. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  14305. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  14306. TzAirDesc = "";
  14307. TzZCost = dto.TzZCost;
  14308. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  14309. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  14310. var index = 1;
  14311. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  14312. foreach (var item in TzHotelDescArr)
  14313. {
  14314. if (AinfoArr != null)
  14315. {
  14316. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14317. if (Ainfo != null)
  14318. {
  14319. if (int.Parse(Ainfo.rs) <= 0)
  14320. {
  14321. continue;
  14322. }
  14323. var hotelText = string.Empty;
  14324. switch (item)
  14325. {
  14326. case "SGR":
  14327. hotelText = "单人间";
  14328. break;
  14329. case "JSES":
  14330. hotelText = "小套房";
  14331. break;
  14332. case "SUITE":
  14333. hotelText = "套房";
  14334. break;
  14335. case "TBR":
  14336. hotelText = "双人间";
  14337. break;
  14338. }
  14339. if (item != "TBR")
  14340. {
  14341. 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";
  14342. }
  14343. else
  14344. {
  14345. 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";
  14346. }
  14347. index++;
  14348. }
  14349. }
  14350. }
  14351. index = 1;
  14352. foreach (var item in TzAirDescArr)
  14353. {
  14354. if (AinfoArr != null)
  14355. {
  14356. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14357. if (Ainfo != null)
  14358. {
  14359. if (int.Parse(Ainfo.rs) <= 0)
  14360. {
  14361. continue;
  14362. }
  14363. 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";
  14364. index++;
  14365. }
  14366. }
  14367. }
  14368. if (dto.costType == "B")
  14369. {
  14370. if (BParameter == null)
  14371. {
  14372. return Ok(JsonView(false, "B段系数不存在!"));
  14373. }
  14374. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  14375. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  14376. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  14377. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  14378. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  14379. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  14380. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  14381. foreach (var item in TzHotelDescArr)
  14382. {
  14383. if (AinfoArr != null)
  14384. {
  14385. TzHotelDesc += "B段信息 \r\n";
  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. var hotelText = string.Empty;
  14394. switch (item)
  14395. {
  14396. case "SGR":
  14397. hotelText = "单人间";
  14398. break;
  14399. case "JSES":
  14400. hotelText = "小套房";
  14401. break;
  14402. case "SUITE":
  14403. hotelText = "套房";
  14404. break;
  14405. case "TBR":
  14406. hotelText = "双人间";
  14407. break;
  14408. }
  14409. if (item != "TBR")
  14410. {
  14411. 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";
  14412. }
  14413. else
  14414. {
  14415. 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";
  14416. }
  14417. index++;
  14418. }
  14419. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  14420. }
  14421. }
  14422. index = 1;
  14423. foreach (var item in TzAirDescArr)
  14424. {
  14425. if (AinfoArr != null)
  14426. {
  14427. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  14428. if (Ainfo != null)
  14429. {
  14430. if (int.Parse(Ainfo.rs) <= 0)
  14431. {
  14432. continue;
  14433. }
  14434. 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";
  14435. index++;
  14436. }
  14437. }
  14438. }
  14439. }
  14440. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  14441. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  14442. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  14443. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  14444. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  14445. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  14446. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  14447. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  14448. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  14449. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  14450. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  14451. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  14452. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  14453. DickeyValue.Add("Visa", Visa); // 签证单人报价
  14454. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  14455. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  14456. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  14457. DickeyValue.Add("TzZCost", TzZCost);
  14458. foreach (var key in DickeyValue.Keys)
  14459. {
  14460. if (doc.Range.Bookmarks[key] != null)
  14461. {
  14462. Bookmark mark = doc.Range.Bookmarks[key];
  14463. mark.Text = DickeyValue[key];
  14464. }
  14465. }
  14466. byte[] bytes = null;
  14467. string strFileName = di.TeamName + "-客户报价.doc";
  14468. using (MemoryStream stream = new MemoryStream())
  14469. {
  14470. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14471. bytes = stream.ToArray();
  14472. }
  14473. return Ok(JsonView(true, "", new
  14474. {
  14475. Data = bytes,
  14476. strFileName,
  14477. }));
  14478. }
  14479. /// <summary>
  14480. /// 团组成本 各模块(酒店,地接,机票)成本提示
  14481. /// </summary>
  14482. /// <param name="dto"></param>
  14483. /// <returns></returns>
  14484. [HttpPost]
  14485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14486. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  14487. {
  14488. try
  14489. {
  14490. #region 参数验证
  14491. if (dto.DiId < 0)
  14492. {
  14493. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  14494. }
  14495. List<int> cTableIds = new List<int>() {
  14496. 76 ,//酒店预订
  14497. 77 ,//行程
  14498. 79 ,//车/导游地接
  14499. 80 ,//签证
  14500. 81 ,//邀请/公务活
  14501. 82 ,//团组客户保险
  14502. 85 ,//机票预订
  14503. 98 ,//其他款项
  14504. 285 ,//收款退还
  14505. 751 ,//酒店早餐
  14506. 1015 // 超支费用
  14507. };
  14508. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  14509. {
  14510. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  14511. }
  14512. #endregion
  14513. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  14514. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  14515. if (_GroupCostParameters.Count <= 0)
  14516. {
  14517. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  14518. }
  14519. if (_GroupCostParameters[0].IsShare == 0)
  14520. {
  14521. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  14522. }
  14523. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  14524. //处理date为空问题
  14525. if (_GroupCosts.Count > 0)
  14526. {
  14527. for (int i = 0; i < _GroupCosts.Count; i++)
  14528. {
  14529. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  14530. {
  14531. if (i > 0)
  14532. {
  14533. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  14534. }
  14535. }
  14536. }
  14537. }
  14538. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  14539. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  14540. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  14541. string currCode = "";
  14542. #region currCode 验证
  14543. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  14544. if (isInt)
  14545. {
  14546. var currData = currDatas.Find(it => it.Id == intCurrency);
  14547. if (currData != null)
  14548. {
  14549. currCode = currData.Name;
  14550. }
  14551. }
  14552. else
  14553. {
  14554. currCode = _GroupCostParameters[0].Currency.Trim();
  14555. }
  14556. #endregion
  14557. //op,酒店单段模式存储
  14558. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  14559. {
  14560. CurrencyCode = currCode,
  14561. Rate = _GroupCostParameters[0].Rate,
  14562. CostType = _GroupCostParameters[0].CostType,
  14563. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  14564. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  14565. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  14566. };
  14567. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  14568. if (_GroupCostParameters.Count == 2)
  14569. {
  14570. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  14571. }
  14572. foreach (var item in _GroupCostParameters)
  14573. {
  14574. decimal _rate = 1;
  14575. decimal _rate1 = item.Rate;
  14576. decimal _scale = 1;
  14577. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  14578. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  14579. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  14580. //if (userInfo != null)
  14581. //{
  14582. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  14583. // {
  14584. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  14585. // {
  14586. // _scale = 1.00M;
  14587. // }
  14588. // }
  14589. //}
  14590. #endregion
  14591. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  14592. {
  14593. CurrencyCode = currCode,
  14594. Rate = _rate1,
  14595. CostType = item.CostType,
  14596. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  14597. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  14598. CostTypeNumber = item.CostTypenumber
  14599. };
  14600. if (_GroupCostParameters.Count > 1)
  14601. {
  14602. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  14603. }
  14604. else
  14605. {
  14606. modulePromptInfo.CostTypeNumber = item.LYJRS;
  14607. }
  14608. if (dto.CTable == 79)//
  14609. {
  14610. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  14611. modulePromptInfo.TotalCost = item.DJCB;
  14612. }
  14613. List<string> costTypes = new List<string>() { "A", "B" };
  14614. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  14615. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  14616. if (_GroupCostsDuplicates.Count() == 1)
  14617. {
  14618. _GroupCostsTypeData = _GroupCosts;
  14619. }
  14620. else
  14621. {
  14622. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  14623. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  14624. }
  14625. /*
  14626. * 76 酒店预订
  14627. * 77 行程
  14628. * 79 车/导游地接
  14629. * 80 签证
  14630. * 81 邀请/公务活动
  14631. * 82 团组客户保险
  14632. * 85 机票预订
  14633. * 98 其他款项
  14634. * 285 收款退还
  14635. * 751 酒店早餐
  14636. * 1015 超支费用
  14637. */
  14638. switch (dto.CTable)
  14639. {
  14640. case 76: // 酒店预订
  14641. _ModuleSubPromptInfo.AddRange(
  14642. _GroupCostsTypeData.Select(it => new
  14643. {
  14644. it.DAY,
  14645. it.Date,
  14646. it.ACCON,
  14647. it.ITIN,
  14648. it.SGR,
  14649. it.TBR,
  14650. it.JS_ES,
  14651. it.Suite
  14652. })
  14653. );
  14654. break;
  14655. case 79: // 车/导游地接
  14656. _ModuleSubPromptInfo.AddRange(
  14657. _GroupCostsTypeData.Select(it => new
  14658. {
  14659. Date = it.Date, //日期
  14660. CarFee = it.CarCost * _rate * _scale, //车费用
  14661. CarType = it.CarType, //车型
  14662. DriverFee = it.CFS * _rate * _scale, //司机工资
  14663. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  14664. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  14665. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  14666. GuideFee = it.TGS * _rate * _scale, //导游费用
  14667. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  14668. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  14669. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  14670. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  14671. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  14672. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  14673. Breakfast = it.B * _rate * _scale, //早餐费
  14674. Lunch = it.L * _rate * _scale, //午餐费
  14675. Dinner = it.D * _rate * _scale, //晚餐费
  14676. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  14677. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  14678. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  14679. TicketFee = it.EF * _rate * _scale, //门票费
  14680. TicketRemark = it.EFR, //门票费描述
  14681. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  14682. TravelSupplies = it.TE * _rate * _scale, //出行物资
  14683. SpentCash = it.PC * _rate * _scale, //零用金
  14684. LeadersFee = it.TLF * _rate * _scale, //领队费
  14685. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  14686. })
  14687. );
  14688. break;
  14689. case 85: // 机票
  14690. List<dynamic> datas = new List<dynamic>();
  14691. datas.Add(
  14692. new
  14693. {
  14694. AirType = "经济舱",
  14695. AirNum = item.JJCRS,
  14696. AirDRCB = item.JJCCB,
  14697. AirZCB = (item.JJCRS * item.JJCCB)
  14698. }
  14699. );
  14700. datas.Add(
  14701. new
  14702. {
  14703. AirType = "公务舱",
  14704. AirNum = item.GWCRS,
  14705. AirDRCB = item.GWCCB,
  14706. AirZCB = (item.GWCRS * item.GWCCB)
  14707. }
  14708. );
  14709. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  14710. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  14711. modulePromptInfo.Data = new
  14712. {
  14713. airFeeData = datas,
  14714. airInitData = initDatas
  14715. };
  14716. _ModulePromptInfos.Add(modulePromptInfo);
  14717. break;
  14718. default:
  14719. break;
  14720. }
  14721. }
  14722. if (dto.CTable != 85)
  14723. {
  14724. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  14725. _ModulePromptInfos.Add(_ModulePromptInfo);
  14726. }
  14727. _view.ModulePromptInfos = _ModulePromptInfos;
  14728. return Ok(JsonView(true, "操作成功!", _view));
  14729. }
  14730. catch (Exception ex)
  14731. {
  14732. return Ok(JsonView(false, ex.Message));
  14733. }
  14734. }
  14735. /// <summary>
  14736. /// 根据黑屏代码重新生成行程
  14737. /// </summary>
  14738. /// <param name="dto"></param>
  14739. /// <returns></returns>
  14740. [HttpPost]
  14741. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  14742. {
  14743. var jw = JsonView(false,"Error");
  14744. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  14745. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  14746. .Select(x=> new
  14747. {
  14748. x.Id,
  14749. x.Title
  14750. })
  14751. .ToList();
  14752. if (Create.Any())
  14753. {
  14754. jw.Msg = "获取成功!";
  14755. jw.Code = 200;
  14756. jw.Data = new
  14757. {
  14758. BlackCodeListSelect = Create,
  14759. blackCodeIsTrue = true
  14760. };
  14761. }
  14762. else
  14763. {
  14764. jw.Code = 400;
  14765. jw.Data = new
  14766. {
  14767. BlackCodeListSelect = Create,
  14768. blackCodeIsTrue = false,
  14769. };
  14770. }
  14771. return Ok(jw);
  14772. }
  14773. /// <summary>
  14774. /// 根据黑屏代码Id重新生成行程
  14775. /// </summary>
  14776. /// <param name="dto"></param>
  14777. /// <returns></returns>
  14778. [HttpPost]
  14779. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  14780. {
  14781. var jw = JsonView(false, "Error");
  14782. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  14783. if (result.Code == 0)
  14784. {
  14785. jw.Msg = "获取成功!";
  14786. jw.Code = 200;
  14787. jw.Data = new
  14788. {
  14789. groupCost = result.Data,
  14790. blackCodeIsTrue = true
  14791. };
  14792. }
  14793. else
  14794. {
  14795. jw.Code = 400;
  14796. jw.Data = new
  14797. {
  14798. groupCost = result.Data,
  14799. blackCodeIsTrue = false,
  14800. };
  14801. }
  14802. return Ok(jw);
  14803. }
  14804. /// <summary>
  14805. /// 成本获取OP历史车费用
  14806. /// </summary>
  14807. /// <param name="dto"></param>
  14808. /// <returns></returns>
  14809. [HttpPost]
  14810. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  14811. {
  14812. var jw = JsonView(false);
  14813. try
  14814. {
  14815. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  14816. //获取现有所有车的数据
  14817. if (!dto.Param.IsNullOrWhiteSpace())
  14818. {
  14819. string sql = $@"
  14820. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  14821. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  14822. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  14823. 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
  14824. AND gctggr.ServiceEndTime is not NULL
  14825. ORDER by gctggrc.id DESC
  14826. ";
  14827. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  14828. var numeberResult = await Task.Run(() =>
  14829. {
  14830. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  14831. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  14832. return numberArr;
  14833. });
  14834. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  14835. foreach (var item in numeberResult)
  14836. {
  14837. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  14838. {
  14839. Country = "数据异常!",
  14840. City = string.Empty,
  14841. };
  14842. item.Area = find.Country + " " + find.City;
  14843. }
  14844. dbResult.AddRange(numeberResult);
  14845. if (dto.Param.Contains("、"))
  14846. {
  14847. var sp = dto.Param.Split("、");
  14848. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14849. .Where(x =>
  14850. {
  14851. return System.Array.Exists(sp, e =>
  14852. {
  14853. bool where = false;
  14854. if (x.Area != null)
  14855. {
  14856. where = x.Area.Contains(e);
  14857. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14858. {
  14859. return false;
  14860. }
  14861. }
  14862. if (x.PriceName != null && !where)
  14863. {
  14864. where = x.PriceName.Contains(e);
  14865. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14866. {
  14867. return false;
  14868. }
  14869. }
  14870. return where;
  14871. });
  14872. }).ToList();
  14873. }
  14874. else
  14875. {
  14876. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14877. .Where(x =>
  14878. {
  14879. bool where = false;
  14880. if (x.Area != null)
  14881. {
  14882. where = x.Area.Contains(dto.Param);
  14883. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14884. {
  14885. return false;
  14886. }
  14887. }
  14888. if (x.PriceName != null && !where)
  14889. {
  14890. where = x.PriceName.Contains(dto.Param);
  14891. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14892. {
  14893. return false;
  14894. }
  14895. }
  14896. return where;
  14897. }
  14898. )
  14899. .ToList();
  14900. }
  14901. }
  14902. var view = dbResult.Select(x =>
  14903. {
  14904. decimal dp = 0.00M;
  14905. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  14906. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  14907. if (string.IsNullOrWhiteSpace(x.DatePrice))
  14908. {
  14909. if (startB && endB)
  14910. {
  14911. var timesp = endD.Subtract(startD);
  14912. if ((timesp.Days + 1) != 0)
  14913. {
  14914. dp = x.Price / (timesp.Days + 1);
  14915. }
  14916. }
  14917. }
  14918. else
  14919. {
  14920. dp = x.Price;
  14921. }
  14922. return new
  14923. {
  14924. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  14925. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  14926. x.Area,
  14927. x.id,
  14928. price = x.Price.ToString("F2"),
  14929. x.PriceName,
  14930. x.PriceContent,
  14931. x.TeamName,
  14932. x.DatePrice,
  14933. dayPrice = dp.ToString("F2"),
  14934. };
  14935. }).OrderByDescending(x => x.id).ToList();
  14936. jw = JsonView(true, "获取成功!", view);
  14937. }
  14938. catch (Exception e)
  14939. {
  14940. jw = JsonView(false, e.Message);
  14941. }
  14942. return Ok(jw);
  14943. }
  14944. #endregion
  14945. #region 酒店预订 新 雷怡 2023-12-28 17:45
  14946. /// <summary>
  14947. /// 酒店预订
  14948. /// 酒店费用列表 根据团组Id查询
  14949. /// </summary>
  14950. /// <param name="_dto"></param>
  14951. /// <returns></returns>
  14952. [HttpPost]
  14953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14954. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  14955. {
  14956. #region 参数验证
  14957. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14958. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14959. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14960. #region 团组操作权限验证 76 酒店预定模块
  14961. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14962. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14963. #endregion
  14964. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14965. #region 页面操作权限验证
  14966. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14967. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14968. #endregion
  14969. #endregion
  14970. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  14971. }
  14972. /// <summary>
  14973. /// 酒店预订
  14974. /// 基础数据
  14975. /// </summary>
  14976. /// <param name="_dto"></param>
  14977. /// <returns></returns>
  14978. [HttpPost]
  14979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14980. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  14981. {
  14982. #region 参数验证
  14983. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14984. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14985. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14986. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14987. #region 页面操作权限验证
  14988. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14989. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14990. #endregion
  14991. #region 团组操作权限验证 76 酒店预定模块
  14992. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14993. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14994. #endregion
  14995. #endregion
  14996. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  14997. }
  14998. /// <summary>
  14999. /// 酒店预订
  15000. /// 创建 入住卷号码
  15001. /// </summary>
  15002. /// <param name="_dto"></param>
  15003. /// <returns></returns>
  15004. [HttpPost]
  15005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15006. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  15007. {
  15008. #region 参数验证
  15009. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15010. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15011. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15012. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15013. #region 页面操作权限验证
  15014. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15015. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15016. #endregion
  15017. #region 团组操作权限验证 76 酒店预定模块
  15018. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15019. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15020. #endregion
  15021. #endregion
  15022. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  15023. if (data.Code != 0)
  15024. {
  15025. return Ok(JsonView(false, data.Msg));
  15026. }
  15027. return Ok(JsonView(true, data.Msg, data.Data));
  15028. }
  15029. /// <summary>
  15030. /// 酒店预订
  15031. /// 详情
  15032. /// </summary>
  15033. /// <param name="_dto"></param>
  15034. /// <returns></returns>
  15035. [HttpPost]
  15036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15037. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  15038. {
  15039. #region 参数验证
  15040. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  15041. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15042. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  15043. #region 团组操作权限验证 76 酒店预定模块
  15044. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15045. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15046. #endregion
  15047. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15048. #region 页面操作权限验证
  15049. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15050. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15051. #endregion
  15052. #endregion
  15053. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  15054. }
  15055. /// <summary>
  15056. /// 酒店预订
  15057. /// Add Or Edit
  15058. /// </summary>
  15059. /// <param name="_dto"></param>
  15060. /// <returns></returns>
  15061. [HttpPost]
  15062. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15063. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  15064. {
  15065. #region 参数验证
  15066. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15067. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15068. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15069. #region 团组操作权限验证 76 酒店预定模块
  15070. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15071. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15072. #endregion
  15073. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15074. #region 页面操作权限验证
  15075. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15076. if (_dto.Id == 0) // Add
  15077. {
  15078. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  15079. }
  15080. else if (_dto.Id > 1) // Edit
  15081. {
  15082. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  15083. }
  15084. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  15085. #endregion
  15086. #endregion
  15087. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  15088. if (_view.Code != 200)
  15089. {
  15090. return Ok(_view);
  15091. }
  15092. #region 成本无酒店价格数据进入超支
  15093. _sqlSugar.BeginTran();
  15094. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  15095. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  15096. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  15097. for (int i = 0; i < groupCost.Count; i++)
  15098. {
  15099. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  15100. {
  15101. groupCost[i].Date = groupCost[i - 1].Date;
  15102. }
  15103. }
  15104. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  15105. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  15106. List<Fin_GroupExtraCostDto_OP>();
  15107. if (start_Bool && end_Bool)
  15108. {
  15109. while (start_Time < end_Time)
  15110. {
  15111. foreach (var item in groupCost_Grp)
  15112. {
  15113. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  15114. {
  15115. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  15116. {
  15117. extraCostList.Add(new
  15118. Fin_GroupExtraCostDto_OP
  15119. {
  15120. Area = _dto.AreaId,
  15121. coefficient = 1.5M,
  15122. createUser = _dto.UserId,
  15123. currency = _dto.CardPriceCurrency,
  15124. diId = _dto.DiId,
  15125. ManagerConfirm = 0,
  15126. SupervisorConfirm = 0,
  15127. SYsupervisorConfirm = 0,
  15128. editType = 1,
  15129. PortType = 1,
  15130. price = _dto.CardPrice,
  15131. PriceCount = 1,
  15132. priceType = 1027,
  15133. priceDetailType = 1044,
  15134. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  15135. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  15136. });
  15137. }
  15138. }
  15139. }
  15140. start_Time = start_Time.AddDays(1);
  15141. }
  15142. }
  15143. if (extraCostList.Any())
  15144. {
  15145. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  15146. }
  15147. _sqlSugar.CommitTran();
  15148. #endregion
  15149. #region 应用推送
  15150. try
  15151. {
  15152. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  15153. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  15154. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  15155. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  15156. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  15157. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  15158. var diId = _dto.DiId;
  15159. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15160. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15161. #region 操作记录
  15162. var opInfo = new Crm_TableOperationRecord()
  15163. {
  15164. TableName = "Grp_HotelReservations",
  15165. PortType = _dto.PortType,
  15166. DataId = hotelId,
  15167. CreateUserId = _dto.UserId
  15168. };
  15169. //var opStatus = OperationEnum.NoOperation;
  15170. if (_dto.Id < 1) //添加操作
  15171. {
  15172. opInfo.OperationItem = OperationEnum.Add;
  15173. }
  15174. else if (_dto.Id > 0)
  15175. {
  15176. opInfo.OperationItem = OperationEnum.Edit;
  15177. }
  15178. string opRemark = string.Empty;
  15179. if (ccpInfo != null)
  15180. {
  15181. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  15182. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  15183. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  15184. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  15185. }
  15186. opInfo.Remark = opRemark;
  15187. await _tableorRep.AddAsync(opInfo);
  15188. #endregion
  15189. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  15190. //2024-10-21 新增LZ UID
  15191. var userIds = new List<int>() { 21 };
  15192. string title = $"费用审核";
  15193. string content = "";
  15194. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15195. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15196. try
  15197. {
  15198. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  15199. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  15200. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  15201. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  15202. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  15203. }
  15204. catch (Exception ex)
  15205. {
  15206. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  15207. }
  15208. }
  15209. catch (Exception ex)
  15210. {
  15211. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  15212. }
  15213. try
  15214. {
  15215. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  15216. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  15217. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  15218. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  15219. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  15220. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  15221. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15222. //自动审核
  15223. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  15224. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  15225. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  15226. //2024-10-21 新增LZ UID
  15227. var userIds = new List<int>() { 21 };
  15228. string title = $"系统通知";
  15229. var diId = _dto.DiId;
  15230. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15231. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15232. string content = "";
  15233. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15234. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15235. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15236. }
  15237. catch (Exception ex)
  15238. {
  15239. }
  15240. #endregion
  15241. return Ok(_view);
  15242. }
  15243. /// <summary>
  15244. /// 酒店自动审核测试
  15245. /// Add Or Edit
  15246. /// </summary>
  15247. /// <param name="diid"></param>
  15248. /// <param name="dataId"></param>
  15249. /// <returns></returns>
  15250. [HttpPost]
  15251. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15252. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  15253. {
  15254. #region 应用推送
  15255. try
  15256. {
  15257. //自动审核
  15258. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  15259. }
  15260. catch (Exception ex)
  15261. {
  15262. return Ok(JsonView(false, "操作失败"));
  15263. }
  15264. #endregion
  15265. return Ok(JsonView(false, "操作成功"));
  15266. }
  15267. /// <summary>
  15268. /// 酒店预订
  15269. /// Del
  15270. /// </summary>
  15271. /// <param name="_dto"></param>
  15272. /// <returns></returns>
  15273. [HttpPost]
  15274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15275. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  15276. {
  15277. #region 参数验证
  15278. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15279. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15280. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15281. #region 团组操作权限验证 76 酒店预定模块
  15282. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15283. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15284. #endregion
  15285. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15286. #region 页面操作权限验证
  15287. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15288. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  15289. #endregion
  15290. #endregion
  15291. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  15292. #region 操作记录
  15293. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  15294. {
  15295. TableName = "Grp_HotelReservations",
  15296. PortType = _dto.PortType,
  15297. OperationItem = OperationEnum.Del,
  15298. DataId = _dto.Id,
  15299. CreateUserId = _dto.UserId
  15300. });
  15301. #endregion
  15302. return Ok(data);
  15303. }
  15304. /// <summary>
  15305. /// 酒店预订
  15306. /// 生成VOUCHER
  15307. /// 2024.05.06 之前版本
  15308. /// </summary>
  15309. /// <param name="_dto"></param>
  15310. /// <returns></returns>
  15311. [HttpPost]
  15312. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15313. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  15314. {
  15315. try
  15316. {
  15317. #region 参数验证
  15318. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15319. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15320. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  15321. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  15322. #region 团组操作权限验证 76 酒店预定模块
  15323. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15324. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15325. #endregion
  15326. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15327. #region 页面操作权限验证
  15328. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15329. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15330. #endregion
  15331. #endregion
  15332. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  15333. //判断数据是否完整
  15334. if (hr != null)
  15335. {
  15336. if (!string.IsNullOrEmpty(hr.DetermineNo))
  15337. {
  15338. string strFileName = "HotelStatement/";
  15339. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  15340. if (dele != null)
  15341. strFileName += dele.TourCode;
  15342. //载入模板
  15343. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  15344. Document doc = new Document(sss);
  15345. DocumentBuilder builder = new DocumentBuilder(doc);
  15346. #region 替换Word模板书签内容
  15347. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  15348. //入住卷预定号码
  15349. if (doc.Range.Bookmarks["VNO"] != null)
  15350. {
  15351. Bookmark mark = doc.Range.Bookmarks["VNO"];
  15352. mark.Text = hr.CheckNumber;
  15353. }
  15354. //酒店时间
  15355. if (doc.Range.Bookmarks["Date"] != null)
  15356. {
  15357. Bookmark mark = doc.Range.Bookmarks["Date"];
  15358. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  15359. }
  15360. //团号
  15361. if (doc.Range.Bookmarks["TNo"] != null)
  15362. {
  15363. Bookmark mark = doc.Range.Bookmarks["TNo"];
  15364. mark.Text = dele.TourCode;
  15365. }
  15366. //预定号码
  15367. if (doc.Range.Bookmarks["BookingId"] != null)
  15368. {
  15369. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  15370. mark.Text = hr.ReservationsNo;
  15371. }
  15372. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  15373. {
  15374. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  15375. mark.Text = hr.DetermineNo;
  15376. }
  15377. //酒店城市
  15378. if (doc.Range.Bookmarks["City"] != null)
  15379. {
  15380. Bookmark mark = doc.Range.Bookmarks["City"];
  15381. mark.Text = hr.City;
  15382. }
  15383. //酒店名称
  15384. if (doc.Range.Bookmarks["HName"] != null)
  15385. {
  15386. Bookmark mark = doc.Range.Bookmarks["HName"];
  15387. mark.Text = hr.HotelName;
  15388. }
  15389. //酒店地址
  15390. if (doc.Range.Bookmarks["Address"] != null)
  15391. {
  15392. Bookmark mark = doc.Range.Bookmarks["Address"];
  15393. mark.Text = hr.HotelAddress;
  15394. }
  15395. //酒店电话
  15396. if (doc.Range.Bookmarks["Tel"] != null)
  15397. {
  15398. Bookmark mark = doc.Range.Bookmarks["Tel"];
  15399. mark.Text = hr.HotelTel;
  15400. }
  15401. //酒店传真
  15402. if (doc.Range.Bookmarks["Fax"] != null)
  15403. {
  15404. Bookmark mark = doc.Range.Bookmarks["Fax"];
  15405. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  15406. {
  15407. mark.Text = hr.HotelFax;
  15408. }
  15409. }
  15410. //入住时间
  15411. if (doc.Range.Bookmarks["CIn"] != null)
  15412. {
  15413. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  15414. Bookmark mark = doc.Range.Bookmarks["CIn"];
  15415. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  15416. }
  15417. //退房时间
  15418. if (doc.Range.Bookmarks["COut"] != null)
  15419. {
  15420. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  15421. Bookmark mark = doc.Range.Bookmarks["COut"];
  15422. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  15423. }
  15424. //客户名称
  15425. if (doc.Range.Bookmarks["GName"] != null)
  15426. {
  15427. string guestName = "";
  15428. string[] clients = new string[] { };
  15429. if (hr.GuestName.Contains(","))
  15430. {
  15431. clients = hr.GuestName.Split(",");
  15432. }
  15433. else
  15434. {
  15435. clients = new string[] { hr.GuestName };
  15436. }
  15437. List<int> clientIds_int = new List<int>();
  15438. if (clients.Length > 0)
  15439. {
  15440. foreach (var item in clients)
  15441. {
  15442. if (item.IsNumeric())
  15443. {
  15444. clientIds_int.Add(int.Parse(item));
  15445. }
  15446. }
  15447. }
  15448. if (clientIds_int.Count > 0)
  15449. {
  15450. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  15451. foreach (var client in _clientDatas)
  15452. {
  15453. //男
  15454. if (client.Sex == 0) guestName += $"Mr.";
  15455. //女
  15456. else if (client.Sex == 1) guestName += $"Ms.";
  15457. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  15458. {
  15459. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  15460. }
  15461. //guestName += $"{client.Pinyin},";
  15462. }
  15463. if (guestName.Length > 0)
  15464. {
  15465. guestName = guestName.Substring(0, guestName.Length - 1);
  15466. }
  15467. }
  15468. else
  15469. {
  15470. guestName = hr.GuestName;
  15471. }
  15472. Bookmark mark = doc.Range.Bookmarks["GName"];
  15473. mark.Text = guestName;
  15474. }
  15475. //房间介绍
  15476. if (doc.Range.Bookmarks["ROOM"] != null)
  15477. {
  15478. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  15479. mark.Text = hr.RoomExplanation;
  15480. }
  15481. //报价描述
  15482. if (doc.Range.Bookmarks["NOTE"] != null)
  15483. {
  15484. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  15485. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  15486. if (ss != null)
  15487. mark.Text = ss.Name;
  15488. }
  15489. //入住时间
  15490. if (doc.Range.Bookmarks["CheckIn"] != null)
  15491. {
  15492. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  15493. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  15494. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  15495. }
  15496. //退房时间
  15497. if (doc.Range.Bookmarks["CheckOut"] != null)
  15498. {
  15499. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  15500. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  15501. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  15502. }
  15503. //日期
  15504. if (doc.Range.Bookmarks["DT"] != null)
  15505. {
  15506. Bookmark mark = doc.Range.Bookmarks["DT"];
  15507. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  15508. }
  15509. //名称
  15510. if (doc.Range.Bookmarks["VName"] != null)
  15511. {
  15512. Bookmark mark = doc.Range.Bookmarks["VName"];
  15513. mark.Text = hr.HotelName;
  15514. }
  15515. //号码
  15516. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  15517. {
  15518. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  15519. mark.Text = hr.CheckNumber;
  15520. }
  15521. #endregion
  15522. strFileName += "VOUCHER.doc";
  15523. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15524. doc.Save(fileDir);
  15525. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15526. return Ok(JsonView(true, "操作成功!", Url));
  15527. }
  15528. else
  15529. {
  15530. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  15531. }
  15532. }
  15533. else
  15534. {
  15535. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  15536. }
  15537. }
  15538. catch (Exception ex)
  15539. {
  15540. return Ok(JsonView(false, ex.Message));
  15541. }
  15542. }
  15543. /// <summary>
  15544. /// 酒店预订
  15545. /// 生成VOUCHER
  15546. /// 2024.05.06 之后版本
  15547. /// </summary>
  15548. /// <param name="_dto"></param>
  15549. /// <returns></returns>
  15550. [HttpPost]
  15551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15552. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  15553. {
  15554. #region 参数验证
  15555. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15556. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15557. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15558. #region 团组操作权限验证 76 酒店预定模块
  15559. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15560. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15561. #endregion
  15562. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15563. #region 页面操作权限验证
  15564. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15565. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15566. #endregion
  15567. #endregion
  15568. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  15569. //判断数据是否完整
  15570. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  15571. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15572. string strFileName = "HotelStatement/";
  15573. string guestNames = ""; //格式Mr.xxx Ms.xxx
  15574. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  15575. #region 数据处理
  15576. List<int> guestIds = new List<int>();
  15577. //int index = 0;
  15578. foreach (var item in hrDtas)
  15579. {
  15580. if (item.GuestName.Contains(","))
  15581. {
  15582. string[] guestIdArr = item.GuestName.Split(',');
  15583. foreach (var guestIdStr in guestIdArr)
  15584. {
  15585. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  15586. if (guestBool)
  15587. {
  15588. guestIds.Add(guestId);
  15589. }
  15590. }
  15591. }
  15592. else guestNames += item.GuestName;
  15593. var voucherInfo = new HotelVoucherInfoView()
  15594. {
  15595. HotelName = item.HotelName,
  15596. CheckInDate = item.CheckInDate,
  15597. CheckOutDate = item.CheckOutDate,
  15598. ConfirmationNumber = item.DetermineNo.Trim(),
  15599. RoomType = item.RoomExplanation
  15600. };
  15601. vouchers.Add(voucherInfo);
  15602. }
  15603. if (guestIds.Count > 0)
  15604. {
  15605. guestIds = guestIds.Distinct().ToList();
  15606. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  15607. if (guestDatas.Count > 0)
  15608. {
  15609. guestNames = "";
  15610. foreach (var guest in guestDatas)
  15611. {
  15612. string guestName = "";
  15613. if (guest.Sex == 0) guestName += @"MR.";
  15614. else if (guest.Sex == 1) guestName += @"MS.";
  15615. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  15616. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  15617. guestNames += @$"{guestName.Trim()}、";
  15618. }
  15619. if (guestNames.Length > 0)
  15620. {
  15621. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  15622. }
  15623. }
  15624. }
  15625. #endregion
  15626. //载入模板
  15627. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  15628. Document doc = new Document(sss);
  15629. DocumentBuilder builder = new DocumentBuilder(doc);
  15630. if (doc.Range.Bookmarks["GuestName"] != null)
  15631. {
  15632. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  15633. mark.Text = guestNames;
  15634. }
  15635. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15636. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  15637. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  15638. for (int i = 1; i <= vouchers.Count; i++)
  15639. {
  15640. HotelVoucherInfoView hviv = vouchers[i - 1];
  15641. builder.MoveToCell(0, i, 0, 0);
  15642. builder.Write(hviv.HotelName);
  15643. builder.MoveToCell(0, i, 1, 0);
  15644. builder.Write(hviv.CheckInDate);
  15645. builder.MoveToCell(0, i, 2, 0);
  15646. builder.Write(hviv.CheckOutDate);
  15647. builder.MoveToCell(0, i, 3, 0);
  15648. builder.Write(hviv.RoomType);
  15649. builder.MoveToCell(0, i, 4, 0);
  15650. builder.Write(hviv.ConfirmationNumber);
  15651. }
  15652. //删除多余行
  15653. int currRowIndex = vouchers.Count + 1;
  15654. int delRows = 21 - currRowIndex;
  15655. if (delRows > 0)
  15656. {
  15657. for (int i = 0; i < delRows; i++)
  15658. {
  15659. table.Rows.RemoveAt(currRowIndex);
  15660. //cultivateRowIndex++;
  15661. }
  15662. }
  15663. strFileName += "VOUCHER.docx";
  15664. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15665. doc.Save(fileDir);
  15666. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15667. return Ok(JsonView(true, "操作成功!", Url));
  15668. }
  15669. /// <summary>
  15670. /// 酒店预订
  15671. /// 生成VOUCHER 批量生成
  15672. /// New
  15673. /// </summary>
  15674. /// <param name="_dto"></param>
  15675. /// <returns></returns>
  15676. [HttpPost]
  15677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15678. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  15679. {
  15680. #region 参数验证
  15681. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15682. if (_dto.PageId < 1) _dto.PageId = 28;
  15683. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15684. #region 团组操作权限验证 76 酒店预定模块
  15685. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15686. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15687. #endregion
  15688. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15689. #region 页面操作权限验证
  15690. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15691. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15692. #endregion
  15693. #endregion
  15694. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  15695. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  15696. .OrderBy(x => x.CheckInDate)
  15697. .ToListAsync();
  15698. //判断数据是否完整
  15699. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  15700. string strFileName = "HotelStatement/";
  15701. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  15702. if (dele != null)
  15703. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  15704. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  15705. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  15706. .Where(it => it.IsDel == 0)
  15707. .ToListAsync();
  15708. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  15709. for (int i = 0; i < hrDtas.Count; i++)
  15710. {
  15711. string guestNames = string.Empty;
  15712. List<int> guestIds = new List<int>();
  15713. var item = hrDtas[i];
  15714. //处理客户姓名
  15715. if (item.GuestName.Contains(","))
  15716. {
  15717. string[] guestIdArr = item.GuestName.Split(',');
  15718. foreach (var guestIdStr in guestIdArr)
  15719. if (int.TryParse(guestIdStr, out int guestId))
  15720. guestIds.Add(guestId);
  15721. }
  15722. else
  15723. {
  15724. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  15725. if (guestIdBool)
  15726. {
  15727. guestIds.Add(guestId);
  15728. }
  15729. //NaN
  15730. if (item.GuestName.Contains("NaN"))
  15731. {
  15732. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  15733. }
  15734. }
  15735. if (guestIds.Count > 0)
  15736. {
  15737. guestIds = guestIds.Distinct().ToList();
  15738. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  15739. if (guestDatas1.Count > 0)
  15740. {
  15741. guestNames = "";
  15742. foreach (var guest in guestDatas1)
  15743. {
  15744. string guestName = "";
  15745. if (guest.Sex == 0) guestName += @"MR.";
  15746. else if (guest.Sex == 1) guestName += @"MS.";
  15747. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  15748. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  15749. guestNames += @$"{guestName.Trim()}、";
  15750. }
  15751. if (guestNames.Length > 0)
  15752. {
  15753. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  15754. }
  15755. }
  15756. }
  15757. //if (!string.IsNullOrEmpty(guestNames))
  15758. //{
  15759. hrDtas[i].GuestName = guestNames;
  15760. //}
  15761. }
  15762. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  15763. Document doc = new Document();
  15764. DocumentBuilder builder = new DocumentBuilder(doc);
  15765. try
  15766. {
  15767. builder.MoveToDocumentStart();
  15768. foreach (var item in hrDtas)
  15769. {
  15770. //标题
  15771. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15772. builder.ParagraphFormat.LineSpacing = 1;
  15773. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15774. builder.ParagraphFormat.Style.Font.Size = 9;
  15775. builder.ParagraphFormat.Style.Font.Bold = true;
  15776. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15777. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  15778. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15779. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15780. builder.ParagraphFormat.LineSpacing = 1;
  15781. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15782. builder.ParagraphFormat.Style.Font.Size = 9;
  15783. builder.ParagraphFormat.Style.Font.Bold = true;
  15784. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  15785. builder.StartTable();
  15786. // 设置边框颜色
  15787. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  15788. //设置边框样式
  15789. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  15790. //表格
  15791. #region 第一行
  15792. builder.InsertCell();
  15793. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15794. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15795. //builder.CellFormat.AllowAutoFit = false;
  15796. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15797. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15798. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15799. builder.CellFormat.WrapText = true; //自动换行
  15800. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15801. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  15802. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15803. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15804. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15805. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15806. builder.Write("TOUR NO:");
  15807. builder.InsertCell();
  15808. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15809. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15810. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15811. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15812. builder.ParagraphFormat.Style.Font.Bold = false;
  15813. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15814. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15815. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15816. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15817. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15818. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15819. builder.Write($"{dele?.TourCode ?? "-"}");
  15820. builder.InsertCell();
  15821. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15822. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15823. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15824. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15825. builder.ParagraphFormat.Style.Font.Bold = false;
  15826. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15827. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15828. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15829. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15830. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15831. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15832. builder.Write($"CITY:");
  15833. builder.InsertCell();
  15834. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15835. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15836. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15837. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15838. builder.ParagraphFormat.Style.Font.Bold = false;
  15839. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15840. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15841. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15842. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15843. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15844. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15845. builder.Write($"{item.City}");
  15846. builder.EndRow();
  15847. #endregion
  15848. #region 第二行
  15849. builder.InsertCell();
  15850. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15851. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15852. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15853. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15854. builder.ParagraphFormat.Style.Font.Bold = false;
  15855. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15856. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15857. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15858. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15859. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15860. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15861. builder.Write("CONFIRMATION NO:");
  15862. builder.InsertCell();
  15863. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15864. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15865. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15866. builder.ParagraphFormat.Style.Font.Bold = false;
  15867. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15868. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15869. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15870. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15871. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15872. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15873. builder.CellFormat.VerticalMerge = CellMerge.None;
  15874. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15875. builder.Write($"{item.DetermineNo}");
  15876. builder.InsertCell();
  15877. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15878. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15879. builder.InsertCell();
  15880. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15881. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15882. builder.EndRow();
  15883. #endregion
  15884. #region 第三行
  15885. builder.InsertCell();
  15886. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15887. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15888. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15889. builder.ParagraphFormat.Style.Font.Bold = false;
  15890. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15891. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15892. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15893. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15894. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15895. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15896. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15897. builder.Write($"HOTEL NAME:");
  15898. builder.InsertCell();
  15899. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15900. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15901. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15902. builder.ParagraphFormat.Style.Font.Bold = false;
  15903. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15904. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15905. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15906. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15907. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15908. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15909. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15910. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15911. builder.Write($"{item.HotelName}");
  15912. builder.InsertCell();
  15913. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15914. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15915. builder.InsertCell();
  15916. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15917. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15918. builder.EndRow();
  15919. #endregion
  15920. #region 第四行
  15921. builder.InsertCell();
  15922. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15923. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15924. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15925. builder.ParagraphFormat.Style.Font.Bold = false;
  15926. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15927. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15928. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15929. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15930. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15931. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15932. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15933. builder.Write($"HOTEL ADDRESS:");
  15934. builder.InsertCell();
  15935. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15936. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15937. builder.ParagraphFormat.Style.Font.Size = 8;
  15938. builder.ParagraphFormat.Style.Font.Bold = false;
  15939. builder.CellFormat.HorizontalMerge = CellMerge.None;
  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.HorizontalMerge = CellMerge.First;
  15947. builder.Write($"{item.HotelAddress}");
  15948. builder.InsertCell();
  15949. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15950. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15951. builder.InsertCell();
  15952. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15953. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15954. builder.EndRow();
  15955. #endregion
  15956. #region 第五行
  15957. builder.InsertCell();
  15958. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15959. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15960. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15961. builder.ParagraphFormat.Style.Font.Bold = false;
  15962. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15963. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15964. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15965. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15966. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15967. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15968. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15969. builder.Write("TEL:");
  15970. builder.InsertCell();
  15971. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15972. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15973. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15974. builder.ParagraphFormat.Style.Font.Bold = false;
  15975. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15976. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15977. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15978. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15979. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15980. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15981. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15982. builder.Write($"{item.HotelTel}");
  15983. builder.InsertCell();
  15984. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15985. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15986. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15987. builder.ParagraphFormat.Style.Font.Bold = false;
  15988. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15989. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15990. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15991. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15992. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15993. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15994. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15995. builder.Write($"FAX:");
  15996. builder.InsertCell();
  15997. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15998. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15999. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16000. builder.ParagraphFormat.Style.Font.Bold = false;
  16001. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16002. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16003. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16004. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16005. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16006. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16007. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16008. builder.Write($"{item.HotelFax}");
  16009. builder.EndRow();
  16010. #endregion
  16011. #region 第六行
  16012. builder.InsertCell();
  16013. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16014. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16015. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16016. builder.ParagraphFormat.Style.Font.Bold = false;
  16017. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16018. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16019. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16020. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16021. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16022. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16023. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16024. builder.Write("CHECK IN:");
  16025. builder.InsertCell();
  16026. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16027. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16028. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16029. builder.ParagraphFormat.Style.Font.Bold = false;
  16030. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16031. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16032. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16033. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16034. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16035. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16036. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16037. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  16038. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  16039. builder.Write($"{checkInStr}");
  16040. builder.InsertCell();
  16041. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16042. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16043. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16044. builder.ParagraphFormat.Style.Font.Bold = false;
  16045. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16046. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16047. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16048. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16049. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16050. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16051. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16052. builder.Write($"CHECK OUT:");
  16053. builder.InsertCell();
  16054. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16055. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16056. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16057. builder.ParagraphFormat.Style.Font.Bold = false;
  16058. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16059. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16060. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16061. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16062. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16063. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16064. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16065. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  16066. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  16067. builder.Write($"{checkOutStr}");
  16068. builder.EndRow();
  16069. #endregion
  16070. #region 第七行
  16071. builder.InsertCell();
  16072. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16073. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16074. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16075. builder.ParagraphFormat.Style.Font.Bold = false;
  16076. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16077. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16078. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16079. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16080. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16081. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16082. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16083. builder.Write($"GUEST NAME:");
  16084. builder.InsertCell();
  16085. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16086. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16087. builder.ParagraphFormat.Style.Font.Size = 8;
  16088. builder.ParagraphFormat.Style.Font.Bold = false;
  16089. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16090. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16091. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16092. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16093. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16094. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16095. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16096. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16097. builder.Write($"{item.GuestName}");
  16098. builder.InsertCell();
  16099. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16100. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16101. builder.InsertCell();
  16102. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16103. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16104. builder.EndRow();
  16105. #endregion
  16106. #region 第八行
  16107. builder.InsertCell();
  16108. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16109. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16110. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16111. builder.ParagraphFormat.Style.Font.Bold = false;
  16112. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16113. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16114. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16115. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16116. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16117. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16118. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16119. builder.Write($"ROOM TYPE:");
  16120. builder.InsertCell();
  16121. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16122. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16123. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16124. builder.ParagraphFormat.Style.Font.Bold = false;
  16125. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16126. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16127. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16128. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16129. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16130. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16131. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16132. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16133. builder.Write($"{item.RoomExplanation}");
  16134. builder.InsertCell();
  16135. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16136. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16137. builder.InsertCell();
  16138. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16139. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16140. builder.EndRow();
  16141. #endregion
  16142. #region 第九行
  16143. builder.InsertCell();
  16144. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16145. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16146. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16147. builder.ParagraphFormat.Style.Font.Bold = false;
  16148. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16149. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16150. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  16151. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  16152. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  16153. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  16154. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  16155. builder.Write($"NOTE:");
  16156. builder.InsertCell();
  16157. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16158. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  16159. builder.ParagraphFormat.Style.Font.Size = 7.5;
  16160. builder.ParagraphFormat.Style.Font.Bold = false;
  16161. builder.CellFormat.HorizontalMerge = CellMerge.None;
  16162. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  16163. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  16164. builder.CellFormat.HorizontalMerge = CellMerge.First;
  16165. 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.");
  16166. builder.InsertCell();
  16167. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  16168. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16169. builder.InsertCell();
  16170. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  16171. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  16172. builder.EndRow();
  16173. #endregion
  16174. builder.EndTable();
  16175. //换行
  16176. builder.Writeln("");
  16177. builder.Writeln("");
  16178. }
  16179. #region 获取文档中的所有表格 设置文字自适应
  16180. // 获取文档中的所有表格。
  16181. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  16182. {
  16183. // 遍历表格中的所有行。
  16184. foreach (Aspose.Words.Tables.Row row in table.Rows)
  16185. {
  16186. foreach (Cell cell in row.Cells)
  16187. {
  16188. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  16189. cellFormat.Width = 0;
  16190. }
  16191. }
  16192. }
  16193. #endregion
  16194. #region 设置页眉
  16195. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  16196. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  16197. if (System.IO.File.Exists(voucherHeaderPath))
  16198. {
  16199. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  16200. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  16201. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  16202. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  16203. // 调整图片位置
  16204. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  16205. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  16206. shape.Top = 50; // 将图片距离页眉上边缘的距离
  16207. shape.Left = 0; // 将图片距离页面左边缘的距离
  16208. shape.Width = 81; // 设置图片宽度
  16209. shape.Height = 36; // 设置图片高度
  16210. }
  16211. //靠右
  16212. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  16213. //// 设置页脚上下边距
  16214. //builder.PageSetup.HeaderDistance = 42;
  16215. // 添加页眉线
  16216. Aspose.Words.Border borderHeader = null;
  16217. try
  16218. {
  16219. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  16220. }
  16221. catch (Exception e)
  16222. {
  16223. // TODO Auto-generated catch block
  16224. //e.printStackTrace();
  16225. }
  16226. borderHeader.Shadow = true;
  16227. borderHeader.DistanceFromText = 2;
  16228. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  16229. #endregion
  16230. }
  16231. catch (Exception ex)
  16232. {
  16233. }
  16234. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  16235. doc.Save(fileDir);
  16236. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  16237. return Ok(JsonView(true, "操作成功!", Url));
  16238. }
  16239. /// <summary>
  16240. /// 酒店预订
  16241. /// 生成 预定成本 Excel
  16242. /// </summary>
  16243. /// <param name="_dto"></param>
  16244. /// <returns></returns>
  16245. [HttpPost]
  16246. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16247. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  16248. {
  16249. #region 参数验证
  16250. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  16251. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  16252. if (!vadalitorRes.IsValid)
  16253. {
  16254. var errors = new StringBuilder();
  16255. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  16256. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  16257. }
  16258. #region 团组操作权限验证 76 酒店预定模块
  16259. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16260. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16261. #endregion
  16262. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16263. #region 页面操作权限验证
  16264. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16265. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16266. #endregion
  16267. #endregion
  16268. decimal _rate = 1.00M;
  16269. string _currency = string.Empty;
  16270. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  16271. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  16272. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  16273. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  16274. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  16275. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  16276. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  16277. if (_GroupCostParameter == null)
  16278. {
  16279. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  16280. bool isIntType = int.TryParse(_currency, out int currId);
  16281. if (isIntType)
  16282. {
  16283. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  16284. }
  16285. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  16286. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  16287. if (currInfo == null)
  16288. {
  16289. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  16290. }
  16291. else _rate = currInfo.Rate;
  16292. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  16293. {
  16294. _rate = _GroupCostParameter.Rate;
  16295. }
  16296. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  16297. //string strFileName = "HotelStatement/";
  16298. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  16299. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  16300. var rateDatas = new List<dynamic>();
  16301. #region 数据处理
  16302. foreach (var item in hrDtas)
  16303. {
  16304. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  16305. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  16306. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  16307. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  16308. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  16309. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  16310. {
  16311. continue;
  16312. }
  16313. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  16314. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  16315. string singleRoomFeeStr = string.Empty,
  16316. doubleRoomFeeStr = string.Empty,
  16317. suiteRoomFeeStr = string.Empty,
  16318. otherRoomFeeStr = string.Empty,
  16319. payMoneyStr = string.Empty,
  16320. cardPriceStr = string.Empty;
  16321. if (roomCurr.Equals("CNY"))
  16322. {
  16323. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  16324. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  16325. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  16326. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  16327. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  16328. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  16329. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  16330. }
  16331. else
  16332. {
  16333. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  16334. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  16335. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  16336. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  16337. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  16338. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  16339. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16340. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16341. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16342. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  16343. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  16344. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  16345. if (ccpPaymentCurrency.Equals("CNY"))
  16346. {
  16347. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  16348. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  16349. }
  16350. else
  16351. {
  16352. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  16353. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  16354. }
  16355. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  16356. if (hotelcardPriceCurrency.Equals("CNY"))
  16357. {
  16358. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  16359. }
  16360. else
  16361. {
  16362. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  16363. }
  16364. }
  16365. string breakfastPriceStr = string.Empty,
  16366. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  16367. governmentRentStr = string.Empty,
  16368. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  16369. cityTaxStr = string.Empty,
  16370. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  16371. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  16372. if (!string.IsNullOrEmpty(breakfastCurrency1))
  16373. {
  16374. if (breakfastCurrency1.Equals("CNY"))
  16375. {
  16376. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  16377. }
  16378. else
  16379. {
  16380. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  16381. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  16382. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  16383. }
  16384. }
  16385. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  16386. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  16387. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  16388. {
  16389. if (governmentRentCurrency.Equals("CNY"))
  16390. {
  16391. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  16392. }
  16393. else
  16394. {
  16395. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  16396. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  16397. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  16398. }
  16399. }
  16400. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  16401. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  16402. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  16403. {
  16404. if (cityTaxStrCurrency1.Equals("CNY"))
  16405. {
  16406. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  16407. }
  16408. else
  16409. {
  16410. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  16411. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  16412. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  16413. }
  16414. }
  16415. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  16416. int payDId = roomInfo?.PayDId ?? 0;
  16417. pcfds.Add(new HotelReservations_PCFD_View()
  16418. {
  16419. City = item.City,
  16420. HotelName = item.HotelName,
  16421. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  16422. // SingleRoomCount = item.SingleRoomCount,
  16423. SingleRoomPrice = singleRoomFeeStr,
  16424. // DoubleRoomCount = item.DoubleRoomCount,
  16425. DoubleRoomPrice = doubleRoomFeeStr,
  16426. //SuiteRoomCount = item.SuiteRoomCount,
  16427. SuiteRoomPrice = suiteRoomFeeStr,
  16428. OtherRoomPrice = otherRoomFeeStr,
  16429. //OtherRoomCount = item.OtherRoomCount,
  16430. BreakfastPrice = breakfastPriceStr,
  16431. GovernmentRent = governmentRentStr,
  16432. CityTax = cityTaxStr,
  16433. RoomExplanation = item.RoomExplanation,
  16434. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  16435. PayTime = roomInfo?.ConsumptionDate,
  16436. BankNo = roomInfo?.BankNo,
  16437. PayMoney = payMoneyStr,
  16438. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  16439. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  16440. CardPrice = cardPriceStr,
  16441. Remark = ccpInfo.Remark
  16442. });
  16443. }
  16444. #endregion
  16445. //载入模板
  16446. WorkbookDesigner designer = new WorkbookDesigner();
  16447. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  16448. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  16449. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  16450. designer.SetDataSource("TourNo", groupInfo.TourCode);
  16451. var rateDatas1 = rateDatas.Distinct();
  16452. var rateStr = string.Empty;
  16453. foreach (var item in rateDatas1)
  16454. {
  16455. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  16456. }
  16457. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  16458. designer.SetDataSource("Opertor", userInfo.CnName);
  16459. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  16460. dt.TableName = "ViewMyHotelReservations";
  16461. designer.SetDataSource(dt);
  16462. designer.Process();
  16463. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  16464. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  16465. designer.Workbook.Save(serverPath);
  16466. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  16467. #region 删除指定行
  16468. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  16469. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  16470. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  16471. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  16472. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  16473. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  16474. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  16475. cssIndex = dt.Columns["CityTax"].Ordinal,
  16476. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  16477. remarkIndex = dt.Columns["Remark"].Ordinal;
  16478. //删除指定列
  16479. foreach (DataRow item in dt.Rows)
  16480. {
  16481. string singleStr = item["SingleRoomPrice"].ToString();
  16482. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  16483. if (containsDigitButNotZero1) singleDel = false;
  16484. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  16485. string doubleStr = item["DoubleRoomPrice"].ToString();
  16486. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16487. if (containsDigitButNotZero2) doubleDel = false;
  16488. string suiteStr = item["SuiteRoomPrice"].ToString();
  16489. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16490. if (containsDigitButNotZero3) suiteDel = false;
  16491. string otherStr = item["OtherRoomPrice"].ToString();
  16492. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  16493. if (containsDigitButNotZero4) otherDel = false;
  16494. string zcStr = item["BreakfastPrice"].ToString();
  16495. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  16496. if (containsDigitButNotZero5) zcDel = false;
  16497. string dsStr = item["GovernmentRent"].ToString();
  16498. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  16499. if (containsDigitButNotZero6) dsDel = false;
  16500. string cssStr = item["CityTax"].ToString();
  16501. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  16502. if (containsDigitButNotZero7) cssDel = false;
  16503. string cpStr = item["ConsumptionPatterns"].ToString();
  16504. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  16505. string remarkStr = item["Remark"].ToString();
  16506. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  16507. }
  16508. DeleteColumn(serverPath, remarkIndex, remarkDel);
  16509. DeleteColumn(serverPath, cpIndex, cpDel);
  16510. DeleteColumn(serverPath, dsIndex, dsDel);
  16511. DeleteColumn(serverPath, cssIndex, cssDel);
  16512. DeleteColumn(serverPath, zcIndex, zcDel);
  16513. DeleteColumn(serverPath, otherIndex, otherDel);
  16514. DeleteColumn(serverPath, suiteIndex, suiteDel);
  16515. DeleteColumn(serverPath, doubleIndex, doubleDel);
  16516. DeleteColumn(serverPath, singleIndex, singleDel);
  16517. #endregion
  16518. //只保留第一个表格
  16519. DeleteSheet(serverPath);
  16520. return Ok(JsonView(true, "操作成功", url = rst));
  16521. }
  16522. else
  16523. {
  16524. _currency = _GroupCostParameter.Currency;
  16525. bool isIntType = int.TryParse(_currency, out int currId);
  16526. if (isIntType)
  16527. {
  16528. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  16529. }
  16530. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  16531. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  16532. if (currInfo == null)
  16533. {
  16534. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  16535. }
  16536. if (!_currency.ToUpper().Equals("CNY"))
  16537. {
  16538. _rate = _GroupCostParameter.Rate;
  16539. }
  16540. _rate = currInfo.Rate;
  16541. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  16542. //string strFileName = "HotelStatement/";
  16543. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  16544. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  16545. #region 数据处理
  16546. foreach (var item in hrDtas)
  16547. {
  16548. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  16549. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  16550. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  16551. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  16552. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  16553. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  16554. string singleRoomFeeStr = string.Empty,
  16555. doubleRoomFeeStr = string.Empty,
  16556. suiteRoomFeeStr = string.Empty,
  16557. otherRoomFeeStr = string.Empty,
  16558. payMoneyStr = string.Empty,
  16559. cardPriceStr = string.Empty;
  16560. if (roomCurr.Equals(_currency))
  16561. {
  16562. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  16563. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  16564. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  16565. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  16566. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  16567. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  16568. }
  16569. else
  16570. {
  16571. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  16572. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  16573. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  16574. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  16575. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  16576. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  16577. }
  16578. string breakfastPriceStr = string.Empty,
  16579. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  16580. governmentRentStr = string.Empty,
  16581. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  16582. cityTaxStrStr = string.Empty,
  16583. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  16584. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  16585. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  16586. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  16587. int payDId = roomInfo?.PayDId ?? 0;
  16588. pcfds.Add(new HotelReservations_PCFD_View()
  16589. {
  16590. City = item.City,
  16591. HotelName = item.HotelName,
  16592. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  16593. // SingleRoomCount = item.SingleRoomCount,
  16594. SingleRoomPrice = singleRoomFeeStr,
  16595. // DoubleRoomCount = item.DoubleRoomCount,
  16596. DoubleRoomPrice = doubleRoomFeeStr,
  16597. //SuiteRoomCount = item.SuiteRoomCount,
  16598. SuiteRoomPrice = suiteRoomFeeStr,
  16599. OtherRoomPrice = otherRoomFeeStr,
  16600. //OtherRoomCount = item.OtherRoomCount,
  16601. BreakfastPrice = breakfastPriceStr,
  16602. GovernmentRent = governmentRentStr,
  16603. CityTax = cityTaxStrStr,
  16604. RoomExplanation = item.RoomExplanation,
  16605. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  16606. PayTime = roomInfo?.ConsumptionDate,
  16607. BankNo = roomInfo?.BankNo,
  16608. PayMoney = payMoneyStr,
  16609. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  16610. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  16611. CardPrice = cardPriceStr,
  16612. Remark = ccpInfo.Remark
  16613. });
  16614. }
  16615. #endregion
  16616. //载入模板
  16617. WorkbookDesigner designer = new WorkbookDesigner();
  16618. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  16619. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  16620. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  16621. designer.SetDataSource("TourNo", groupInfo.TourCode);
  16622. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  16623. designer.SetDataSource("Opertor", userInfo.CnName);
  16624. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  16625. dt.TableName = "ViewMyHotelReservations";
  16626. designer.SetDataSource(dt);
  16627. designer.Process();
  16628. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  16629. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  16630. designer.Workbook.Save(serverPath);
  16631. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  16632. #region 删除指定行
  16633. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  16634. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  16635. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  16636. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  16637. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  16638. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  16639. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  16640. cssIndex = dt.Columns["CityTax"].Ordinal,
  16641. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  16642. remarkIndex = dt.Columns["Remark"].Ordinal;
  16643. //删除指定列
  16644. foreach (DataRow item in dt.Rows)
  16645. {
  16646. string singleStr = item["SingleRoomPrice"].ToString();
  16647. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  16648. if (containsDigitButNotZero1) singleDel = false;
  16649. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  16650. string doubleStr = item["DoubleRoomPrice"].ToString();
  16651. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16652. if (containsDigitButNotZero2) doubleDel = false;
  16653. string suiteStr = item["SuiteRoomPrice"].ToString();
  16654. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16655. if (containsDigitButNotZero3) suiteDel = false;
  16656. string otherStr = item["OtherRoomPrice"].ToString();
  16657. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  16658. if (containsDigitButNotZero4) otherDel = false;
  16659. string zcStr = item["BreakfastPrice"].ToString();
  16660. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  16661. if (containsDigitButNotZero5) zcDel = false;
  16662. string dsStr = item["GovernmentRent"].ToString();
  16663. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  16664. if (containsDigitButNotZero6) dsDel = false;
  16665. string cssStr = item["CityTax"].ToString();
  16666. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  16667. if (containsDigitButNotZero7) cssDel = false;
  16668. string cpStr = item["ConsumptionPatterns"].ToString();
  16669. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  16670. string remarkStr = item["Remark"].ToString();
  16671. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  16672. }
  16673. DeleteColumn(serverPath, remarkIndex, remarkDel);
  16674. DeleteColumn(serverPath, cpIndex, cpDel);
  16675. DeleteColumn(serverPath, dsIndex, dsDel);
  16676. DeleteColumn(serverPath, cssIndex, cssDel);
  16677. DeleteColumn(serverPath, zcIndex, zcDel);
  16678. DeleteColumn(serverPath, otherIndex, otherDel);
  16679. DeleteColumn(serverPath, suiteIndex, suiteDel);
  16680. DeleteColumn(serverPath, doubleIndex, doubleDel);
  16681. DeleteColumn(serverPath, singleIndex, singleDel);
  16682. #endregion
  16683. //只保留第一个表格
  16684. DeleteSheet(serverPath);
  16685. return Ok(JsonView(true, "操作成功", url = rst));
  16686. }
  16687. //return Ok(JsonView(false));
  16688. }
  16689. /// <summary>
  16690. /// 删除指定列
  16691. /// </summary>
  16692. /// <param name="file"></param>
  16693. /// <param name="columnIndex"></param>
  16694. /// <param name="isDel"></param>
  16695. private void DeleteColumn(string file, int columnIndex, bool isDel)
  16696. {
  16697. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16698. //wb.Save(file);
  16699. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  16700. if (sheet1 != null)
  16701. {
  16702. if (isDel)
  16703. {
  16704. Cells cells = sheet1.Cells;
  16705. cells.DeleteColumn(columnIndex);
  16706. }
  16707. }
  16708. wb.Save(file);
  16709. }
  16710. /// <summary>
  16711. /// 删除sheet
  16712. /// </summary>
  16713. /// <param name="file"></param>
  16714. /// <param name="sheetName"></param>
  16715. private void DeleteSheet(string file, string sheetName = "")
  16716. {
  16717. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16718. //wb.Save(file);
  16719. List<string> sheets = new List<string>();
  16720. foreach (var item in wb.Worksheets)
  16721. {
  16722. sheets.Add(item.Name);
  16723. }
  16724. if (sheets.Count > 0)
  16725. {
  16726. sheets.RemoveAt(0);//不删除第一个sheet
  16727. foreach (var item in sheets)
  16728. {
  16729. wb.Worksheets.RemoveAt(item);
  16730. }
  16731. }
  16732. wb.Save(file);
  16733. }
  16734. /// <summary>
  16735. /// 酒店预订
  16736. /// 确认单
  16737. /// </summary>
  16738. /// <param name="_dto"></param>
  16739. /// <returns></returns>
  16740. [HttpPost]
  16741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16742. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  16743. {
  16744. try
  16745. {
  16746. #region 参数验证
  16747. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  16748. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16749. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  16750. #region 团组操作权限验证 76 酒店预定模块
  16751. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16752. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  16753. #endregion
  16754. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16755. #region 页面操作权限验证
  16756. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16757. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16758. #endregion
  16759. #endregion
  16760. //团组信息
  16761. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  16762. //酒店数据
  16763. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  16764. if (listhoteldata.Count < 0)
  16765. {
  16766. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  16767. }
  16768. //利datatable存储
  16769. DataTable dt = new DataTable();
  16770. dt.Columns.Add("CheckInDate", typeof(string));
  16771. dt.Columns.Add("City", typeof(string));
  16772. dt.Columns.Add("Hotel", typeof(string));
  16773. dt.Columns.Add("Room", typeof(string));
  16774. for (int i = 0; i < listhoteldata.Count; i++)
  16775. {
  16776. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  16777. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  16778. while (dayStart < dayEnd)
  16779. {
  16780. string temp = "";
  16781. DataRow row = dt.NewRow();
  16782. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  16783. row["City"] = listhoteldata[i].City;
  16784. row["Hotel"] = listhoteldata[i].HotelName;
  16785. if (listhoteldata[i].SingleRoomCount > 0)
  16786. {
  16787. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  16788. }
  16789. if (listhoteldata[i].DoubleRoomCount > 0)
  16790. {
  16791. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  16792. }
  16793. if (listhoteldata[i].SuiteRoomCount > 0)
  16794. {
  16795. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  16796. }
  16797. if (listhoteldata[i].OtherRoomCount > 0)
  16798. {
  16799. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  16800. }
  16801. row["Room"] = temp;
  16802. dt.Rows.Add(row);
  16803. dayStart = dayStart.AddDays(1);
  16804. }
  16805. }
  16806. Dictionary<string, string> dic = new Dictionary<string, string>();
  16807. dic.Add("Dele", di.TeamName);
  16808. dic.Add("City", di.VisitCountry);
  16809. //模板路径
  16810. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  16811. //载入模板
  16812. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  16813. DocumentBuilder builder = new DocumentBuilder(doc);
  16814. foreach (var key in dic.Keys)
  16815. {
  16816. builder.MoveToBookmark(key);
  16817. builder.Write(dic[key]);
  16818. }
  16819. //获取word里所有表格
  16820. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16821. //获取所填表格的序数
  16822. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16823. var rowStart = tableOne.Rows[0]; //获取第1行
  16824. //循环赋值
  16825. for (int i = 0; i < dt.Rows.Count; i++)
  16826. {
  16827. builder.MoveToCell(0, i + 1, 0, 0);
  16828. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  16829. builder.MoveToCell(0, i + 1, 1, 0);
  16830. builder.Write(dt.Rows[i]["City"].ToString());
  16831. builder.MoveToCell(0, i + 1, 2, 0);
  16832. builder.Write(dt.Rows[i]["Hotel"].ToString());
  16833. builder.MoveToCell(0, i + 1, 3, 0);
  16834. builder.Write(dt.Rows[i]["Room"].ToString());
  16835. }
  16836. //删除多余行
  16837. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  16838. {
  16839. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  16840. }
  16841. string strFileName = di.TeamName + "酒店确认单.doc";
  16842. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  16843. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  16844. return Ok(JsonView(true, "成功", url));
  16845. }
  16846. catch (Exception ex)
  16847. {
  16848. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  16849. }
  16850. }
  16851. #endregion
  16852. #region 团组状态
  16853. /// <summary>
  16854. /// 团组状态列表 Page
  16855. /// </summary>
  16856. /// <param name="dto">团组列表请求dto</param>
  16857. /// <returns></returns>
  16858. [HttpPost]
  16859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16860. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  16861. {
  16862. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16863. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  16864. {
  16865. string sqlWhere = string.Empty;
  16866. if (dto.IsSure == 0) //未完成
  16867. {
  16868. sqlWhere += string.Format(@" And IsSure = 0");
  16869. }
  16870. else if (dto.IsSure == 1) //已完成
  16871. {
  16872. sqlWhere += string.Format(@" And IsSure = 1");
  16873. }
  16874. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  16875. {
  16876. string tj = dto.SearchCriteria;
  16877. 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}%')",
  16878. tj, tj, tj, tj, tj);
  16879. }
  16880. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  16881. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  16882. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  16883. From (
  16884. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  16885. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  16886. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  16887. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  16888. From Grp_DelegationInfo gdi
  16889. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  16890. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  16891. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  16892. Where gdi.IsDel = 0 {0}
  16893. ) temp ", sqlWhere);
  16894. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  16895. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  16896. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  16897. }
  16898. else
  16899. {
  16900. return Ok(JsonView(false, "查询失败"));
  16901. }
  16902. }
  16903. /// <summary>
  16904. /// 团组状态
  16905. /// 设置操作完成
  16906. /// </summary>
  16907. /// <param name="dto">团组列表请求dto</param>
  16908. /// <returns></returns>
  16909. [HttpPost]
  16910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16911. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  16912. {
  16913. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16914. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  16915. {
  16916. Id = dto.Id,
  16917. IsSure = 1
  16918. };
  16919. var result = await _sqlSugar.Updateable(_DelegationInfo)
  16920. .UpdateColumns(it => new { it.IsSure })
  16921. .WhereColumns(it => new { it.Id })
  16922. .ExecuteCommandAsync();
  16923. if (result > 0)
  16924. {
  16925. return Ok(JsonView(true, "操作完成!"));
  16926. }
  16927. return Ok(JsonView(false, "操作失败!"));
  16928. }
  16929. #endregion
  16930. #region 保险费用录入
  16931. /// <summary>
  16932. /// 根据团组Id查询保险费用列表
  16933. /// </summary>
  16934. /// <param name="dto"></param>
  16935. /// <returns></returns>
  16936. [HttpPost]
  16937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16938. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  16939. {
  16940. Result groupData = await _customersRep.CustomersByDiId(dto);
  16941. if (groupData.Code != 0)
  16942. {
  16943. return Ok(JsonView(false, groupData.Msg));
  16944. }
  16945. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16946. }
  16947. /// <summary>
  16948. /// 根据保险费用Id查询保险费用详细
  16949. /// </summary>
  16950. /// <param name="dto"></param>
  16951. /// <returns></returns>
  16952. [HttpPost]
  16953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16954. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  16955. {
  16956. try
  16957. {
  16958. Result groupData = await _customersRep.CustomersById(dto);
  16959. if (groupData.Code != 0)
  16960. {
  16961. return Ok(JsonView(false, groupData.Msg));
  16962. }
  16963. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16964. }
  16965. catch (Exception ex)
  16966. {
  16967. return Ok(JsonView(false, ex.Message));
  16968. }
  16969. }
  16970. /// <summary>
  16971. /// 保险费用录入页面初始化绑定
  16972. /// </summary>
  16973. /// <param name="dto"></param>
  16974. /// <returns></returns>
  16975. [HttpPost]
  16976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16977. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  16978. {
  16979. try
  16980. {
  16981. Result groupData = await _customersRep.CustomersInitialize(dto);
  16982. if (groupData.Code != 0)
  16983. {
  16984. return Ok(JsonView(false, groupData.Msg));
  16985. }
  16986. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16987. }
  16988. catch (Exception ex)
  16989. {
  16990. return Ok(JsonView(false, ex.Message));
  16991. }
  16992. }
  16993. /// <summary>
  16994. /// 保险费用操作(Status:1.新增,2.修改)
  16995. /// </summary>
  16996. /// <param name="dto"></param>
  16997. /// <returns></returns>
  16998. [HttpPost]
  16999. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17000. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  17001. {
  17002. Result groupData = await _customersRep.OpCustomers(dto);
  17003. if (groupData.Code != 0)
  17004. {
  17005. return Ok(JsonView(false, groupData.Msg));
  17006. }
  17007. #region 应用推送
  17008. try
  17009. {
  17010. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  17011. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  17012. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  17013. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17014. //自动审核
  17015. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  17016. //2024-10-21 新增LZ UID
  17017. var userIds = new List<int>() { 21 };
  17018. string title = $"系统通知";
  17019. var diId = dto.DiId;
  17020. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17021. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17022. string content = "";
  17023. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17024. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17025. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17026. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  17027. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  17028. }
  17029. catch (Exception ex)
  17030. {
  17031. }
  17032. #endregion
  17033. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  17034. }
  17035. /// <summary>
  17036. /// 保险文件上传
  17037. /// </summary>
  17038. /// <param name="file"></param>
  17039. /// <returns></returns>
  17040. [HttpPost]
  17041. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17042. public async Task<IActionResult> UploadCus(IFormFile file)
  17043. {
  17044. try
  17045. {
  17046. if (file != null)
  17047. {
  17048. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  17049. //文件名称
  17050. string projectFileName = file.FileName;
  17051. //上传的文件的路径
  17052. string filePath = "";
  17053. if (!Directory.Exists(fileDir))
  17054. {
  17055. Directory.CreateDirectory(fileDir);
  17056. }
  17057. //上传的文件的路径
  17058. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  17059. using (FileStream fs = System.IO.File.Create(filePath))
  17060. {
  17061. file.CopyTo(fs);
  17062. fs.Flush();
  17063. }
  17064. return Ok(JsonView(true, "上传成功!", projectFileName));
  17065. }
  17066. else
  17067. {
  17068. return Ok(JsonView(false, "上传失败!"));
  17069. }
  17070. }
  17071. catch (Exception ex)
  17072. {
  17073. return Ok(JsonView(false, "程序错误!"));
  17074. throw;
  17075. }
  17076. }
  17077. /// <summary>
  17078. /// 保险删除指定文件
  17079. /// </summary>
  17080. /// <param name="dto"></param>
  17081. /// <returns></returns>
  17082. [HttpPost]
  17083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17084. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  17085. {
  17086. try
  17087. {
  17088. string filePath = "";
  17089. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  17090. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  17091. //int id = 0;
  17092. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  17093. // 删除该文件
  17094. try
  17095. {
  17096. System.IO.File.Delete(filePath);
  17097. 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()
  17098. {
  17099. Attachment = "",
  17100. }).ExecuteCommandAsync();
  17101. if (result != 0)
  17102. {
  17103. return Ok(JsonView(true, "成功!"));
  17104. }
  17105. else
  17106. {
  17107. return Ok(JsonView(false, "失败!"));
  17108. }
  17109. }
  17110. catch (Exception)
  17111. {
  17112. 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()
  17113. {
  17114. Attachment = "",
  17115. }).ExecuteCommandAsync();
  17116. if (result != 0)
  17117. {
  17118. return Ok(JsonView(true, "成功!"));
  17119. }
  17120. else
  17121. {
  17122. return Ok(JsonView(false, "失败!"));
  17123. }
  17124. }
  17125. }
  17126. catch (Exception ex)
  17127. {
  17128. return Ok(JsonView(false, "程序错误!"));
  17129. throw;
  17130. }
  17131. }
  17132. /// <summary>
  17133. /// 保险费用操作(删除)
  17134. /// </summary>
  17135. /// <param name="dto"></param>
  17136. /// <returns></returns>
  17137. [HttpPost]
  17138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17139. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  17140. {
  17141. try
  17142. {
  17143. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  17144. if (!res)
  17145. {
  17146. return Ok(JsonView(false, "删除失败"));
  17147. }
  17148. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  17149. {
  17150. IsDel = 1,
  17151. DeleteUserId = dto.DeleteUserId,
  17152. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  17153. }).ExecuteCommandAsync();
  17154. return Ok(JsonView(true, "删除成功!"));
  17155. }
  17156. catch (Exception ex)
  17157. {
  17158. return Ok(JsonView(false, "程序错误!"));
  17159. throw;
  17160. }
  17161. }
  17162. #endregion
  17163. #region 接团客户名单 PageId 104
  17164. /// <summary>
  17165. /// 接团客户名单
  17166. /// 迁移数据(慎用!)
  17167. /// </summary>
  17168. /// <returns></returns>
  17169. [HttpPost]
  17170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17171. public async Task<IActionResult> PostTourClientListChange()
  17172. {
  17173. try
  17174. {
  17175. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  17176. //var groupClinetData1
  17177. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  17178. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  17179. int updateCount = 0;
  17180. if (oldOAClientList.Count > 0)
  17181. {
  17182. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  17183. _sqlSugar.BeginTran();
  17184. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  17185. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  17186. foreach (var item in oldOAClientList)
  17187. {
  17188. int comId = 0;
  17189. string format = "yyyy-MM-dd HH:mm:ss";
  17190. string data11 = "1990-01-01 00:00";
  17191. var data1 = IsValidDate(item.OPdate, format);
  17192. if (data1) data11 = item.OPdate;
  17193. //客户公司验证
  17194. if (!string.IsNullOrEmpty(item.Company))
  17195. {
  17196. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  17197. if (clientComInfo == null) // add
  17198. {
  17199. var addInfo = new Crm_CustomerCompany()
  17200. {
  17201. CompanyAbbreviation = "",
  17202. CompanyFullName = item.Company,
  17203. Address = "",
  17204. PostCodes = "",
  17205. LastedOpUserId = item.OPer,
  17206. LastedOpDt = Convert.ToDateTime(data11),
  17207. CreateUserId = item.OPer,
  17208. CreateTime = Convert.ToDateTime(data11),
  17209. IsDel = 0
  17210. };
  17211. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  17212. if (comId1 > 0) comId = comId1;
  17213. }
  17214. else comId = clientComInfo.Id;
  17215. }
  17216. //客户人员验证
  17217. int clientId = 0;
  17218. string name = item.LastName + item.Name;
  17219. if (!string.IsNullOrEmpty(name))
  17220. {
  17221. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  17222. if (clientInfo == null)
  17223. {
  17224. DateTime? dateTime = null;
  17225. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  17226. if (isDt) dateTime = birthDayDt;
  17227. var addInfo1 = new Crm_DeleClient()
  17228. {
  17229. CrmCompanyId = comId,
  17230. DiId = -1,
  17231. LastName = item.LastName,
  17232. FirstName = item.Name,
  17233. OldName = "",
  17234. Pinyin = item.Pinyin,
  17235. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  17236. Marriage = 0,
  17237. Phone = item.Phone,
  17238. Job = item.Job,
  17239. BirthDay = dateTime
  17240. };
  17241. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  17242. if (clientId1 > 0) clientId = clientId1;
  17243. }
  17244. else clientId = clientInfo.Id;
  17245. }
  17246. if (clientId < 1)
  17247. {
  17248. continue;
  17249. }
  17250. int airType = 0;
  17251. if (item.AirType == "超经舱") airType = 459;
  17252. else if (item.AirType == "公务舱") airType = 458;
  17253. else if (item.AirType == "经济舱") airType = 460;
  17254. else if (item.AirType == "其他") airType = 565;
  17255. else if (item.AirType == "头等舱") airType = 457;
  17256. var _TourClientListEntity = new Grp_TourClientList()
  17257. {
  17258. DiId = item.Diid,
  17259. ClientId = clientId,
  17260. CreateUserId = item.OPer,
  17261. CreateTime = Convert.ToDateTime(data11),
  17262. Remark = item.Remark,
  17263. IsDel = item.Isdel,
  17264. ShippingSpaceTypeId = airType,
  17265. ShippingSpaceSpecialNeeds = item.AirRemark,
  17266. HotelSpecialNeeds = item.RoomType
  17267. };
  17268. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  17269. if (_TourClientList > 0)
  17270. {
  17271. updateCount++;
  17272. }
  17273. }
  17274. _sqlSugar.CommitTran();
  17275. }
  17276. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  17277. }
  17278. catch (Exception ex)
  17279. {
  17280. _sqlSugar.RollbackTran();
  17281. return Ok(JsonView(false, ex.Message));
  17282. }
  17283. //return Ok(JsonView(true));
  17284. }
  17285. private bool IsValidDate(string dateString, string format)
  17286. {
  17287. DateTime dateValue;
  17288. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  17289. return valid;
  17290. }
  17291. /// <summary>
  17292. /// 接团客户名单
  17293. /// 根据团组Id查询List
  17294. /// </summary>
  17295. /// <param name="_dto"></param>
  17296. /// <returns></returns>
  17297. [HttpPost]
  17298. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17299. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  17300. {
  17301. #region 参数验证
  17302. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  17303. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  17304. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  17305. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17306. #region 页面操作权限验证
  17307. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17308. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17309. #endregion
  17310. #endregion
  17311. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  17312. if (viewData.Code != 0)
  17313. {
  17314. return Ok(JsonView(false, viewData.Msg));
  17315. }
  17316. return Ok(JsonView(viewData.Data));
  17317. }
  17318. /// <summary>
  17319. /// 接团客户名单
  17320. /// 基础数据 Init
  17321. /// </summary>
  17322. /// <param name="_dto"></param>
  17323. /// <returns></returns>
  17324. [HttpPost]
  17325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17326. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  17327. {
  17328. #region 参数验证
  17329. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17330. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17331. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17332. #region 页面操作权限验证
  17333. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17334. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17335. #endregion
  17336. #endregion
  17337. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  17338. }
  17339. /// <summary>
  17340. /// 接团客户名单
  17341. /// 根据 Id查询 Details
  17342. /// </summary>
  17343. /// <param name="_dto"></param>
  17344. /// <returns></returns>
  17345. [HttpPost]
  17346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17347. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  17348. {
  17349. #region 参数验证
  17350. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17351. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17352. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  17353. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17354. #region 页面操作权限验证
  17355. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17356. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  17357. #endregion
  17358. #endregion
  17359. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  17360. if (viewData.Code != 0)
  17361. {
  17362. return Ok(JsonView(false, viewData.Msg));
  17363. }
  17364. return Ok(JsonView(viewData.Data));
  17365. }
  17366. /// <summary>
  17367. /// 接团客户名单
  17368. /// Add Or Edit
  17369. /// </summary>
  17370. /// <param name="_dto"></param>
  17371. /// <returns></returns>
  17372. [HttpPost]
  17373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17374. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  17375. {
  17376. #region 参数验证
  17377. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17378. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17379. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  17380. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17381. #region 页面操作权限验证
  17382. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17383. if (_dto.Id == 0) //添加
  17384. {
  17385. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17386. }
  17387. else if (_dto.Id >= 0) //修改
  17388. {
  17389. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  17390. }
  17391. #endregion
  17392. #endregion
  17393. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  17394. if (viewData.Code != 0)
  17395. {
  17396. return Ok(JsonView(false, viewData.Msg));
  17397. }
  17398. return Ok(JsonView(true));
  17399. }
  17400. /// <summary>
  17401. /// 接团客户名单
  17402. /// json字符串 AddMultiple(添加多个)
  17403. /// </summary>
  17404. /// <param name="_dto"></param>
  17405. /// <returns></returns>
  17406. [HttpPost]
  17407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17408. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  17409. {
  17410. #region 参数验证
  17411. string jsonLabel = _dto.JsonLabel;
  17412. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17413. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17414. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17415. #region 页面操作权限验证
  17416. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17417. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17418. #endregion
  17419. #endregion
  17420. var request = new TourClientListAddMultipleDto();
  17421. request.DiId = _dto.DiId;
  17422. request.UserId = _dto.UserId;
  17423. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  17424. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  17425. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  17426. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  17427. var infos = new List<TourClientListInfo>();
  17428. foreach (var data in datas)
  17429. {
  17430. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  17431. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  17432. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  17433. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  17434. {
  17435. continue;
  17436. }
  17437. infos.Add(new TourClientListInfo()
  17438. {
  17439. IsAccompany = 1,
  17440. LastName = lastName,
  17441. FirstName = firstName,
  17442. Pinyin = lastNameEn + @"/" + firstNameEn,
  17443. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  17444. CompanyFullName = data.CompanyFullName,
  17445. Job = data.Job
  17446. });
  17447. }
  17448. if (infos.Any())
  17449. {
  17450. var viewData = await _tourClientListRep._AddMultiple(request);
  17451. if (viewData.Code != 0)
  17452. {
  17453. return Ok(JsonView(false, viewData.Msg));
  17454. }
  17455. return Ok(JsonView(true));
  17456. }
  17457. return Ok(JsonView(false));
  17458. }
  17459. /// <summary>
  17460. /// 接团客户名单
  17461. /// AddMultiple(添加多个)
  17462. /// </summary>
  17463. /// <param name="_dto"></param>
  17464. /// <returns></returns>
  17465. [HttpPost]
  17466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17467. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  17468. {
  17469. #region 参数验证
  17470. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17471. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17472. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17473. #region 页面操作权限验证
  17474. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17475. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  17476. #endregion
  17477. #endregion
  17478. var viewData = await _tourClientListRep._AddMultiple(_dto);
  17479. if (viewData.Code != 0)
  17480. {
  17481. return Ok(JsonView(false, viewData.Msg));
  17482. }
  17483. return Ok(JsonView(true));
  17484. }
  17485. /// <summary>
  17486. /// 接团客户名单
  17487. /// Del
  17488. /// </summary>
  17489. /// <param name="_dto"></param>
  17490. /// <returns></returns>
  17491. [HttpPost]
  17492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17493. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  17494. {
  17495. #region 参数验证
  17496. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17497. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17498. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17499. #region 页面操作权限验证
  17500. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17501. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  17502. #endregion
  17503. #endregion
  17504. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  17505. if (viewData.Code != 0)
  17506. {
  17507. return Ok(JsonView(false, viewData.Msg));
  17508. }
  17509. return Ok(JsonView(true));
  17510. }
  17511. /// <summary>
  17512. /// 接团客户名单
  17513. /// 文件下载 客户名单
  17514. /// </summary>
  17515. /// <param name="_dto"></param>
  17516. /// <returns></returns>
  17517. [HttpPost]
  17518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17519. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  17520. {
  17521. #region 参数验证
  17522. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  17523. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  17524. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  17525. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17526. #region 页面操作权限验证
  17527. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17528. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17529. #endregion
  17530. #endregion
  17531. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  17532. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  17533. From Grp_TourClientList tcl
  17534. Left Join
  17535. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  17536. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  17537. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  17538. From Crm_DeleClient dc
  17539. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  17540. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  17541. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  17542. Where dc.IsDel = 0) temp
  17543. On temp.DcId =tcl.ClientId
  17544. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  17545. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  17546. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  17547. //载入模板
  17548. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  17549. if (_dto.Language == 1)
  17550. {
  17551. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  17552. }
  17553. //载入模板
  17554. var doc = new Document(tempPath);
  17555. DocumentBuilder builder = new DocumentBuilder(doc);
  17556. //获取word里所有表格
  17557. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17558. //获取所填表格的序数
  17559. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  17560. var rowStart = tableOne.Rows[0]; //获取第1行
  17561. if (_dto.Language == 0)
  17562. {
  17563. //循环赋值
  17564. for (int i = 0; i < DcList.Count; i++)
  17565. {
  17566. EncryptionProcessor.DecryptProperties(DcList[i]);
  17567. builder.MoveToCell(0, i + 1, 0, 0);
  17568. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  17569. builder.MoveToCell(0, i + 1, 1, 0);
  17570. int sex = DcList[i].Sex;
  17571. string sexStr = string.Empty;
  17572. if (sex == 0) sexStr = "男";
  17573. else if (sex == 1) sexStr = "女";
  17574. else sexStr = "未设置";
  17575. builder.Write(sexStr);
  17576. builder.MoveToCell(0, i + 1, 2, 0);
  17577. string birthDay = DcList[i].BirthDay;
  17578. string birthDayStr = string.Empty;
  17579. if (!string.IsNullOrEmpty(birthDay))
  17580. {
  17581. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  17582. }
  17583. builder.Write(birthDayStr);
  17584. builder.MoveToCell(0, i + 1, 3, 0);
  17585. string company = "";
  17586. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  17587. {
  17588. company = DcList[i].CompanyFullName.ToString();
  17589. }
  17590. builder.Write(company);
  17591. builder.MoveToCell(0, i + 1, 4, 0);
  17592. builder.Write(DcList[i].Job);
  17593. }
  17594. }
  17595. else if (_dto.Language == 1)
  17596. {
  17597. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  17598. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  17599. List<string> transArrayStr = new List<string>();
  17600. string transStrRes1 = "";
  17601. for (int i = 0; i < DcList.Count; i++)
  17602. {
  17603. var dc = DcList[i];
  17604. EncryptionProcessor.DecryptProperties(dc);
  17605. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  17606. if (dc.Job.Equals("暂无")) dc.Job = "-";
  17607. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  17608. if (DcList.Count - 1 == i) transStrRes1 += str1;
  17609. else transStrRes1 += $"{str1}|";
  17610. }
  17611. //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";
  17612. string transStrRes = "";
  17613. if (transStrRes1.Length > 0)
  17614. {
  17615. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  17616. }
  17617. //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
  17618. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  17619. //List<string> transArray = new List<string> { };
  17620. List<TranslateInfo> transArray = new List<TranslateInfo>();
  17621. if (transStrRes.Contains("|"))
  17622. {
  17623. string[] transArray1 = transStrRes.Split('|');
  17624. if (transArray1.Length > 0)
  17625. {
  17626. foreach (var item in transArray1)
  17627. {
  17628. if (item.Contains("&"))
  17629. {
  17630. string[] transArray2 = item.Split('&');
  17631. int index = 0;
  17632. string companyName = "", job = "";
  17633. if (transArray2.Length > 0)
  17634. {
  17635. bool success = int.TryParse(transArray2[0].Trim(), out index);
  17636. if (1 < transArray2.Length) companyName = transArray2[1];
  17637. if (2 < transArray2.Length) job = transArray2[2];
  17638. }
  17639. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  17640. }
  17641. }
  17642. }
  17643. }
  17644. //循环赋值
  17645. for (int i = 0; i < DcList.Count; i++)
  17646. {
  17647. string PYName = "";
  17648. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  17649. {
  17650. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  17651. string PY_First = DcList[i].Pinyin.Split('/')[1];
  17652. PYName = PY_First + " " + PY_Last;
  17653. }
  17654. else
  17655. {
  17656. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  17657. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  17658. PYName = PY_First + " " + PY_Last;
  17659. }
  17660. builder.MoveToCell(0, i + 1, 0, 0);
  17661. builder.Write(PYName);
  17662. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  17663. builder.MoveToCell(0, i + 1, 1, 0);
  17664. builder.Write(sex);
  17665. DateTime birthDt;
  17666. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  17667. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  17668. builder.MoveToCell(0, i + 1, 2, 0);
  17669. builder.Write(birthday);
  17670. string company = string.Empty, job = string.Empty;
  17671. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  17672. if (dcTransInfo != null)
  17673. {
  17674. company = dcTransInfo.CompanyName;
  17675. job = dcTransInfo.Job;
  17676. }
  17677. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  17678. {
  17679. //查询对照表
  17680. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  17681. if (tempCec != null)
  17682. {
  17683. company = tempCec.enName;
  17684. }
  17685. //翻译
  17686. else
  17687. {
  17688. }
  17689. }
  17690. builder.MoveToCell(0, i + 1, 3, 0);
  17691. builder.Write(company);
  17692. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  17693. {
  17694. //查询对照表
  17695. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  17696. if (tempPec != null)
  17697. {
  17698. job = tempPec.enName;
  17699. }
  17700. //翻译
  17701. else
  17702. {
  17703. }
  17704. }
  17705. builder.MoveToCell(0, i + 1, 4, 0);
  17706. builder.Write(job);
  17707. }
  17708. }
  17709. //删除多余行
  17710. while (tableOne.Rows.Count > DcList.Count + 1)
  17711. {
  17712. tableOne.Rows.RemoveAt(DcList.Count + 1);
  17713. }
  17714. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  17715. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  17716. doc.Save(fileDir);
  17717. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  17718. return Ok(JsonView(true, "操作成功!", Url));
  17719. }
  17720. private class TranslateInfo
  17721. {
  17722. public int Index { get; set; }
  17723. public string CompanyName { get; set; }
  17724. public string Job { get; set; }
  17725. }
  17726. #endregion
  17727. #region 团组倒推表
  17728. /// <summary>
  17729. /// 倒推表基础数据
  17730. /// Init
  17731. /// </summary>
  17732. /// <returns></returns>
  17733. [HttpPost]
  17734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17735. public async Task<IActionResult> PostInvertedListInit()
  17736. {
  17737. var viewData = await _invertedListRep._Init();
  17738. if (viewData.Code != 0)
  17739. {
  17740. return Ok(JsonView(false, viewData.Msg));
  17741. }
  17742. return Ok(JsonView(viewData.Data));
  17743. }
  17744. /// <summary>
  17745. /// 倒推表
  17746. /// Info
  17747. /// </summary>
  17748. /// <param name="dto"></param>
  17749. /// <returns></returns>
  17750. [HttpPost]
  17751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17752. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  17753. {
  17754. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  17755. if (viewData.Code != 0)
  17756. {
  17757. return Ok(JsonView(false, viewData.Msg));
  17758. }
  17759. return Ok(JsonView(viewData.Data));
  17760. }
  17761. /// <summary>
  17762. /// 倒推表
  17763. /// Create
  17764. /// </summary>
  17765. /// <param name="dto"></param>
  17766. /// <returns></returns>
  17767. [HttpPost]
  17768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17769. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  17770. {
  17771. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  17772. if (viewData.Code != 0)
  17773. {
  17774. return Ok(JsonView(false, viewData.Msg));
  17775. }
  17776. return Ok(JsonView(viewData.Data));
  17777. }
  17778. /// <summary>
  17779. /// 倒推表
  17780. /// Update
  17781. /// </summary>
  17782. /// <param name="dto"></param>
  17783. /// <returns></returns>
  17784. [HttpPost]
  17785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17786. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  17787. {
  17788. var viewData = await _invertedListRep._Update(dto);
  17789. if (viewData.Code != 0)
  17790. {
  17791. return Ok(JsonView(false, viewData.Msg));
  17792. }
  17793. return Ok(JsonView(viewData.Data));
  17794. }
  17795. /// <summary>
  17796. /// 倒推表
  17797. /// File Download
  17798. /// </summary>
  17799. /// <param name="dto"></param>
  17800. /// <returns></returns>
  17801. [HttpPost]
  17802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17803. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  17804. {
  17805. var info2 = await _invertedListRep._Info(1, dto.DiId);
  17806. if (info2.Code != 0)
  17807. {
  17808. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  17809. }
  17810. var info1 = info2.Data as InvertedListInfoView;
  17811. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  17812. string teamName = "";
  17813. if (info != null) teamName = info.TeamName;
  17814. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  17815. var doc = new Document();
  17816. var builder = new DocumentBuilder(doc);
  17817. #region old insert
  17818. ////载入模板
  17819. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  17820. //Document doc = new Document(tempPath);
  17821. //DocumentBuilder builder = new DocumentBuilder(doc);
  17822. //利用键值对存放数据
  17823. //Dictionary<string, string> dic = new Dictionary<string, string>();
  17824. //dic.Add("TeamName", teamName);
  17825. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  17826. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  17827. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  17828. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  17829. //dic.Add("SQRemark", info1.ApprovalRemark);
  17830. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  17831. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  17832. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  17833. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  17834. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  17835. //dic.Add("QZRemark", info1.VisaInformationRemark);
  17836. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  17837. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  17838. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  17839. //dic.Add("CQRemark", info1.IssueVisaRemark);
  17840. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  17841. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  17842. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  17843. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  17844. //#region 填充word模板书签内容
  17845. //foreach (var key in dic.Keys)
  17846. //{
  17847. // builder.MoveToBookmark(key);
  17848. // builder.Write(dic[key]);
  17849. //}
  17850. //#endregion
  17851. #endregion
  17852. #region New Insert
  17853. string titleFont = $"仿宋",
  17854. contentFont = $"仿宋";
  17855. var fontColor = Color.FromArgb(64, 64, 64);
  17856. //设置标题 团组名称
  17857. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17858. builder.Font.Name = titleFont;
  17859. builder.Font.Color = fontColor;
  17860. builder.Font.Size = 12;
  17861. builder.Font.Bold = true;
  17862. builder.Writeln(teamName);
  17863. //设置副标题 团组出访时间
  17864. builder.Font.Size = 12;
  17865. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  17866. builder.Writeln();
  17867. var backgroundColor = Color.FromArgb(199, 199, 199);
  17868. var table = builder.StartTable();
  17869. builder.InsertCell();
  17870. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  17871. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  17872. builder.CellFormat.Borders.LineWidth = 1;
  17873. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  17874. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  17875. builder.RowFormat.Height = 40;
  17876. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17877. builder.Font.Name = contentFont;
  17878. builder.Font.Size = 12;
  17879. builder.Font.Bold = true;
  17880. builder.Font.Color = fontColor;
  17881. builder.Write("时间");
  17882. builder.InsertCell();
  17883. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  17884. builder.Write("流程");
  17885. builder.InsertCell();
  17886. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  17887. builder.Write("说明");
  17888. builder.EndRow();
  17889. //报批资料准备
  17890. if (info1.IsSelectedAirportd)
  17891. {
  17892. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  17893. }
  17894. //报批/提供送签资料
  17895. if (info1.IsSelectedApprovalData)
  17896. {
  17897. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  17898. }
  17899. //出批件护照办理
  17900. if (info1.IsSelectedIssueApproval)
  17901. {
  17902. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  17903. }
  17904. //签证资料准备
  17905. if (info1.IsSelectedVisaInfo)
  17906. {
  17907. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  17908. }
  17909. //送签
  17910. if (info1.IsSelectedSendVisa)
  17911. {
  17912. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  17913. }
  17914. //出签
  17915. if (info1.IsSelectedIssueVisa)
  17916. {
  17917. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  17918. }
  17919. //机票
  17920. if (info1.IsSelectedAirTicket)
  17921. {
  17922. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  17923. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  17924. }
  17925. //酒店
  17926. if (info1.IsSelectedHotel)
  17927. {
  17928. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  17929. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  17930. }
  17931. //开行前会
  17932. if (info1.IsSelectedPreTripMeeting)
  17933. {
  17934. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  17935. }
  17936. //送机
  17937. if (info1.IsSelectedAirportdDropOff)
  17938. {
  17939. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  17940. }
  17941. builder.EndTable();
  17942. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  17943. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  17944. for (int i = 0; i < table.Rows.Count; i++)
  17945. {
  17946. var row = table.Rows[i];
  17947. //设置宽度
  17948. row.Cells[0].CellFormat.Width = 20.00;
  17949. row.Cells[1].CellFormat.Width = 30.00;
  17950. row.Cells[2].CellFormat.Width = 50.00;
  17951. if (i != 0)
  17952. {
  17953. //边框设置
  17954. InvertedListFileDownloadSetBorders(row.Cells, 0);
  17955. InvertedListFileDownloadSetBorders(row.Cells, 1);
  17956. InvertedListFileDownloadSetBorders(row.Cells, 2);
  17957. }
  17958. }
  17959. #region 页脚插入图片
  17960. // 创建页脚
  17961. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  17962. doc.FirstSection.HeadersFooters.Add(footer);
  17963. Paragraph para = new Paragraph(doc);
  17964. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  17965. footer.AppendChild(para);
  17966. builder.MoveTo(para);
  17967. string imagePath = "./Images/FMGJ_Log.png";
  17968. builder.InsertImage(imagePath);
  17969. #endregion
  17970. #endregion
  17971. var fileDir = AppSettingsHelper.Get("WordBasePath");
  17972. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  17973. string filePath = fileDir + $@"InvertedList/{fileName}";
  17974. doc.Save(filePath);
  17975. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  17976. return Ok(JsonView(true, "操作成功!", Url));
  17977. }
  17978. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  17979. {
  17980. var fontColor = Color.FromArgb(64, 64, 64);
  17981. builder.InsertCell();
  17982. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  17983. builder.RowFormat.Height = 40;
  17984. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17985. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17986. builder.Font.Name = fontName;
  17987. builder.Font.Size = 8;
  17988. builder.Font.Bold = true;
  17989. builder.Font.Color = fontColor;
  17990. builder.Write(dateTime);
  17991. builder.InsertCell();
  17992. builder.Font.Size = 9;
  17993. builder.Font.Bold = true;
  17994. builder.Font.Color = fontColor;
  17995. builder.Write(content);
  17996. builder.InsertCell();
  17997. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17998. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17999. builder.Font.Size = 9;
  18000. builder.Font.Bold = false;
  18001. builder.Font.Color = fontColor;
  18002. builder.Write(reamrk);
  18003. builder.EndRow();
  18004. }
  18005. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  18006. {
  18007. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  18008. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  18009. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  18010. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  18011. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  18012. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  18013. }
  18014. #endregion
  18015. #region 会务倒推表
  18016. /// <summary>
  18017. /// 会务倒推表
  18018. /// Init
  18019. /// </summary>
  18020. /// <returns></returns>
  18021. [HttpPost]
  18022. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18023. public async Task<IActionResult> InforRetrogressTableInit()
  18024. {
  18025. var groupData = await _groupRepository.PostShareGroupInfos(1);
  18026. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  18027. return Ok(JsonView(false, groupData.Msg));
  18028. }
  18029. /// <summary>
  18030. /// 会务倒推表
  18031. /// ExcelDownload
  18032. /// </summary>
  18033. /// <param name="dto"></param>
  18034. /// <returns></returns>
  18035. [HttpPost]
  18036. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  18037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18038. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  18039. {
  18040. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  18041. var validatorRes = await validator.ValidateAsync(dto);
  18042. if (!validatorRes.IsValid)
  18043. {
  18044. StringBuilder sb = new StringBuilder();
  18045. foreach (var item in validatorRes.Errors)
  18046. {
  18047. sb.AppendLine(item.ErrorMessage);
  18048. }
  18049. return Ok(JsonView(false, sb.ToString()));
  18050. }
  18051. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  18052. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  18053. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  18054. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  18055. #region Excel
  18056. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  18057. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  18058. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  18059. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  18060. var fileNamePrefix = string.Empty;
  18061. if (days >= 30)
  18062. {
  18063. tempPath += $"会务工作倒推进度表(30天).xlsx";
  18064. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  18065. }
  18066. else if (days < 30 && days > 7)
  18067. {
  18068. tempPath += $"会务工作倒推进度表(15天).xlsx";
  18069. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  18070. }
  18071. else if (days <= 7)
  18072. {
  18073. tempPath += $"会务工作倒推进度表(7天).xlsx";
  18074. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  18075. }
  18076. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  18077. fileName = CommonFun.ValidFileName(fileName);
  18078. //载入模板
  18079. WorkbookDesigner designer = new WorkbookDesigner();
  18080. designer.Workbook = new Workbook(tempPath);
  18081. designer.Process();
  18082. if (!Directory.Exists(savePath))
  18083. {
  18084. Directory.CreateDirectory(savePath);
  18085. }
  18086. string serverPath = $"{savePath}{fileName}";
  18087. designer.Workbook.Save(serverPath);
  18088. string rst = $"{servicePath}{ftpPath}{fileName}";
  18089. #endregion
  18090. return Ok(JsonView(new { url = rst }));
  18091. }
  18092. #endregion
  18093. #region 三公签证费用(签证费、代办费)
  18094. /// <summary>
  18095. /// 三公签证费用(签证费、代办费)
  18096. /// List
  18097. /// </summary>
  18098. /// <returns></returns>
  18099. [HttpPost]
  18100. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18101. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  18102. {
  18103. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  18104. if (_view.Code != 0)
  18105. {
  18106. return Ok(JsonView(false, _view.Msg));
  18107. }
  18108. return Ok(JsonView(true, "操作成功!", _view.Data));
  18109. }
  18110. /// <summary>
  18111. /// 三公签证费用(签证费、代办费)
  18112. /// Add Or Update
  18113. /// </summary>
  18114. /// <returns></returns>
  18115. [HttpPost]
  18116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18117. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  18118. {
  18119. var _view = await _visaFeeInfoRep._Update(_dto);
  18120. if (_view.Code != 0)
  18121. {
  18122. return Ok(JsonView(false, _view.Msg));
  18123. }
  18124. return Ok(JsonView(true, _view.Msg));
  18125. }
  18126. #endregion
  18127. #region 酒店询价
  18128. /// <summary>
  18129. /// 酒店询价
  18130. /// Init
  18131. /// </summary>
  18132. /// <returns></returns>
  18133. [HttpPost]
  18134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18135. public async Task<IActionResult> PostHotelInquiryInit()
  18136. {
  18137. var res = await _hotelInquiryRep._Init();
  18138. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18139. return Ok(JsonView(true, res.Msg, res.Data));
  18140. }
  18141. /// <summary>
  18142. /// 酒店询价
  18143. /// page Item
  18144. /// </summary>
  18145. /// <param name="_dto"></param>
  18146. /// <returns></returns>
  18147. [HttpPost]
  18148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18149. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  18150. {
  18151. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  18152. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18153. var view = res.Data as PageDataViewBase;
  18154. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  18155. }
  18156. /// <summary>
  18157. /// 酒店询价
  18158. /// info
  18159. /// </summary>
  18160. /// <param name="_dto"></param>
  18161. /// <returns></returns>
  18162. [HttpPost]
  18163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18164. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  18165. {
  18166. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  18167. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18168. return Ok(JsonView(true, res.Msg, res.Data));
  18169. }
  18170. /// <summary>
  18171. /// 酒店询价
  18172. /// Add Or Edit
  18173. /// </summary>
  18174. /// <param name="_dto"></param>
  18175. /// <returns></returns>
  18176. [HttpPost]
  18177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18178. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  18179. {
  18180. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  18181. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18182. return Ok(JsonView(true, res.Msg, res.Data));
  18183. }
  18184. /// <summary>
  18185. /// 酒店询价
  18186. /// Del
  18187. /// </summary>
  18188. /// <param name="_dto"></param>
  18189. /// <returns></returns>
  18190. [HttpPost]
  18191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18192. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  18193. {
  18194. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  18195. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  18196. return Ok(JsonView(true, res.Msg, res.Data));
  18197. }
  18198. #endregion
  18199. #region 下载匹配op行程单
  18200. /// <summary>
  18201. /// 匹配op行程单
  18202. /// Init
  18203. /// </summary>
  18204. /// <param name="dto">团组列表请求dto</param>
  18205. /// <returns></returns>
  18206. [HttpPost]
  18207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18208. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  18209. {
  18210. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  18211. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18212. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  18213. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  18214. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  18215. .Where(it => it.IsDel == 0)
  18216. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  18217. .OrderByDescending(it => it.VisitStartDate)
  18218. .ToList();
  18219. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  18220. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  18221. var diids = groupInfos.Select(it => it.Id).ToList();
  18222. List<string> countrys = new List<string>();
  18223. foreach (var item in country)
  18224. {
  18225. var data = _groupRepository.FormartTeamName(item);
  18226. var dataArray = _groupRepository.GroupSplitCountry(data);
  18227. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  18228. }
  18229. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  18230. List<string> areaArray = new List<string>(); //GetGroupCityLine
  18231. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  18232. foreach (var item in areaItem)
  18233. {
  18234. string areaStr = item.Value;
  18235. if (!string.IsNullOrEmpty(areaStr))
  18236. {
  18237. string[] str1 = areaStr.Split("-");
  18238. if (str1.Length > 0)
  18239. {
  18240. areaArray.AddRange(str1);
  18241. }
  18242. }
  18243. }
  18244. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  18245. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  18246. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  18247. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  18248. .ToList();
  18249. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  18250. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  18251. .Where(it => countriesIds.Contains(it.Id))
  18252. .Select(it => new { it.Id, Name = it.Name_CN })
  18253. .ToList();
  18254. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  18255. .Select(it => it.TeamName).ToList();
  18256. stopwatch.Stop();
  18257. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  18258. }
  18259. ///// <summary>
  18260. ///// 匹配op行程单
  18261. ///// Init 查询区域数据
  18262. ///// </summary>
  18263. ///// <param name="dto">团组列表请求dto</param>
  18264. ///// <returns></returns>
  18265. //[HttpPost]
  18266. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18267. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  18268. //{
  18269. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  18270. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  18271. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  18272. // if (string.IsNullOrEmpty(countriesDataStr))
  18273. // {
  18274. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  18275. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  18276. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  18277. // }
  18278. // else
  18279. // {
  18280. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  18281. // }
  18282. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  18283. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  18284. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  18285. // List<dynamic> childList = new List<dynamic>();
  18286. // int parentId = dto.CountriesId;
  18287. // if (provinceData.Count > 1)
  18288. // {
  18289. // foreach (var item1 in provinceData)
  18290. // {
  18291. // List<dynamic> childList1 = new List<dynamic>();
  18292. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  18293. // foreach (var item2 in citiesData1)
  18294. // {
  18295. // List<dynamic> childList2 = new List<dynamic>();
  18296. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  18297. // foreach (var item3 in countiesData1)
  18298. // {
  18299. // childList2.Add(new
  18300. // {
  18301. // id = item3.Id,
  18302. // parentId = item2.Id,
  18303. // level = "district",
  18304. // name = item3.Name_CN,
  18305. // });
  18306. // }
  18307. // childList1.Add(new
  18308. // {
  18309. // id = item2.Id,
  18310. // parentId = item1.Id,
  18311. // level = "city",
  18312. // name = item2.Name_CN,
  18313. // childList = childList2
  18314. // });
  18315. // }
  18316. // childList.Add(new
  18317. // {
  18318. // id = item1.Id,
  18319. // parentId = parentId,
  18320. // level = "province",
  18321. // name = item1.Name_CN,
  18322. // childList = childList1
  18323. // });
  18324. // }
  18325. // //城市
  18326. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  18327. // foreach (var item2 in citiesData2)
  18328. // {
  18329. // List<dynamic> childList22 = new List<dynamic>();
  18330. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  18331. // foreach (var item3 in countiesData1)
  18332. // {
  18333. // childList22.Add(new
  18334. // {
  18335. // id = item3.Id,
  18336. // parentId = item2.Id,
  18337. // level = "district",
  18338. // name = item3.Name_CN,
  18339. // });
  18340. // }
  18341. // childList.Add(new
  18342. // {
  18343. // id = item2.Id,
  18344. // parentId = parentId,
  18345. // level = "city",
  18346. // name = item2.Name_CN,
  18347. // childList = childList22
  18348. // });
  18349. // }
  18350. // }
  18351. // else
  18352. // {
  18353. // foreach (var item2 in citiesData)
  18354. // {
  18355. // string cname = item2.Name_CN;
  18356. // List<dynamic> childList1 = new List<dynamic>();
  18357. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  18358. // foreach (var item3 in countiesData1)
  18359. // {
  18360. // childList1.Add(new
  18361. // {
  18362. // Id = item3.Id,
  18363. // parentId = item2.Id,
  18364. // level = "district",
  18365. // name = item3.Name_CN
  18366. // });
  18367. // }
  18368. // childList.Add(new
  18369. // {
  18370. // id = item2.Id,
  18371. // parentId = parentId,
  18372. // level = "city",
  18373. // name = item2.Name_CN,
  18374. // childList = childList1
  18375. // });
  18376. // }
  18377. // }
  18378. // stopwatch.Stop();
  18379. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  18380. //}
  18381. /// <summary>
  18382. /// 匹配op行程单
  18383. /// 接团信息列表 Page
  18384. /// </summary>
  18385. /// <param name="dto">团组列表请求dto</param>
  18386. /// <returns></returns>
  18387. [HttpPost]
  18388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18389. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  18390. {
  18391. var swatch = new Stopwatch();
  18392. swatch.Start();
  18393. #region 参数验证
  18394. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18395. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  18396. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18397. #region 页面操作权限验证
  18398. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  18399. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  18400. #endregion
  18401. #endregion
  18402. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  18403. {
  18404. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  18405. //string sqlWhere = "";
  18406. if (!string.IsNullOrEmpty(dto.Country))
  18407. {
  18408. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  18409. }
  18410. if (!string.IsNullOrEmpty(dto.Area))
  18411. {
  18412. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  18413. }
  18414. if (!string.IsNullOrEmpty(dto.TeamName))
  18415. {
  18416. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  18417. }
  18418. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  18419. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  18420. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  18421. swatch.Stop();
  18422. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  18423. }
  18424. else
  18425. {
  18426. return Ok(JsonView(false, "查询失败"));
  18427. }
  18428. }
  18429. /// <summary>
  18430. /// 匹配op行程单
  18431. /// 行程单下载
  18432. /// </summary>
  18433. /// <param name="dto">团组列表请求dto</param>
  18434. /// <returns></returns>
  18435. [HttpPost]
  18436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18437. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  18438. {
  18439. #region 参数验证
  18440. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18441. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  18442. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18443. #region 页面操作权限验证
  18444. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  18445. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  18446. #endregion
  18447. #endregion
  18448. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  18449. {
  18450. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  18451. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  18452. }
  18453. else
  18454. {
  18455. return Ok(JsonView(false, "下载失败!"));
  18456. }
  18457. }
  18458. #endregion
  18459. #region 国家信息 数据 注释
  18460. //[HttpPost]
  18461. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  18462. //{
  18463. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  18464. // foreach (var item in dto)
  18465. // {
  18466. // infos.Add(new Grp_GroupsTaskAssignment()
  18467. // {
  18468. // DIId = item,
  18469. // CTId = 82,
  18470. // UId = 248,
  18471. // IsEnable = 1,
  18472. // CreateUserId = 233,
  18473. // CreateTime = DateTime.Now,
  18474. // IsDel = 0
  18475. // });
  18476. // infos.Add(new Grp_GroupsTaskAssignment()
  18477. // {
  18478. // DIId = item,
  18479. // CTId = 82,
  18480. // UId = 286,
  18481. // IsEnable = 1,
  18482. // CreateUserId = 233,
  18483. // CreateTime = DateTime.Now,
  18484. // IsDel = 0
  18485. // });
  18486. // }
  18487. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  18488. // return Ok("操作成功");
  18489. //}
  18490. //public class paramJsonDto
  18491. //{
  18492. // public List<CountriesInfo> str { get; set; }
  18493. //}
  18494. //[HttpPost]
  18495. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  18496. //{
  18497. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  18498. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  18499. // List<Sys_Cities> cities = new List<Sys_Cities>();
  18500. // List<Sys_Cities> districts = new List<Sys_Cities>();
  18501. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  18502. // _sqlSugar.BeginTran();
  18503. // int countitiesIndex = 0;
  18504. // foreach (var item in dto.str)
  18505. // {
  18506. // dynamic data = item.c;
  18507. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  18508. // if (data != null)
  18509. // {
  18510. // countitiesIndex++;
  18511. // foreach (var item1 in data)
  18512. // {
  18513. // string cnname = item1.cn;
  18514. // string enname = item1.en;
  18515. // Sys_Cities provinceInfo = new Sys_Cities()
  18516. // {
  18517. // CountriesId = countriesId,
  18518. // Name_CN = cnname,
  18519. // Name_EN = enname,
  18520. // ParentId = 0,
  18521. // IsCapital = 1,
  18522. // CreateUserId = 208,
  18523. // CreateTime = DateTime.Now,
  18524. // IsDel = 0
  18525. // };
  18526. // if (item1.lv == "province") //省份
  18527. // {
  18528. // provinceInfo.Level = 1;
  18529. // int provinceId = 0;
  18530. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  18531. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  18532. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  18533. // var data1 = item1.c;
  18534. // foreach (var item2 in data1)
  18535. // {
  18536. // if (item2.lv == "city")
  18537. // {
  18538. // string citycnname = item2.cn;
  18539. // string cityenname = item2.en;
  18540. // Sys_Cities cityInfo = new Sys_Cities()
  18541. // {
  18542. // CountriesId = countriesId,
  18543. // ParentId = provinceId,
  18544. // Level = 2,
  18545. // Name_CN = citycnname,
  18546. // Name_EN = cityenname,
  18547. // IsCapital = 1,
  18548. // CreateUserId = 208,
  18549. // CreateTime = DateTime.Now,
  18550. // IsDel = 0
  18551. // };
  18552. // if (item2.c != null)
  18553. // {
  18554. // int cityId = 0;
  18555. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  18556. // if (citiesInfo != null) cityId = citiesInfo.Id;
  18557. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  18558. // foreach (var item3 in item2.c)
  18559. // {
  18560. // if (item3.lv == "district")
  18561. // {
  18562. // var districtInfo = new Sys_Cities()
  18563. // {
  18564. // CountriesId = countriesId,
  18565. // Name_CN = item3.cn,
  18566. // Name_EN = item3.en,
  18567. // Level = 3,
  18568. // ParentId = cityId,
  18569. // IsCapital = 1,
  18570. // CreateUserId = 208,
  18571. // CreateTime = DateTime.Now,
  18572. // IsDel = 0
  18573. // };
  18574. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  18575. // //{
  18576. // districts.Add(districtInfo);
  18577. // //}
  18578. // }
  18579. // }
  18580. // }
  18581. // else
  18582. // {
  18583. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  18584. // //{
  18585. // cities.Add(cityInfo);
  18586. // //}
  18587. // }
  18588. // }
  18589. // }
  18590. // }
  18591. // else if (item1.lv == "city")//城市
  18592. // {
  18593. // provinceInfo.Level = 2;
  18594. // if (item1.c != null)
  18595. // {
  18596. // int cityId = 0;
  18597. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  18598. // if (citiesInfo != null) cityId = citiesInfo.Id;
  18599. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  18600. // foreach (var item3 in item1.c)
  18601. // {
  18602. // if (item3.lv == "district")
  18603. // {
  18604. // var districtInfo = new Sys_Cities()
  18605. // {
  18606. // CountriesId = countriesId,
  18607. // Name_CN = item3.cn,
  18608. // Name_EN = item3.en,
  18609. // Level = 3,
  18610. // ParentId = cityId,
  18611. // IsCapital = 1,
  18612. // CreateUserId = 208,
  18613. // CreateTime = DateTime.Now,
  18614. // IsDel = 0
  18615. // };
  18616. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  18617. // //{
  18618. // districts.Add(districtInfo);
  18619. // //}
  18620. // }
  18621. // }
  18622. // }
  18623. // else
  18624. // {
  18625. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  18626. // //{
  18627. // cities.Add(provinceInfo);
  18628. // //}
  18629. // }
  18630. // }
  18631. // }
  18632. // }
  18633. // }
  18634. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  18635. // cities = cities.Distinct().ToList();
  18636. // districts = districts.Distinct().ToList();
  18637. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  18638. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  18639. // cities.AddRange(districts);
  18640. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  18641. // //_sqlSugar.RollbackTran();
  18642. // _sqlSugar.CommitTran();
  18643. // return Ok(JsonView(false, "操作成功!"));
  18644. //}
  18645. //[HttpPost]
  18646. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  18647. //{
  18648. // List<CountitiesInfo> infos = dto.MyProperty;
  18649. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  18650. // _sqlSugar.BeginTran();
  18651. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  18652. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  18653. // foreach (var item in infos)
  18654. // {
  18655. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  18656. // if (countryInfo != null)
  18657. // {
  18658. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  18659. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  18660. // if (cityInfo1 != null)
  18661. // {
  18662. // cityInfo1.IsCapital = 0;
  18663. // cityInfos.Add(cityInfo1);
  18664. // }
  18665. // }
  18666. // }
  18667. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  18668. // .UpdateColumns(it => it.IsCapital)
  18669. // .WhereColumns(it => it.Id)
  18670. // .ExecuteCommand();
  18671. // //_sqlSugar.RollbackTran();
  18672. // _sqlSugar.CommitTran();
  18673. // return Ok(JsonView(false, "操作成功!"));
  18674. //}
  18675. //public class CounrtiesDto
  18676. //{
  18677. // public List<CountitiesInfo> MyProperty { get; set; }
  18678. //}
  18679. //public class CountitiesInfo
  18680. //{
  18681. // /// <summary>
  18682. // /// 圣约翰
  18683. // /// </summary>
  18684. // public string capital_name_chinese { get; set; }
  18685. // /// <summary>
  18686. // ///
  18687. // /// </summary>
  18688. // public string capital_name { get; set; }
  18689. // /// <summary>
  18690. // ///
  18691. // /// </summary>
  18692. // public string country_type { get; set; }
  18693. // /// <summary>
  18694. // /// 安提瓜和巴布达
  18695. // /// </summary>
  18696. // public string country_name_chinese { get; set; }
  18697. // /// <summary>
  18698. // /// 安提瓜和巴布达
  18699. // /// </summary>
  18700. // public string country_name_chinese_short { get; set; }
  18701. // /// <summary>
  18702. // /// 安提瓜和巴布达
  18703. // /// </summary>
  18704. // public string country_name_chinese_UN { get; set; }
  18705. // /// <summary>
  18706. // ///
  18707. // /// </summary>
  18708. // public string country_name_english_abbreviation { get; set; }
  18709. // /// <summary>
  18710. // ///
  18711. // /// </summary>
  18712. // public string country_name_english_formal { get; set; }
  18713. // /// <summary>
  18714. // ///
  18715. // /// </summary>
  18716. // public string country_name_english_UN { get; set; }
  18717. // /// <summary>
  18718. // ///
  18719. // /// </summary>
  18720. // public string continent_name { get; set; }
  18721. // /// <summary>
  18722. // ///
  18723. // /// </summary>
  18724. // public string subregion_name { get; set; }
  18725. // /// <summary>
  18726. // ///
  18727. // /// </summary>
  18728. // public string country_code2 { get; set; }
  18729. // /// <summary>
  18730. // ///
  18731. // /// </summary>
  18732. // public string country_code3 { get; set; }
  18733. // /// <summary>
  18734. // ///
  18735. // /// </summary>
  18736. // public string phone_code { get; set; }
  18737. //}
  18738. //public class CountriesInfo : BasicInfo
  18739. //{
  18740. // public List<CitiesInfo> c { get; set; }
  18741. //}
  18742. //public class CitiesInfo : BasicInfo
  18743. //{
  18744. // public List<AreaInfo> c { get; set; }
  18745. //}
  18746. //public class AreaInfo : BasicInfo
  18747. //{
  18748. // public List<AreaInfo> c { get; set; }
  18749. //}
  18750. //public class BasicInfo
  18751. //{
  18752. // public string code { get; set; }
  18753. // public string cn { get; set; }
  18754. // public string lv { get; set; }
  18755. // public string en { get; set; }
  18756. //}
  18757. #endregion
  18758. #region 查看邀请方
  18759. /// <summary>
  18760. /// 查看邀请方
  18761. /// 邀请方信息 Init
  18762. /// </summary>
  18763. /// <param name="dto"></param>
  18764. /// <returns></returns>
  18765. [HttpPost]
  18766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18767. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  18768. {
  18769. string sqlWhere = string.Empty;
  18770. if (!string.IsNullOrEmpty(dto.Search))
  18771. {
  18772. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  18773. }
  18774. string sql = string.Format($@"Select
  18775. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  18776. Id,
  18777. UnitName
  18778. From Res_InvitationOfficialActivityData
  18779. Where IsDel = 0
  18780. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  18781. RefAsync<int> total = 0;
  18782. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18783. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  18784. }
  18785. /// <summary>
  18786. /// 查看邀请方
  18787. /// 国家信息 Init
  18788. /// </summary>
  18789. /// <param name="dto"></param>
  18790. /// <returns></returns>
  18791. [HttpPost]
  18792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18793. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  18794. {
  18795. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  18796. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  18797. var diids = groupInfos.Select(it => it.Id).ToList();
  18798. List<string> countrys = new List<string>();
  18799. foreach (var item in country)
  18800. {
  18801. var data = _groupRepository.FormartTeamName(item);
  18802. var dataArray = _groupRepository.GroupSplitCountry(data);
  18803. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  18804. }
  18805. countrys = countrys.Distinct().ToList();
  18806. for (int i = 0; i < countrys.Count; i++)
  18807. {
  18808. string item = countrys[i];
  18809. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  18810. {
  18811. countrys.Remove(item);
  18812. i--;
  18813. }
  18814. }
  18815. RefAsync<int> total = 0;
  18816. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  18817. .Where(it => countrys.Contains(it.Name_CN))
  18818. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18819. .Select(it => new { id = it.Id, name = it.Name_CN })
  18820. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18821. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18822. }
  18823. /// <summary>
  18824. /// 查看邀请方
  18825. /// 城市信息 Init
  18826. /// </summary>
  18827. /// <param name="dto"></param>
  18828. /// <returns></returns>
  18829. [HttpPost]
  18830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18831. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  18832. {
  18833. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  18834. RefAsync<int> total = 0;
  18835. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  18836. .Where(it => it.CountriesId == dto.CountiesId)
  18837. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18838. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  18839. .Select(it => new { id = it.Id, name = it.Name_CN })
  18840. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18841. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18842. }
  18843. /// <summary>
  18844. /// 查看邀请方
  18845. /// 团组名称 Init
  18846. /// </summary>
  18847. /// <param name="dto"></param>
  18848. /// <returns></returns>
  18849. [HttpPost]
  18850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18851. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  18852. {
  18853. var watch = new Stopwatch();
  18854. watch.Start();
  18855. RefAsync<int> total = 0;
  18856. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  18857. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  18858. .Where((oa, di) => oa.IsDel == 0)
  18859. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  18860. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  18861. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  18862. .Distinct()
  18863. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18864. watch.Stop();
  18865. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  18866. }
  18867. /// <summary>
  18868. /// 查看邀请方
  18869. /// 团组 & 邀请方信息
  18870. /// </summary>
  18871. /// <param name="dto"></param>
  18872. /// <returns></returns>
  18873. [HttpPost]
  18874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18875. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  18876. {
  18877. var watch = new Stopwatch();
  18878. watch.Start();
  18879. RefAsync<int> total = 0;
  18880. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  18881. .AS("Grp_DelegationInfo")
  18882. .Includes(x => x.InvitingInfos)
  18883. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  18884. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  18885. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  18886. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  18887. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  18888. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  18889. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18890. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  18891. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  18892. infos.ForEach(x =>
  18893. {
  18894. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  18895. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  18896. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  18897. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  18898. });
  18899. watch.Stop();
  18900. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  18901. }
  18902. #endregion
  18903. #region 报批行程
  18904. /// <summary>
  18905. /// 报批行程初始化
  18906. /// </summary>
  18907. /// <param name="dto"></param>
  18908. /// <returns></returns>
  18909. [HttpPost]
  18910. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  18911. {
  18912. const int chiNumber = 5;
  18913. var jw = JsonView(false);
  18914. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  18915. var group = groupList.First();
  18916. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  18917. group = groupList.First(x => x.Id == diid);
  18918. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18919. .Where(x => x.DiId == diid && x.IsDel == 0)
  18920. .ToArray();
  18921. var count = 1;
  18922. foreach (var item in blackCodeList)
  18923. {
  18924. if (string.IsNullOrWhiteSpace(item.Title))
  18925. {
  18926. item.Title = "未设置名称数据" + count;
  18927. }
  18928. count++;
  18929. };
  18930. if (group == null)
  18931. {
  18932. jw.Msg = "暂无团组!";
  18933. return Ok(jw);
  18934. }
  18935. var data = new
  18936. {
  18937. groupList = groupList.Select(x => new
  18938. {
  18939. x.TeamName,
  18940. x.Id
  18941. }),
  18942. content = new ArrayList(),
  18943. groupInfo = new
  18944. {
  18945. group.VisitDays,
  18946. group.TourCode,
  18947. group.VisitPNumber,
  18948. group.TeamName,
  18949. group.Id,
  18950. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  18951. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  18952. },
  18953. blackCodeList = blackCodeList.Select(x => new
  18954. {
  18955. x.Title,
  18956. x.Id
  18957. }),
  18958. FileTempList = new ArrayList()
  18959. {
  18960. new { Index = 1,FileName = "旧模板" },
  18961. new { Index = 2,FileName = "省外办" },
  18962. new { Index = 3,FileName = "市外办" },
  18963. }
  18964. };
  18965. var resultArr = new ArrayList();
  18966. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  18967. #region 默认不生成行程
  18968. //if (content.Count == 0)
  18969. //{
  18970. // var stay = "-";
  18971. // var cityPath = "-";
  18972. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18973. // .Where(x => x.DiId == diid && x.IsDel == 0)
  18974. // .ToList();
  18975. // //添加城市路径以及住宿地
  18976. // //黑屏代码数据
  18977. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  18978. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18979. // {
  18980. // jw = JsonView(true, "黑屏代码有误!", data);
  18981. // return Ok(jw);
  18982. // }
  18983. // data = data with
  18984. // {
  18985. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  18986. // {
  18987. // x.Title,
  18988. // x.Id,
  18989. // }).ToArray())
  18990. // };
  18991. // foreach (DataRow row in dtBlack.Rows)
  18992. // {
  18993. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18994. // {
  18995. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  18996. // return Ok(jw);
  18997. // }
  18998. // }
  18999. // //黑屏代码获取时间区间
  19000. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  19001. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  19002. // _sqlSugar.BeginTran();
  19003. // for (int i = 0; i < timeArr.Count; i++)
  19004. // {
  19005. // stay = "-";
  19006. // cityPath = "-";
  19007. // DateTime NewData = DateTime.Parse(timeArr[i]);
  19008. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  19009. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  19010. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  19011. // if (tbSelect.Length > 0)
  19012. // {
  19013. // List<string> threeCodeStr = new List<string>();
  19014. // foreach (var item in tbSelect)
  19015. // {
  19016. // var threeCode = item["Three"].ToString() ?? "";
  19017. // if (threeCode.Length == 6)
  19018. // {
  19019. // var start = threeCode.Substring(0, 3);
  19020. // var end = threeCode.Substring(3, 3);
  19021. // if (threeCodeStr.Count == 0)
  19022. // {
  19023. // threeCodeStr.Add(start);
  19024. // threeCodeStr.Add(end);
  19025. // }
  19026. // else
  19027. // {
  19028. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  19029. // {
  19030. // threeCodeStr.Add(end);
  19031. // }
  19032. // else
  19033. // {
  19034. // threeCodeStr.Add(start);
  19035. // threeCodeStr.Add(end);
  19036. // }
  19037. // }
  19038. // }
  19039. // }
  19040. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  19041. // var last = threeCodeStr.Last();
  19042. // foreach (var item in threeCodeStr)
  19043. // {
  19044. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  19045. // if (item.Equals(last))
  19046. // {
  19047. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  19048. // }
  19049. // }
  19050. // cityPath = cityPath.Trim('-');
  19051. // }
  19052. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  19053. // appro.Diid = diid ?? -1;
  19054. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  19055. // appro.Id = thisId;
  19056. // appro.CreateUserId = dto.UserId;
  19057. // appro.CreateTime = DateTime.Now;
  19058. // content.Add(appro);
  19059. // }
  19060. // _sqlSugar.CommitTran();
  19061. //}
  19062. #endregion
  19063. foreach (var x in content)
  19064. {
  19065. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  19066. if (chiList.Count < chiNumber)
  19067. {
  19068. for (int i = chiList.Count; i < chiNumber; i++)
  19069. {
  19070. chiList.Add(new Grp_ApprovalTravelDetails());
  19071. }
  19072. }
  19073. resultArr.Add(new
  19074. {
  19075. x.Id,
  19076. x.Date,
  19077. x.Diid,
  19078. chiList = chiList.Select(x1 => new
  19079. {
  19080. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  19081. x1.Details,
  19082. x1.ParentId,
  19083. x1.Id
  19084. })
  19085. });
  19086. }
  19087. data = data with
  19088. {
  19089. content = resultArr,
  19090. };
  19091. jw = JsonView(true, "获取成功!", data);
  19092. return Ok(jw);
  19093. }
  19094. /// <summary>
  19095. /// 报批行程删除
  19096. /// </summary>
  19097. /// <param name="dto"></param>
  19098. /// <returns></returns>
  19099. [HttpPost]
  19100. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  19101. {
  19102. var jw = JsonView(false);
  19103. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  19104. if (group == null)
  19105. {
  19106. jw.Msg = "团组参数有误!";
  19107. return Ok(jw);
  19108. }
  19109. try
  19110. {
  19111. _sqlSugar.BeginTran();
  19112. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  19113. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  19114. {
  19115. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  19116. DeleteUserId = dto.uesrId,
  19117. IsDel = 1
  19118. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  19119. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  19120. {
  19121. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  19122. DeleteUserId = dto.uesrId,
  19123. IsDel = 1
  19124. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  19125. _sqlSugar.CommitTran();
  19126. jw = JsonView(true, "删除成功");
  19127. }
  19128. catch (Exception ex)
  19129. {
  19130. jw = JsonView(false, ex.Message);
  19131. }
  19132. return Ok(jw);
  19133. }
  19134. /// <summary>
  19135. /// 报批行程保存
  19136. /// </summary>
  19137. /// <param name="dto"></param>
  19138. /// <returns></returns>
  19139. [HttpPost]
  19140. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  19141. {
  19142. var jw = JsonView(false);
  19143. var Find = dto.Arr.Find(x => x.id == 0);
  19144. if (Find != null)
  19145. {
  19146. jw.Msg = "生成的ID为0!";
  19147. return Ok(jw);
  19148. }
  19149. foreach (var item in dto.Arr)
  19150. {
  19151. foreach (var chi in item.chiList)
  19152. {
  19153. if (chi.parentId == 0)
  19154. {
  19155. chi.parentId = item.id;
  19156. }
  19157. }
  19158. }
  19159. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  19160. _sqlSugar.BeginTran();
  19161. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  19162. {
  19163. var parentIds = dto.Arr.Select(x => x.id).ToList();
  19164. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  19165. {
  19166. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  19167. DeleteUserId = dto.UserId,
  19168. IsDel = 1
  19169. }).ExecuteCommand();
  19170. }
  19171. try
  19172. {
  19173. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  19174. {
  19175. CreateTime = DateTime.Now,
  19176. CreateUserId = dto.UserId,
  19177. Details = x.details,
  19178. ParentId = x.parentId,
  19179. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  19180. Remark = "",
  19181. IsDel = 0
  19182. }).ToList()).ExecuteCommand();
  19183. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  19184. {
  19185. Id = x.id,
  19186. Details = x.details,
  19187. ParentId = x.parentId,
  19188. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  19189. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  19190. {
  19191. Details = x.Details,
  19192. ParentId = x.ParentId,
  19193. Time = x.Time
  19194. }).ExecuteCommand();
  19195. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  19196. {
  19197. Id = x.id,
  19198. Date = x.date,
  19199. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  19200. {
  19201. Date = x.Date
  19202. }).ExecuteCommand();
  19203. _sqlSugar.CommitTran();
  19204. jw = JsonView(true, "保存成功!");
  19205. }
  19206. catch (Exception ex)
  19207. {
  19208. _sqlSugar.RollbackTran();
  19209. jw = JsonView(false, "保存失败!" + ex.Message);
  19210. }
  19211. return Ok(jw);
  19212. }
  19213. /// <summary>
  19214. /// 报批行程生成
  19215. /// </summary>
  19216. /// <param name="dto"></param>
  19217. /// <returns></returns>
  19218. [HttpPost]
  19219. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  19220. {
  19221. var jw = JsonView(false);
  19222. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  19223. if (group == null)
  19224. {
  19225. jw.Msg = "暂无该团组!";
  19226. return Ok(jw);
  19227. }
  19228. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  19229. //黑屏代码数据
  19230. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  19231. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  19232. {
  19233. jw.Msg = "黑屏代码有误!";
  19234. return Ok(jw);
  19235. }
  19236. foreach (DataRow row in dtBlack.Rows)
  19237. {
  19238. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  19239. {
  19240. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  19241. return Ok(jw);
  19242. }
  19243. }
  19244. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  19245. var resultArr = new ArrayList();
  19246. //if (officialActivitiesArr.Count == 0)
  19247. //{
  19248. // jw.Msg = "暂无公务出访信息!";
  19249. // return Ok(jw);
  19250. //}
  19251. try
  19252. {
  19253. _sqlSugar.BeginTran();
  19254. DeleteApprovalJourney(new
  19255. Domain.Dtos.Groups.DeleteApprovalJourney
  19256. {
  19257. Diid = dto.Diid,
  19258. uesrId = dto.Userid
  19259. });
  19260. var stay = "-";
  19261. var cityPath = "-";
  19262. var arriveCountry = string.Empty;
  19263. //添加城市路径以及住宿地
  19264. //黑屏代码获取时间区间
  19265. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  19266. var empty = "【未收入该三字码!请机票同事录入】";
  19267. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  19268. #region 配置公务活动时间
  19269. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  19270. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  19271. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  19272. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  19273. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  19274. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  19275. {
  19276. 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" }),
  19277. 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"}),
  19278. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  19279. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  19280. };
  19281. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  19282. {
  19283. 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" }),
  19284. 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"}),
  19285. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  19286. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  19287. };
  19288. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  19289. {
  19290. 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" }),
  19291. 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"}),
  19292. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  19293. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  19294. };
  19295. #endregion
  19296. var nextDayNum = 0;
  19297. for (int i = 0; i < timeArr.Count; i++)
  19298. {
  19299. stay = "-";
  19300. cityPath = "-";
  19301. var chiarr = new List<Grp_ApprovalTravelDetails>();
  19302. DateTime NewData = DateTime.Parse(timeArr[i]);
  19303. //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();
  19304. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  19305. if (nextDayNum > 0)
  19306. {
  19307. nextDayNum--;
  19308. }
  19309. if (tbSelect.Length > 0)
  19310. {
  19311. List<string> threeCodeStr = new List<string>();
  19312. bool isTrade = false;
  19313. string trip = string.Empty;
  19314. foreach (var item in tbSelect)
  19315. {
  19316. if (nextDayNum == 0)
  19317. {
  19318. nextDayNum = Convert.ToInt32(item["Sign"]);
  19319. }
  19320. var airStartTime = item["StartTime"].ToString() ?? "0000";
  19321. var airEndTime = item["EndTime"].ToString() ?? "0000";
  19322. var takeOffTime = DateTime.Parse(timeArr[i]);
  19323. var fallToTime = DateTime.Parse(timeArr[i]);
  19324. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  19325. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  19326. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  19327. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  19328. if (nextDayNum > 0)
  19329. {
  19330. fallToTime = fallToTime.AddDays(nextDayNum);
  19331. }
  19332. trip = string.Empty;
  19333. var start = string.Empty;
  19334. var end = string.Empty;
  19335. var threeCode = item["Three"].ToString() ?? "";
  19336. if (threeCode.Length == 6)
  19337. {
  19338. start = threeCode.Substring(0, 3);
  19339. end = threeCode.Substring(3, 3);
  19340. if (threeCodeStr.Count == 0)
  19341. {
  19342. threeCodeStr.Add(start);
  19343. threeCodeStr.Add(end);
  19344. }
  19345. else
  19346. {
  19347. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  19348. {
  19349. threeCodeStr.Add(end);
  19350. }
  19351. else
  19352. {
  19353. threeCodeStr.Add(start);
  19354. threeCodeStr.Add(end);
  19355. }
  19356. }
  19357. }
  19358. //处理机票信息
  19359. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  19360. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  19361. if (start_Object == null)
  19362. {
  19363. start_Object = new Res_ThreeCode()
  19364. {
  19365. AirPort = empty,
  19366. AirPort_En = empty,
  19367. City = empty,
  19368. Country = empty,
  19369. Four = empty,
  19370. Three = empty,
  19371. };
  19372. }
  19373. if (end_Object == null)
  19374. {
  19375. end_Object = new Res_ThreeCode()
  19376. {
  19377. AirPort = empty,
  19378. AirPort_En = empty,
  19379. City = empty,
  19380. Country = empty,
  19381. Four = empty,
  19382. Three = empty,
  19383. };
  19384. }
  19385. //机型判断
  19386. string airModel = item["AirModel"].ToString();
  19387. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  19388. string flightTime = item["FlightTime"].ToString();
  19389. flightTime = ParseBlackTime(flightTime);
  19390. //航班号
  19391. string flightcode = item["Fliagtcode"].ToString();
  19392. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  19393. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  19394. if (aircompany == null)
  19395. {
  19396. aircompany = new Res_AirCompany
  19397. {
  19398. CnName = hsEmpty,
  19399. EnName = hsEmpty,
  19400. ShortCode = hsEmpty,
  19401. };
  19402. }
  19403. //航班前公务安排
  19404. if (tbSelect.First().Equals(item) && i != 0)
  19405. {
  19406. foreach (var takeoff in takeoffTimes)
  19407. {
  19408. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  19409. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  19410. {
  19411. foreach (var addTime in takeoff.Item2)
  19412. {
  19413. chiarr.Add(new Grp_ApprovalTravelDetails
  19414. {
  19415. Time = addTime,
  19416. CreateTime = DateTime.Now,
  19417. CreateUserId = dto.Userid,
  19418. ParentId = 0,
  19419. Details = "公务活动"
  19420. });
  19421. }
  19422. break;
  19423. }
  19424. }
  19425. }
  19426. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  19427. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  19428. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  19429. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  19430. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  19431. if (isTrade)
  19432. {
  19433. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  19434. trip += "(转机不出机场)。";
  19435. }
  19436. //else
  19437. //{
  19438. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  19439. //}
  19440. chiarr.Add(new Grp_ApprovalTravelDetails
  19441. {
  19442. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  19443. CreateTime = DateTime.Now,
  19444. CreateUserId = dto.Userid,
  19445. ParentId = 0,
  19446. Details = trip
  19447. });
  19448. //最后一条到达的时间安排公务
  19449. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  19450. {
  19451. bool isCheckCountry = false;
  19452. if (end_Object.Country != arriveCountry)
  19453. {
  19454. arriveCountry = end_Object.Country;
  19455. isCheckCountry = true;
  19456. }
  19457. if (nextDayNum == 0)
  19458. {
  19459. //需要入境的情况
  19460. if (isCheckCountry)
  19461. {
  19462. foreach (var fallTime in fallTimesCheckCountry)
  19463. {
  19464. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  19465. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  19466. {
  19467. foreach (var addTime in fallTime.Item2)
  19468. {
  19469. chiarr.Add(new Grp_ApprovalTravelDetails
  19470. {
  19471. Time = addTime,
  19472. CreateTime = DateTime.Now,
  19473. CreateUserId = dto.Userid,
  19474. ParentId = 0,
  19475. Details = "公务活动"
  19476. });
  19477. }
  19478. break;
  19479. }
  19480. }
  19481. }
  19482. else
  19483. {
  19484. foreach (var fallTime in fallTimesNotCheckCountry)
  19485. {
  19486. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  19487. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  19488. {
  19489. foreach (var addTime in fallTime.Item2)
  19490. {
  19491. chiarr.Add(new Grp_ApprovalTravelDetails
  19492. {
  19493. Time = addTime,
  19494. CreateTime = DateTime.Now,
  19495. CreateUserId = dto.Userid,
  19496. ParentId = 0,
  19497. Details = "公务活动"
  19498. });
  19499. }
  19500. break;
  19501. }
  19502. }
  19503. }
  19504. }
  19505. }
  19506. }
  19507. //添加乘车语句
  19508. //chiarr.Add(new Grp_ApprovalTravelDetails
  19509. //{
  19510. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  19511. // CreateTime = DateTime.Now,
  19512. // CreateUserId = dto.Userid,
  19513. // ParentId = 0,
  19514. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  19515. //});
  19516. //if (i != timeArr.Count - 1)
  19517. //{
  19518. // fallToTime = fallToTime.AddHours(2.5);
  19519. // foreach (var item in Times)
  19520. // {
  19521. // //排列公务时间
  19522. // if (fallToTime.Hour < item.Item1)
  19523. // {
  19524. // chiarr.Add(new Grp_ApprovalTravelDetails
  19525. // {
  19526. // Time = $"{item.Item2} - {item.Item3}",
  19527. // CreateTime = DateTime.Now,
  19528. // CreateUserId = dto.Userid,
  19529. // ParentId = 0,
  19530. // Details = "公务活动"
  19531. // });
  19532. // }
  19533. // }
  19534. //}
  19535. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  19536. var last = threeCodeStr.Last();
  19537. foreach (var item in threeCodeStr)
  19538. {
  19539. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  19540. if (item.Equals(last))
  19541. {
  19542. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  19543. }
  19544. }
  19545. cityPath = cityPath.Trim('-');
  19546. }
  19547. else
  19548. {
  19549. foreach (var item in Times)
  19550. {
  19551. chiarr.Add(new Grp_ApprovalTravelDetails
  19552. {
  19553. Time = $"{item.Item2} - {item.Item3}",
  19554. CreateTime = DateTime.Now,
  19555. CreateUserId = dto.Userid,
  19556. ParentId = 0,
  19557. Details = "公务活动"
  19558. });
  19559. }
  19560. }
  19561. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  19562. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  19563. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  19564. appro.Diid = dto.Diid;
  19565. appro.CreateUserId = dto.Userid;
  19566. appro.CreateTime = DateTime.Now;
  19567. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  19568. appro.Id = thisId;
  19569. //foreach (var item in gwinfo)
  19570. //{
  19571. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  19572. // chi.Details = "拜访" + item.Client;
  19573. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  19574. // {
  19575. // chi.Details += "," + item.ReqSample;
  19576. // }
  19577. // chi.ParentId = thisId;
  19578. // chi.Time = item.Time;
  19579. // chiarr.Add(chi);
  19580. //}
  19581. if (chiarr.Count < 6)
  19582. {
  19583. for (int j = chiarr.Count; j < 6; j++)
  19584. {
  19585. chiarr.Add(new
  19586. Grp_ApprovalTravelDetails());
  19587. }
  19588. }
  19589. resultArr.Add(new
  19590. {
  19591. appro.Id,
  19592. appro.Date,
  19593. appro.Diid,
  19594. chiList = chiarr.Select(x1 => new
  19595. {
  19596. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  19597. x1.Details,
  19598. x1.ParentId,
  19599. x1.Id
  19600. })
  19601. });
  19602. }
  19603. _sqlSugar.CommitTran();
  19604. jw = JsonView(true, "生成成功!", resultArr);
  19605. }
  19606. catch (Exception ex)
  19607. {
  19608. jw.Code = 400;
  19609. jw.Msg = "生成失败!" + ex.Message;
  19610. }
  19611. return Ok(jw);
  19612. }
  19613. /// <summary>
  19614. /// 报批行程word导出
  19615. /// </summary>
  19616. /// <param name="dto"></param>
  19617. /// <returns></returns>
  19618. [HttpPost]
  19619. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  19620. {
  19621. var jw = JsonView(false);
  19622. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  19623. if (group == null)
  19624. {
  19625. jw.Msg = "暂无该团组!";
  19626. return Ok(jw);
  19627. }
  19628. //模板路径
  19629. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  19630. var fileName = string.Empty;
  19631. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  19632. bool bold = false;
  19633. if (dto.FileIndex == 1)
  19634. {
  19635. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  19636. }
  19637. else if (dto.FileIndex == 2)
  19638. {
  19639. fileName = "省外办-报批.docx";
  19640. bold = false;
  19641. titleFont = "方正黑体简体";
  19642. timeFont = "Times New Roman";
  19643. contentFont = "方正仿宋_GBK";
  19644. }
  19645. else if (dto.FileIndex == 3)
  19646. {
  19647. fileName = "市外办-报批.docx";
  19648. titleFont = "方正黑体简体";
  19649. timeFont = "Times New Roman";
  19650. contentFont = "方正仿宋简体";
  19651. }
  19652. tempPath = tempPath + fileName;
  19653. //载入模板
  19654. Document doc = new Document(tempPath);
  19655. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19656. //获取所填表格的序数
  19657. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19658. Aspose.Words.Tables.Row titleRowClone = null;
  19659. Aspose.Words.Tables.Row CenterRowClone = null;
  19660. int index = 0;
  19661. int indexChi = 0;
  19662. int SetIndex = 0;
  19663. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  19664. //获取数据,放到datatable
  19665. foreach (var item in ApprovalTravelArr)
  19666. {
  19667. if (index > 0)
  19668. {
  19669. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  19670. tableOne.AppendChild(titleRowClone);
  19671. }
  19672. var textTime = item.Date;
  19673. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  19674. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  19675. SetIndex++;
  19676. if (ChiRep.Count > 0)
  19677. {
  19678. foreach (var itemChi in ChiRep)
  19679. {
  19680. var txtTime = itemChi.Time;
  19681. var txtDetail = itemChi.Details;
  19682. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  19683. {
  19684. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  19685. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  19686. //indexChi++;
  19687. //SetIndex++;
  19688. break;
  19689. }
  19690. if (indexChi > 0)
  19691. {
  19692. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  19693. tableOne.AppendChild(CenterRowClone);
  19694. }
  19695. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  19696. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  19697. indexChi++;
  19698. SetIndex++;
  19699. }
  19700. }
  19701. //else
  19702. //{
  19703. // if (indexChi > 0)
  19704. // {
  19705. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  19706. // tableOne.AppendChild(CenterRowClone);
  19707. // }
  19708. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  19709. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  19710. // indexChi++;
  19711. // SetIndex++;
  19712. //}
  19713. index++;
  19714. }
  19715. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  19716. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  19717. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  19718. jw.Code = 200;
  19719. jw.Msg = "";
  19720. return Ok(jw);
  19721. }
  19722. private string ParseBlackTime(string time)
  19723. {
  19724. // 匹配可能只有分钟的情况
  19725. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  19726. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  19727. if (match.Success)
  19728. {
  19729. string hours = match.Groups[1].Value;
  19730. string minutes = match.Groups[2].Value;
  19731. // 如果小时部分为空,则只显示分钟
  19732. if (string.IsNullOrEmpty(hours))
  19733. {
  19734. return $"{minutes}分钟";
  19735. }
  19736. // 如果分钟部分为空,则只显示小时
  19737. else if (string.IsNullOrEmpty(minutes))
  19738. {
  19739. return $"{hours}小时";
  19740. }
  19741. // 否则显示完整格式
  19742. else
  19743. {
  19744. return $"{hours}小时{minutes}分钟";
  19745. }
  19746. }
  19747. else
  19748. {
  19749. return "未知时长";
  19750. }
  19751. }
  19752. private string intToString(int numberVal)
  19753. {
  19754. string numberval = numberVal.ToString();
  19755. Dictionary<char, string> Number = new Dictionary<char, string>();
  19756. Number.Add('1', "一");
  19757. Number.Add('2', "二");
  19758. Number.Add('3', "三");
  19759. Number.Add('4', "四");
  19760. Number.Add('5', "五");
  19761. Number.Add('6', "六");
  19762. Number.Add('7', "七");
  19763. Number.Add('8', "八");
  19764. Number.Add('9', "九");
  19765. string stringNumberVal = string.Empty;
  19766. for (int i = 0; i < numberval.Length; i++)
  19767. {
  19768. if (i == 0)
  19769. {
  19770. stringNumberVal += Number[numberval[i]];
  19771. }
  19772. else if (i >= 1)
  19773. {
  19774. if (numberval[i] == '0')
  19775. {
  19776. stringNumberVal = "十";
  19777. }
  19778. else
  19779. {
  19780. stringNumberVal += "十" + Number[numberval[i]];
  19781. }
  19782. }
  19783. }
  19784. return stringNumberVal;
  19785. }
  19786. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  19787. {
  19788. //获取table中的某个单元格,从0开始
  19789. Cell lshCell = table.Rows[rows].Cells[cells];
  19790. //将单元格中段落移除
  19791. foreach (Paragraph item in lshCell.Paragraphs)
  19792. {
  19793. lshCell.Paragraphs.Remove(item);
  19794. }
  19795. if (val.Contains("\r\n"))
  19796. {
  19797. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  19798. foreach (var item in spArr)
  19799. {
  19800. //新建一个段落
  19801. Paragraph p = new Paragraph(doc);
  19802. var r = new Run(doc, item);
  19803. //设置字体
  19804. if (!string.IsNullOrEmpty(font))
  19805. {
  19806. r.Font.Name = font;
  19807. }
  19808. r.Font.Bold = bold;
  19809. //把设置的值赋给之前新建的段落
  19810. p.AppendChild(r);
  19811. //将此段落加到单元格内
  19812. lshCell.AppendChild(p);
  19813. }
  19814. }
  19815. else
  19816. {
  19817. //新建一个段落
  19818. Paragraph p = new Paragraph(doc);
  19819. var r = new Run(doc, val);
  19820. //设置字体
  19821. if (!string.IsNullOrEmpty(font))
  19822. {
  19823. r.Font.Name = font;
  19824. }
  19825. r.Font.Bold = bold;
  19826. //把设置的值赋给之前新建的段落
  19827. p.AppendChild(r);
  19828. //将此段落加到单元格内
  19829. lshCell.AppendChild(p);
  19830. }
  19831. }
  19832. [HttpPost]
  19833. public async Task<IActionResult> ServerHttp(string paramStr)
  19834. {
  19835. paramStr = paramStr.TrimEnd('\'');
  19836. paramStr = paramStr.TrimStart('\'');
  19837. JsonView jw = JsonView(false);
  19838. JObject param = JObject.Parse(paramStr);
  19839. if (!param.ContainsKey("url"))
  19840. {
  19841. jw.Msg = "url null";
  19842. return Ok(jw);
  19843. }
  19844. string url = param["url"]!.ToString();
  19845. var methon = "get";
  19846. Dictionary<string, string> headValues = null;
  19847. string bodyStr = string.Empty;
  19848. if (param.ContainsKey("methon"))
  19849. {
  19850. methon = param["methon"]!.ToString().ToLower();
  19851. }
  19852. if (param.ContainsKey("header"))
  19853. {
  19854. var header = param["header"]!.ToString();
  19855. JObject headerJobject = JObject.Parse(header);
  19856. headValues = new Dictionary<string, string>();
  19857. foreach (JProperty item in headerJobject.Properties())
  19858. {
  19859. var value = item.Value.ToString();
  19860. var head = item.Path;
  19861. headValues.Add(head, value);
  19862. }
  19863. }
  19864. HttpClient client = new HttpClient();
  19865. string responseString = string.Empty;
  19866. StringContent content = null;
  19867. if (headValues != null)
  19868. {
  19869. foreach (var item in headValues.Keys)
  19870. {
  19871. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  19872. {
  19873. if (param.ContainsKey("body"))
  19874. {
  19875. bodyStr = param["body"]!.ToString();
  19876. }
  19877. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  19878. }
  19879. else
  19880. {
  19881. client.DefaultRequestHeaders.Add(item, headValues[item]);
  19882. }
  19883. }
  19884. }
  19885. try
  19886. {
  19887. if (methon == "get")
  19888. {
  19889. responseString = await client.GetStringAsync(url);
  19890. }
  19891. else if (methon == "post")
  19892. {
  19893. var request = new HttpRequestMessage(HttpMethod.Post, url)
  19894. {
  19895. Content = content
  19896. };
  19897. var response = await client.SendAsync(request);
  19898. try
  19899. {
  19900. Stream responseStream = await response.Content.ReadAsStreamAsync();
  19901. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  19902. {
  19903. using (StreamReader reader = new StreamReader(gzipStream))
  19904. {
  19905. responseString = await reader.ReadToEndAsync();
  19906. }
  19907. }
  19908. }
  19909. catch (Exception)
  19910. {
  19911. responseString = await response.Content.ReadAsStringAsync();
  19912. }
  19913. }
  19914. else
  19915. {
  19916. responseString = "methon error";
  19917. }
  19918. jw = JsonView(true, "success", responseString);
  19919. }
  19920. catch (Exception ex)
  19921. {
  19922. jw.Msg = "error " + ex.Message;
  19923. jw.Data = ex.StackTrace;
  19924. }
  19925. finally
  19926. {
  19927. client.Dispose();
  19928. }
  19929. return Ok(jw);
  19930. }
  19931. #endregion
  19932. #region 团组接待意见调查
  19933. /// <summary>
  19934. /// 团组接待意见调查 - 信息管理
  19935. /// 基础数据(团组)
  19936. /// </summary>
  19937. /// <returns></returns>
  19938. [HttpGet]
  19939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19940. public async Task<IActionResult> OpinionaireInit()
  19941. {
  19942. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  19943. .Select(x => new
  19944. {
  19945. x.Id,
  19946. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  19947. })
  19948. .OrderByDescending(x => x.Id)
  19949. .ToListAsync();
  19950. return Ok(JsonView(groupData, groupData.Count));
  19951. }
  19952. /// <summary>
  19953. /// 团组接待意见调查 - 信息管理
  19954. /// 列表
  19955. /// </summary>
  19956. /// <param name="groupId"></param>
  19957. /// <returns></returns>
  19958. [HttpGet("{groupId}")]
  19959. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19960. public async Task<IActionResult> OpinionaireManageList(int groupId)
  19961. {
  19962. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19963. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  19964. .Select(x => new
  19965. {
  19966. x.Id,
  19967. x.TourGuideName,
  19968. x.CityName,
  19969. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  19970. x.CreateTime
  19971. })
  19972. .OrderBy(x => x.Id)
  19973. .ToListAsync();
  19974. return Ok(JsonView(data));
  19975. }
  19976. /// <summary>
  19977. /// 团组接待意见调查 - 信息管理
  19978. /// 保存
  19979. /// </summary>
  19980. /// <param name="dto"></param>
  19981. /// <returns></returns>
  19982. [HttpPost]
  19983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19984. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  19985. {
  19986. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19987. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19988. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19989. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  19990. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  19991. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  19992. _opinionaireRep.BeginTran();
  19993. if (addData != null && addData.Count > 0)
  19994. {
  19995. foreach (var item in addData)
  19996. {
  19997. item.CreateUserId = currUserInfo.UserId;
  19998. item.DiId = dto.DiId;
  19999. }
  20000. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  20001. }
  20002. if (updData != null && updData.Count > 0)
  20003. {
  20004. var upd = await _opinionaireRep._sqlSugar
  20005. .Updateable(updData)
  20006. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  20007. .WhereColumns(x => new { x.Id })
  20008. .ExecuteCommandAsync();
  20009. }
  20010. _opinionaireRep.CommitTran();
  20011. return Ok(JsonView("操作成功!"));
  20012. }
  20013. /// <summary>
  20014. /// 团组接待意见调查 - 信息管理
  20015. /// 删除
  20016. /// </summary>
  20017. /// <param name="id"></param>
  20018. /// <returns></returns>
  20019. [HttpDelete("{id}")]
  20020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20021. public async Task<IActionResult> OpinionaireManageDel(int id)
  20022. {
  20023. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  20024. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  20025. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  20026. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  20027. if (!del) return Ok(JsonView("操作失败!"));
  20028. return Ok(JsonView("操作成功!"));
  20029. }
  20030. /// <summary>
  20031. /// 团组接待意见调查 - 用户
  20032. /// 列表
  20033. /// </summary>
  20034. /// <param name="diId"></param>
  20035. /// <returns></returns>
  20036. [HttpGet("{diId}")]
  20037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20038. public async Task<IActionResult> OpinionaireUserList(int diId)
  20039. {
  20040. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  20041. var sql = string.Format(@"
  20042. SELECT
  20043. o.Id,
  20044. o.DiId,
  20045. di.TeamName AS 'GroupName',
  20046. di.VisitPNumber AS 'PeopleNumber',
  20047. di.ClientName AS 'LeadGroup',
  20048. di.VisitCountry AS 'Travel',
  20049. di.VisitDays AS 'Days',
  20050. o.CityName,
  20051. o.TourGuideName,
  20052. o.Catering,
  20053. o.CateringReason,
  20054. o.Stay,
  20055. o.StayReason,
  20056. o.[Route],
  20057. o.RouteReason,
  20058. o.OfficialActivity,
  20059. o.OfficialActivityReason,
  20060. o.TourGuide,
  20061. o.TourGuideReason,
  20062. o.[Translate],
  20063. o.TranslateReason,
  20064. o.Trip,
  20065. o.TripReason,
  20066. o.ESFileName,
  20067. o.SignatureDate,
  20068. o.Remark
  20069. FROM
  20070. Grp_Opinionaire o
  20071. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  20072. WHERE
  20073. o.IsDel = 0
  20074. AND o.DiId = {0}
  20075. ORDER BY
  20076. o.Id ASC", diId);
  20077. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  20078. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  20079. return Ok(JsonView(data));
  20080. }
  20081. /// <summary>
  20082. /// 团组接待意见调查 - 用户
  20083. /// 保存
  20084. /// </summary>
  20085. /// <param name="dto"></param>
  20086. /// <returns></returns>
  20087. [HttpPost]
  20088. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20089. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  20090. {
  20091. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  20092. foreach (var item in dto)
  20093. {
  20094. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  20095. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  20096. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  20097. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  20098. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  20099. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  20100. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  20101. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  20102. }
  20103. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  20104. if (!Directory.Exists(filePathBase))
  20105. {
  20106. Directory.CreateDirectory(filePathBase);
  20107. }
  20108. #region 上传文件
  20109. var filePaths = new List<string>();
  20110. foreach (var item in dto)
  20111. {
  20112. var file = item.File;
  20113. // 将文件保存到指定位置
  20114. var filePath = Path.Combine(filePathBase, file.FileName);
  20115. using (var stream = new FileStream(filePath, FileMode.Create))
  20116. {
  20117. await file.CopyToAsync(stream);
  20118. }
  20119. //验证文件是否上传成功
  20120. if (!System.IO.File.Exists(filePath))
  20121. {
  20122. foreach (var filePathStr in filePaths)
  20123. {
  20124. System.IO.File.Delete(filePathStr);
  20125. }
  20126. return Ok(JsonView(false, "文件上传失败!"));
  20127. }
  20128. item.ESFileName = file.FileName;
  20129. }
  20130. #endregion
  20131. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  20132. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  20133. .UpdateColumns(x => new
  20134. {
  20135. x.Catering,
  20136. x.CateringReason,
  20137. x.Stay,
  20138. x.StayReason,
  20139. x.Route,
  20140. x.RouteReason,
  20141. x.OfficialActivity,
  20142. x.OfficialActivityReason,
  20143. x.TourGuide,
  20144. x.TourGuideReason,
  20145. x.Translate,
  20146. x.TranslateReason,
  20147. x.Trip,
  20148. x.TripReason,
  20149. x.ESFileName,
  20150. x.SignatureDate,
  20151. x.Remark
  20152. })
  20153. .WhereColumns(x => new { x.Id })
  20154. .ExecuteCommandAsync();
  20155. if (upd < 1)
  20156. {
  20157. foreach (var filePathStr in filePaths)
  20158. {
  20159. System.IO.File.Delete(filePathStr);
  20160. }
  20161. return Ok(JsonView(false));
  20162. }
  20163. return Ok(JsonView(true));
  20164. }
  20165. #endregion
  20166. #region 团组餐厅相关信息
  20167. /// <summary>
  20168. /// 团组相关餐厅信息
  20169. /// 基础数据(团组)
  20170. /// </summary>
  20171. /// <returns></returns>
  20172. [HttpGet]
  20173. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20174. public async Task<IActionResult> RestaurantInit()
  20175. {
  20176. return Ok(await _restaurantRep.InitAsync());
  20177. }
  20178. /// <summary>
  20179. /// 团组相关餐厅信息
  20180. /// Item
  20181. /// </summary>
  20182. /// <param name="dto"></param>
  20183. /// <returns></returns>
  20184. [HttpPost]
  20185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20186. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  20187. {
  20188. int portType = dto.PortType,
  20189. groupId = dto.GroupId;
  20190. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  20191. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  20192. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  20193. }
  20194. /// <summary>
  20195. /// 团组相关餐厅信息
  20196. /// List
  20197. /// </summary>
  20198. /// <param name="dto"></param>
  20199. /// <returns></returns>
  20200. [HttpPost]
  20201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20202. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  20203. {
  20204. int portType = dto.PortType,
  20205. groupId = dto.GroupId;
  20206. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  20207. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  20208. var sql = string.Format(@" SELECT
  20209. ri.Id,
  20210. ri.GroupId,
  20211. ri.Date,
  20212. ri.StartTime,
  20213. ri.EndTime,
  20214. CASE WHEN ri.Type = 1 THEN '早餐'
  20215. WHEN ri.Type = 2 THEN '午餐'
  20216. WHEN ri.Type = 3 THEN '晚餐'
  20217. ELSE '其他'
  20218. END AS 'Type',
  20219. ri.Name,
  20220. ri.Address,
  20221. ri.Tel,
  20222. ri.Remark,
  20223. ri.CreateTime,
  20224. u.CnName AS CreateUserName
  20225. FROM
  20226. Grp_RestaurantInfo ri
  20227. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  20228. WHERE
  20229. ri.IsDel = 0
  20230. AND ri.GroupId = {0}
  20231. ORDER BY
  20232. ri.Date ASC
  20233. ", groupId);
  20234. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  20235. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  20236. return Ok(JsonView(infos));
  20237. }
  20238. /// <summary>
  20239. /// 团组相关餐厅信息
  20240. /// Info
  20241. /// </summary>
  20242. /// <param name="dto"></param>
  20243. /// <returns></returns>
  20244. [HttpPost]
  20245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20246. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  20247. {
  20248. int portType = dto.PortType,
  20249. id = dto.Id;
  20250. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  20251. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  20252. return Ok(await _restaurantRep.InfoAsync(portType, id));
  20253. }
  20254. /// <summary>
  20255. /// 团组相关餐厅信息
  20256. /// Op
  20257. /// </summary>
  20258. /// <param name="dto"></param>
  20259. /// <returns></returns>
  20260. [HttpPost]
  20261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20262. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  20263. {
  20264. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20265. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  20266. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  20267. return Ok(await _restaurantRep.OpAsync(dto));
  20268. }
  20269. /// <summary>
  20270. /// 团组相关餐厅信息
  20271. /// Del
  20272. /// </summary>
  20273. /// <param name="dto"></param>
  20274. /// <returns></returns>
  20275. [HttpPost]
  20276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20277. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  20278. {
  20279. int userId = dto.DeleteUserId;
  20280. var id = dto.Id;
  20281. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20282. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  20283. return Ok(await _restaurantRep.DelAsync(dto));
  20284. }
  20285. #endregion
  20286. // /// <summary>
  20287. // ///
  20288. // /// </summary>
  20289. // /// <param name="_dto"></param>
  20290. // /// <returns></returns>
  20291. // [HttpPost]
  20292. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20293. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  20294. // {
  20295. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  20296. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  20297. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  20298. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  20299. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  20300. // dic_psg.Add("客人", 974);
  20301. // dic_psg.Add("司机", 975);
  20302. // dic_psg.Add("导游", 976);
  20303. // dic_psg.Add("公司内部人员", 977);
  20304. // dic_psg.Add("司机/导游/公司内部人员", 978);
  20305. // foreach (var item in list_visa)
  20306. // {
  20307. // Grp_VisaInfo temp = new Grp_VisaInfo();
  20308. // temp.Id = item.Id;
  20309. // temp.DIId = item.DIId;
  20310. // temp.VisaClient = item.VisaClient;
  20311. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  20312. // temp.VisaCurrency = item.VisaCurrency;
  20313. // temp.IsThird = item.IsThird;
  20314. // if (dic_psg.ContainsKey(item.PassengerType))
  20315. // {
  20316. // temp.PassengerType = dic_psg[item.PassengerType];
  20317. // }
  20318. // else {
  20319. // temp.PassengerType = -1;
  20320. // }
  20321. // temp.VisaNumber = item.VisaNumber;
  20322. // temp.VisaFreeNumber = item.VisaFreeNumber;
  20323. // temp.CreateUserId = item.Operators;
  20324. // DateTime dt_ct;
  20325. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  20326. // if (b_ct)
  20327. // {
  20328. // temp.CreateTime = dt_ct;
  20329. // }
  20330. // else
  20331. // {
  20332. // temp.CreateTime = DateTime.Now;
  20333. // }
  20334. // temp.DeleteTime = "";
  20335. // temp.DeleteUserId = 0;
  20336. // temp.Remark = item.Remark;
  20337. // if (string.IsNullOrEmpty(temp.Remark)) {
  20338. // temp.Remark = "";
  20339. // }
  20340. // temp.IsDel = item.IsDel;
  20341. // temp.VisaDescription = item.VisaAttachment;
  20342. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  20343. //([Id]
  20344. // ,[DIId]
  20345. // ,[VisaClient]
  20346. // ,[VisaPrice]
  20347. // ,[VisaCurrency]
  20348. // ,[IsThird]
  20349. // ,[PassengerType]
  20350. // ,[VisaNumber]
  20351. // ,[VisaFreeNumber]
  20352. // ,[CreateUserId]
  20353. // ,[CreateTime]
  20354. // ,[DeleteTime]
  20355. // ,[DeleteUserId]
  20356. // ,[Remark]
  20357. // ,[IsDel]
  20358. // ,[visaDescription])
  20359. // VALUES
  20360. // ({0},{1},'{2}',{3},{4}
  20361. //,{5},{6},{7},{8},{9}
  20362. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  20363. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  20364. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  20365. //);
  20366. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  20367. // }
  20368. // return Ok(JsonView(true, "操作成功!"));
  20369. // }
  20370. /// <summary>
  20371. /// 123132123
  20372. /// </summary>
  20373. /// <param name="_dto"></param>
  20374. /// <returns></returns>
  20375. [HttpPost]
  20376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20377. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  20378. {
  20379. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  20380. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  20381. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  20382. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  20383. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  20384. dicDetail.Add(789, 1034);
  20385. dicDetail.Add(790, 1035);
  20386. dicDetail.Add(791, 1036);
  20387. dicDetail.Add(792, 1037);
  20388. dicDetail.Add(793, 1038);
  20389. dicDetail.Add(794, 1039);
  20390. dicDetail.Add(795, 1040);
  20391. dicDetail.Add(796, 1041);
  20392. dicDetail.Add(797, 1042);
  20393. dicDetail.Add(798, 1043);
  20394. dicDetail.Add(801, 1044);
  20395. dicDetail.Add(802, 1045);
  20396. dicDetail.Add(803, 1046);
  20397. Dictionary<int, int> dic = new Dictionary<int, int>();
  20398. dic.Add(806, 1027);
  20399. dic.Add(807, 1028);
  20400. dic.Add(808, 1029);
  20401. dic.Add(809, 1030);
  20402. dic.Add(810, 1031);
  20403. dic.Add(811, 1032);
  20404. dic.Add(812, 1033);
  20405. foreach (var item in list_visa)
  20406. {
  20407. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  20408. temp.Coefficient = item.coefficient;
  20409. DateTime dtCrt;
  20410. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  20411. if (b1)
  20412. {
  20413. temp.CreateTime = dtCrt;
  20414. }
  20415. else
  20416. {
  20417. temp.CreateTime = DateTime.Now;
  20418. }
  20419. temp.CreateUserId = item.Operators;
  20420. temp.DeleteTime = "";
  20421. temp.DeleteUserId = 0;
  20422. temp.DiId = int.Parse(item.DIID);
  20423. temp.FilePath = item.FilePath;
  20424. temp.IsDel = item.IsDel;
  20425. temp.Price = item.Price;
  20426. temp.PriceCount = 1;
  20427. temp.PriceCurrency = item.Currency;
  20428. int detailId = 0;
  20429. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  20430. {
  20431. detailId = dicDetail[item.PriceTypeDetail];
  20432. }
  20433. temp.PriceDetailType = detailId;
  20434. temp.PriceDt = DateTime.Now;
  20435. temp.PriceName = item.PriceName;
  20436. temp.PriceSum = item.Price;
  20437. int tid = 0;
  20438. if (dic.ContainsKey(item.PriceType))
  20439. {
  20440. tid = dic[item.PriceType];
  20441. }
  20442. temp.PriceType = tid;
  20443. temp.Remark = item.Remark;
  20444. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  20445. }
  20446. return Ok(JsonView(true, "操作成功!"));
  20447. }
  20448. [HttpPost]
  20449. public IActionResult TimeTest()
  20450. {
  20451. var jw = JsonView(false, "error");
  20452. _sqlSugar.BeginTran();
  20453. try
  20454. {
  20455. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  20456. .Select(x => new Crm_NewClientData
  20457. {
  20458. Id = x.Id,
  20459. Client = x.Client,
  20460. Contact = x.Contact,
  20461. Location = x.Location,
  20462. })
  20463. .ToList();
  20464. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  20465. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  20466. Stopwatch stopwatch = new Stopwatch();
  20467. // 开始计时
  20468. stopwatch.Start();
  20469. foreach (var item in clientList)
  20470. {
  20471. EncryptionProcessor.DecryptProperties(item);
  20472. }
  20473. stopwatch.Stop();
  20474. jw.Code = 200;
  20475. jw.Data = stopwatch.ElapsedMilliseconds;
  20476. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  20477. }
  20478. catch (Exception ex)
  20479. {
  20480. jw.Code = 400;
  20481. jw.Msg = ex.Message;
  20482. }
  20483. return Ok(jw);
  20484. }
  20485. }
  20486. }