GroupsController.cs 614 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing.Texts;
  3. using Aspose.Words;
  4. using Aspose.Words.Tables;
  5. using NPOI.Util;
  6. using OASystem.API.OAMethodLib;
  7. using OASystem.API.OAMethodLib.File;
  8. using OASystem.Domain.Dtos.Groups;
  9. using OASystem.Domain.Entities.Groups;
  10. using OASystem.Domain.ViewModels.Groups;
  11. using OASystem.Infrastructure.Repositories.Groups;
  12. using TencentCloud.Ocr.V20181119.Models;
  13. using OASystem.Infrastructure.Tools;
  14. using System.Web;
  15. using System.Data;
  16. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  17. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  18. using Cell = Aspose.Words.Tables.Cell;
  19. using Row = Aspose.Words.Tables.Row;
  20. using System.Runtime.Intrinsics.Arm;
  21. using Microsoft.AspNetCore.Mvc.Filters;
  22. using OASystem.Domain.Entities.Customer;
  23. using NPOI.SS.Formula.Functions;
  24. using OASystem.Domain.Dtos.CRM;
  25. using System.Diagnostics;
  26. using MathNet.Numerics.Statistics.Mcmc;
  27. using AlibabaCloud.OpenApiClient.Models;
  28. using System;
  29. using NPOI.HPSF;
  30. using SqlSugar;
  31. using System.Collections;
  32. using Org.BouncyCastle.Ocsp;
  33. using System.Globalization;
  34. using static QRCoder.PayloadGenerator;
  35. using Bookmark = Aspose.Words.Bookmark;
  36. using Aspose.Words.Fields;
  37. using NPOI.POIFS.FileSystem;
  38. using Microsoft.AspNetCore.Mvc.ViewEngines;
  39. using OASystem.Domain.ViewModels.QiYeWeChat;
  40. using OASystem.Domain.Entities.Financial;
  41. using NPOI.POIFS.Crypt.Dsig;
  42. using System.Diagnostics.Eventing.Reader;
  43. using System.IO;
  44. using StackExchange.Redis;
  45. using Org.BouncyCastle.Utilities;
  46. using Aspose.Words.Drawing;
  47. using Aspose.Cells.Charts;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using Quartz.Util;
  50. using Google.Protobuf.WellKnownTypes;
  51. using Microsoft.AspNetCore.SignalR;
  52. using OASystem.API.OAMethodLib.Hub.HubClients;
  53. using OASystem.API.OAMethodLib.Hub.Hubs;
  54. using System.Collections.Generic;
  55. using OASystem.API.OAMethodLib.JuHeAPI;
  56. using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
  57. using SixLabors.Fonts.Tables.AdvancedTypographic;
  58. using Microsoft.EntityFrameworkCore;
  59. using System.Security.Cryptography.Xml;
  60. using MathNet.Numerics;
  61. using System.Security.Policy;
  62. using System.Xml;
  63. using OASystem.Domain.Dtos.QiYeWeChat;
  64. using static NPOI.POIFS.Crypt.CryptoFunctions;
  65. using Aspose.Words.Lists;
  66. using OASystem.API.OAMethodLib.YouDaoAPI;
  67. using NPOI.XSSF.Streaming.Values;
  68. using OASystem.API.OAMethodLib.Quartz.Business;
  69. using System.Linq;
  70. using NPOI.POIFS.NIO;
  71. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  72. using OASystem.Domain.ViewModels.Statistics;
  73. using NPOI.XSSF.Model;
  74. using NetTaste;
  75. using Microsoft.AspNetCore.Http;
  76. using EyeSoft.Collections.Generic;
  77. using NPOI.HSSF.Util;
  78. using NPOI.HSSF.UserModel;
  79. using NPOI.SS.UserModel;
  80. using NPOI.XSSF.UserModel;
  81. using MySqlX.XDevAPI.Relational;
  82. using SqlSugar.Extensions;
  83. using Table = Aspose.Words.Tables.Table;
  84. using Aspose.Cells.Tables;
  85. using NPOI.SS.Util;
  86. using RestSharp.Extensions;
  87. using Microsoft.AspNetCore.WebUtilities;
  88. using K4os.Compression.LZ4.Internal;
  89. using static Pipelines.Sockets.Unofficial.SocketConnection;
  90. using System.Diagnostics.PerformanceData;
  91. using System.Drawing.Printing;
  92. namespace OASystem.API.Controllers
  93. {
  94. /// <summary>
  95. /// 团组相关
  96. /// </summary>
  97. //[Authorize]
  98. [Route("api/[controller]/[action]")]
  99. public class GroupsController : ControllerBase
  100. {
  101. private readonly GrpScheduleRepository _grpScheduleRep;
  102. private readonly IMapper _mapper;
  103. private readonly DelegationInfoRepository _groupRepository;
  104. private readonly TaskAssignmentRepository _taskAssignmentRep;
  105. private readonly AirTicketResRepository _airTicketResRep;
  106. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  107. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  108. private readonly DelegationEnDataRepository _delegationEnDataRep;
  109. private readonly DelegationVisaRepository _delegationVisaRep;
  110. private readonly VisaPriceRepository _visaPriceRep;
  111. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  112. private readonly HotelPriceRepository _hotelPriceRep;
  113. private readonly CustomersRepository _customersRep;
  114. private readonly MessageRepository _message;
  115. private readonly SqlSugarClient _sqlSugar;
  116. private readonly TourClientListRepository _tourClientListRep;
  117. private readonly TeamRateRepository _teamRateRep;
  118. #region 成本相关
  119. private readonly CheckBoxsRepository _checkBoxs;
  120. private readonly GroupCostRepository _GroupCostRepository;
  121. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  122. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  123. #endregion
  124. private readonly SetDataRepository _setDataRep;
  125. private string url;
  126. private string path;
  127. private readonly EnterExitCostRepository _enterExitCostRep;
  128. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  129. private readonly UsersRepository _usersRep;
  130. private readonly IJuHeApiService _juHeApi;
  131. private readonly InvertedListRepository _invertedListRep;
  132. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  133. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  134. private readonly HotelInquiryRepository _hotelInquiryRep;
  135. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  136. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  137. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  138. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  139. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  140. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  141. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  142. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep)
  143. {
  144. _mapper = mapper;
  145. _grpScheduleRep = grpScheduleRep;
  146. _groupRepository = groupRepository;
  147. _taskAssignmentRep = taskAssignmentRep;
  148. _airTicketResRep = airTicketResRep;
  149. _sqlSugar = sqlSugar;
  150. url = AppSettingsHelper.Get("ExcelBaseUrl");
  151. path = AppSettingsHelper.Get("ExcelBasePath");
  152. if (!System.IO.Directory.Exists(path))
  153. {
  154. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  155. }
  156. _decreasePaymentsRep = decreasePaymentsRep;
  157. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  158. _delegationEnDataRep = delegationEnDataRep;
  159. _enterExitCostRep = enterExitCostRep;
  160. _delegationVisaRep = delegationVisaRep;
  161. _message = message;
  162. _visaPriceRep = visaPriceRep;
  163. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  164. _checkBoxs = checkBoxs;
  165. _GroupCostRepository = GroupCostRepository;
  166. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  167. _GroupCostParameterRepository = GroupCostParameterRepository;
  168. _hotelPriceRep = hotelPriceRep;
  169. _customersRep = customersRep;
  170. _setDataRep = setDataRep;
  171. _tourClientListRep = tourClientListRep;
  172. _teamRateRep = teamRateRep;
  173. _hubContext = hubContext;
  174. _usersRep = usersRep;
  175. _juHeApi = juHeApi;
  176. _invertedListRep = invertedListRep;
  177. _visaFeeInfoRep = visaFeeInfoRep;
  178. _ticketBlackCodeRep = ticketBlackCodeRep;
  179. _hotelInquiryRep = hotelInquiryRep;
  180. }
  181. #region 流程管控
  182. /// <summary>
  183. /// 获取团组流程管控信息
  184. /// </summary>
  185. /// <param name="paras">参数Json字符串</param>
  186. /// <returns></returns>
  187. [HttpPost]
  188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  189. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  190. {
  191. if (string.IsNullOrEmpty(_jsonDto.Paras))
  192. {
  193. return Ok(JsonView(false, "参数为空"));
  194. }
  195. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  196. if (_ScheduleDto != null)
  197. {
  198. if (_ScheduleDto.SearchType == 2)//获取列表
  199. {
  200. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  201. return Ok(JsonView(_grpScheduleViewList));
  202. }
  203. else//获取对象
  204. {
  205. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  206. if (_grpScheduleView != null)
  207. {
  208. return Ok(JsonView(_grpScheduleView));
  209. }
  210. }
  211. }
  212. else
  213. {
  214. return Ok(JsonView(false, "参数反序列化失败"));
  215. }
  216. return Ok(JsonView(false, "暂无数据!"));
  217. }
  218. /// <summary>
  219. /// 修改团组流程管控详细表数据
  220. /// </summary>
  221. /// <param name="paras"></param>
  222. /// <returns></returns>
  223. [HttpPost]
  224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  225. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  226. {
  227. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  228. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  229. .SetColumns(it => it.Duty == _detail.Duty)
  230. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  231. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  232. .SetColumns(it => it.JobContent == _detail.JobContent)
  233. .SetColumns(it => it.Remark == _detail.Remark)
  234. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  235. .Where(s => s.Id == dto.Id)
  236. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  237. .ExecuteCommandAsync();
  238. if (result > 0)
  239. {
  240. return Ok(JsonView(true, "保存成功!"));
  241. }
  242. return Ok(JsonView(false, "保存失败!"));
  243. }
  244. /// <summary>
  245. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  246. /// </summary>
  247. /// <param name="dto"></param>
  248. /// <returns></returns>
  249. [HttpPost]
  250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  251. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  252. {
  253. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  254. _detail.IsDel = 1;
  255. _detail.DeleteUserId = dto.Duty;
  256. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  257. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  258. .SetColumns(it => it.IsDel == _detail.IsDel)
  259. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  260. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  261. .Where(it => it.Id == dto.Id)
  262. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  263. //.WhereColumns(s => s.Id == dto.Id)
  264. .ExecuteCommandAsync();
  265. if (result > 0)
  266. {
  267. return Ok(JsonView(true, "删除成功!"));
  268. }
  269. return Ok(JsonView(false, "删除失败!"));
  270. }
  271. /// <summary>
  272. /// 增加团组流程管控详细表数据
  273. /// </summary>
  274. /// <param name="dto"></param>
  275. /// <returns></returns>
  276. [HttpPost]
  277. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  278. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  279. {
  280. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  281. if (DateTime.Now < _detail.ExpectBeginDt)
  282. {
  283. _detail.StepStatus = 0;
  284. }
  285. else
  286. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  287. _detail.StepStatus = 1;
  288. }
  289. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  290. if (result > 0)
  291. {
  292. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  293. return Ok(JsonView(true, "添加成功!", _result));
  294. }
  295. return Ok(JsonView(false, "添加失败!"));
  296. }
  297. #endregion
  298. #region 团组基本信息
  299. /// <summary>
  300. /// 接团信息列表
  301. /// </summary>
  302. /// <param name="dto">团组列表请求dto</param>
  303. /// <returns></returns>
  304. [HttpPost]
  305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  306. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  307. {
  308. var groupData = await _groupRepository.GetGroupList(dto);
  309. if (groupData.Code != 0)
  310. {
  311. return Ok(JsonView(false, groupData.Msg));
  312. }
  313. return Ok(JsonView(groupData.Data));
  314. }
  315. /// <summary>
  316. /// 接团信息列表 Page
  317. /// </summary>
  318. /// <param name="dto">团组列表请求dto</param>
  319. /// <returns></returns>
  320. [HttpPost]
  321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  322. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  323. {
  324. #region 参数验证
  325. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  326. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  327. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  328. #region 页面操作权限验证
  329. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  330. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  331. #endregion
  332. #endregion
  333. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  334. {
  335. string sqlWhere = string.Empty;
  336. if (dto.IsSure == 0) //未完成
  337. {
  338. sqlWhere += string.Format(@" And IsSure = 0");
  339. }
  340. else if (dto.IsSure == 1) //已完成
  341. {
  342. sqlWhere += string.Format(@" And IsSure = 1");
  343. }
  344. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  345. {
  346. string tj = dto.SearchCriteria;
  347. 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}%')",
  348. tj, tj, tj, tj, tj);
  349. }
  350. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  351. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  352. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  353. JietuanOperator,IsSure,CreateTime
  354. From (
  355. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  356. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  357. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  358. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  359. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  360. From Grp_DelegationInfo gdi
  361. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  362. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  363. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  364. Where gdi.IsDel = 0 {0}
  365. ) temp", sqlWhere);
  366. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  367. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  368. #region 处理所属部门
  369. /*
  370. * 1.sq 和 gyy 等显示 市场部
  371. * 2.王鸽和主管及张总还有管理员号统一国交部
  372. * 2-1. 4 管理员 ,21 张海麟
  373. */
  374. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  375. List<int> userIds1 = new List<int>() { 4, 21 };
  376. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  377. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  378. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  379. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  380. .ToList();
  381. foreach (var item in _DelegationList)
  382. {
  383. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  384. }
  385. #endregion
  386. var _view = new
  387. {
  388. PageFuncAuth = pageFunAuthView,
  389. Data = _DelegationList
  390. };
  391. return Ok(JsonView(true, "查询成功!", _view, total));
  392. }
  393. else
  394. {
  395. return Ok(JsonView(false, "查询失败"));
  396. }
  397. }
  398. /// <summary>
  399. /// 团组列表
  400. /// </summary>
  401. /// <returns></returns>
  402. [HttpPost]
  403. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  404. {
  405. #region 参数验证
  406. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  407. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  408. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  409. #region 页面操作权限验证
  410. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  411. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  412. #endregion
  413. #endregion
  414. if (dto.PortType != 1 && dto.PortType != 2)
  415. {
  416. return Ok(JsonView(false, "查询失败!"));
  417. }
  418. string orderbyStr = "order by gdi.CreateTime Desc";
  419. string sqlWhere = string.Empty;
  420. if (dto.IsSure == 0) //未完成
  421. {
  422. sqlWhere += string.Format(@" And IsSure = 0");
  423. }
  424. else if (dto.IsSure == 1) //已完成
  425. {
  426. sqlWhere += string.Format(@" And IsSure = 1");
  427. }
  428. //团组类型
  429. if (dto.TeamDid > 0)
  430. {
  431. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  432. }
  433. //团组名称
  434. if (!string.IsNullOrEmpty(dto.TeamName))
  435. {
  436. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  437. }
  438. //客户名称
  439. if (!string.IsNullOrEmpty(dto.ClientName))
  440. {
  441. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  442. }
  443. //客户单位
  444. if (!string.IsNullOrEmpty(dto.ClientUnit))
  445. {
  446. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  447. }
  448. //出访时间
  449. if (!string.IsNullOrEmpty(dto.visitDataTime))
  450. {
  451. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  452. orderbyStr = "order by gdi.VisitDate";
  453. }
  454. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  455. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  456. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  457. JietuanOperator,IsSure,CreateTime
  458. From (
  459. Select row_number() over({0}) as Row_Number,
  460. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  461. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  462. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  463. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  464. From Grp_DelegationInfo gdi
  465. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  466. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  467. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  468. Where gdi.IsDel = 0 {1}
  469. ) temp ", orderbyStr, sqlWhere);
  470. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  471. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  472. #region 处理所属部门
  473. /*
  474. * 1.sq 和 gyy 等显示 市场部
  475. * 2.王鸽和主管及张总还有管理员号统一国交部
  476. * 2-1. 4 管理员 ,21 张海麟
  477. */
  478. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  479. List<int> userIds1 = new List<int>() { 4, 21 };
  480. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  481. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  482. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  483. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  484. .ToList();
  485. foreach (var item in _DelegationList)
  486. {
  487. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  488. }
  489. #endregion
  490. var _view = new
  491. {
  492. PageFuncAuth = pageFunAuthView,
  493. Data = _DelegationList
  494. };
  495. return Ok(JsonView(true, "查询成功!", _view, total));
  496. }
  497. /// <summary>
  498. /// 接团信息详情
  499. /// </summary>
  500. /// <param name="dto">团组info请求dto</param>
  501. /// <returns></returns>
  502. [HttpPost]
  503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  504. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  505. {
  506. var groupData = await _groupRepository.GetGroupInfo(dto);
  507. if (groupData.Code != 0)
  508. {
  509. return Ok(JsonView(false, groupData.Msg));
  510. }
  511. return Ok(JsonView(groupData.Data));
  512. }
  513. /// <summary>
  514. /// 接团信息 编辑添加
  515. /// 基础信息数据源
  516. /// </summary>
  517. /// <param name="dto"></param>
  518. /// <returns></returns>
  519. [HttpPost]
  520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  521. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  522. {
  523. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  524. if (groupData.Code != 0)
  525. {
  526. return Ok(JsonView(false, groupData.Msg));
  527. }
  528. return Ok(JsonView(groupData.Data));
  529. }
  530. /// <summary>
  531. /// 接团信息 操作(增改)
  532. /// </summary>
  533. /// <param name="dto"></param>
  534. /// <returns></returns>
  535. [HttpPost]
  536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  537. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  538. {
  539. try
  540. {
  541. var groupData = await _groupRepository.GroupOperation(dto);
  542. if (groupData.Code != 0)
  543. {
  544. return Ok(JsonView(false, groupData.Msg));
  545. }
  546. int diId = 0;
  547. //添加时 默认加入团组汇率
  548. if (dto.Status == 1) //添加
  549. {
  550. diId = groupData.Data;
  551. //添加默认币种
  552. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  553. //默认分配权限
  554. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  555. //消息提示 王鸽 主管号
  556. List<int> _managerIds = new List<int>() { 22, 32 };
  557. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  558. if (userIds.Count > 0)
  559. {
  560. userIds.Add(208);
  561. //创建团组管控
  562. GroupStepForDelegation.CreateWorkStep(diId);
  563. //发送消息
  564. string groupName = dto.TeamName;
  565. string createGroupUser = string.Empty;
  566. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  567. if (userInfo != null) createGroupUser = userInfo.CnName;
  568. string title = $"系统通知";
  569. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  570. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  571. }
  572. //默认创建倒推表
  573. await _invertedListRep._Create(dto.UserId, diId);
  574. }
  575. else if (dto.Status == 2)
  576. {
  577. diId = dto.Id;
  578. }
  579. return Ok(JsonView(true, "操作成功!", diId));
  580. }
  581. catch (Exception ex)
  582. {
  583. Logs("[response]" + JsonConvert.SerializeObject(dto));
  584. Logs(ex.Message);
  585. return Ok(JsonView(false, ex.Message));
  586. }
  587. }
  588. /// <summary>
  589. /// 接团流程操作(增改)
  590. /// 安卓端使用 建团时添加客户名单
  591. /// </summary>
  592. /// <param name="dto"></param>
  593. /// <returns></returns>
  594. [HttpPost]
  595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  596. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  597. {
  598. try
  599. {
  600. #region 参数验证
  601. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  602. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  603. #region 页面操作权限验证
  604. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  605. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  606. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  607. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  608. #endregion
  609. #endregion
  610. _sqlSugar.BeginTran();
  611. var _dto = new GroupOperationDto();
  612. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  613. var groupData = await _groupRepository.GroupOperation(_dto);
  614. if (groupData.Code != 0)
  615. {
  616. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  617. }
  618. int diId = 0;
  619. //添加时 默认加入团组汇率
  620. if (dto.Status == 1) //添加
  621. {
  622. diId = groupData.Data;
  623. //添加默认币种
  624. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  625. //默认分配权限
  626. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  627. //消息提示 王鸽 主管号
  628. List<int> _managerIds = new List<int>() { 22, 32 };
  629. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  630. if (userIds.Count > 0)
  631. {
  632. userIds.Add(208);
  633. //创建团组管控
  634. GroupStepForDelegation.CreateWorkStep(diId);
  635. //发送消息
  636. string groupName = dto.TeamName;
  637. string createGroupUser = string.Empty;
  638. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  639. if (userInfo != null) createGroupUser = userInfo.CnName;
  640. string title = $"系统通知";
  641. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  642. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  643. }
  644. }
  645. if (dto.Status == 2)
  646. {
  647. diId = dto.Id;
  648. if (diId == 0)
  649. {
  650. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  651. }
  652. }
  653. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  654. if (viewData.Code != 0)
  655. {
  656. _sqlSugar.RollbackTran();
  657. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  658. }
  659. _sqlSugar.CommitTran();
  660. return Ok(JsonView(true, "添加成功"));
  661. }
  662. catch (Exception ex)
  663. {
  664. _sqlSugar.RollbackTran();
  665. return Ok(JsonView(false, ex.Message));
  666. }
  667. }
  668. /// <summary>
  669. /// 接团信息 操作(删除)
  670. /// </summary>
  671. /// <param name="dto"></param>
  672. /// <returns></returns>
  673. [HttpPost]
  674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  675. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  676. {
  677. try
  678. {
  679. var groupData = await _groupRepository.GroupDel(dto);
  680. if (groupData.Code != 0)
  681. {
  682. return Ok(JsonView(false, groupData.Msg));
  683. }
  684. return Ok(JsonView(true));
  685. }
  686. catch (Exception ex)
  687. {
  688. Logs("[response]" + JsonConvert.SerializeObject(dto));
  689. Logs(ex.Message);
  690. return Ok(JsonView(false, ex.Message));
  691. }
  692. }
  693. /// <summary>
  694. /// 获取团组销售报价号
  695. /// 团组添加时 使用
  696. /// </summary>
  697. /// <returns></returns>
  698. [HttpPost]
  699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  700. public async Task<IActionResult> GetGroupSalesQuoteNo()
  701. {
  702. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  703. if (groupData.Code != 0)
  704. {
  705. return Ok(JsonView(false, groupData.Msg));
  706. }
  707. object salesQuoteNo = new
  708. {
  709. SalesQuoteNo = groupData.Data
  710. };
  711. return Ok(JsonView(salesQuoteNo));
  712. }
  713. /// <summary>
  714. /// 设置确认出团
  715. /// </summary>
  716. /// <param name="dto"></param>
  717. /// <returns></returns>
  718. [HttpPost]
  719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  720. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  721. {
  722. var groupData = await _groupRepository.ConfirmationGroup(dto);
  723. if (groupData.Code != 0)
  724. {
  725. return Ok(JsonView(false, groupData.Msg));
  726. }
  727. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  728. #region OA消息推送
  729. try
  730. {
  731. string groupName = groupInfo.TeamName;
  732. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  733. List<int> userIds = new List<int>();
  734. listUser.ForEach(s => userIds.Add(s.Id));
  735. string title = $"系统通知";
  736. string content = $"团组[{groupName}]已确认出团!";
  737. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  738. }
  739. catch (Exception ex)
  740. {
  741. }
  742. #endregion
  743. #region 应用推送
  744. try
  745. {
  746. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  747. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  748. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  749. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  750. {
  751. List<string> userList = new List<string>() { users.QiyeChatUserId };
  752. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  753. }
  754. }
  755. catch (Exception ex)
  756. {
  757. }
  758. #endregion
  759. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  760. return Ok(JsonView(true, "操作成功!", groupData.Data));
  761. }
  762. /// <summary>
  763. /// 获取团组名称data And 签证国别Data
  764. /// </summary>
  765. /// <param name="dto"></param>
  766. /// <returns></returns>
  767. [HttpPost]
  768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  769. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  770. {
  771. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  772. if (groupData.Code != 0)
  773. {
  774. return Ok(JsonView(false, groupData.Msg));
  775. }
  776. return Ok(JsonView(groupData.Data));
  777. }
  778. /// <summary>
  779. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  780. /// </summary>
  781. /// <returns></returns>
  782. [HttpPost]
  783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  784. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  785. {
  786. try
  787. {
  788. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  789. if (groupData.Code != 0)
  790. {
  791. return Ok(JsonView(false, groupData.Msg));
  792. }
  793. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  794. }
  795. catch (Exception ex)
  796. {
  797. return Ok(JsonView(false, "程序错误!"));
  798. throw;
  799. }
  800. }
  801. #endregion
  802. #region 团组&签证
  803. /// <summary>
  804. /// 根据团组Id获取签证客户信息List
  805. /// </summary>
  806. /// <param name="dto">请求dto</param>
  807. /// <returns></returns>
  808. [HttpPost]
  809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  810. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  811. {
  812. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  813. if (groupData.Code != 0)
  814. {
  815. return Ok(JsonView(false, groupData.Msg));
  816. }
  817. return Ok(JsonView(groupData.Data));
  818. }
  819. /// <summary>
  820. /// IOS获取团组签证拍照上传进度01(团组列表)
  821. /// </summary>
  822. /// <param name="dto">请求dto</param>
  823. /// <returns></returns>
  824. [HttpPost]
  825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  826. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  827. {
  828. if (dto == null)
  829. {
  830. return Ok(JsonView(false, "参数为空"));
  831. }
  832. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  833. return Ok(JsonView(visaList));
  834. }
  835. /// <summary>
  836. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  837. /// </summary>
  838. /// <returns></returns>
  839. [HttpPost]
  840. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  841. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  842. {
  843. if (dto == null)
  844. {
  845. return Ok(JsonView(false, "请求错误:"));
  846. }
  847. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  848. return Ok(JsonView(list));
  849. }
  850. /// <summary>
  851. /// IOS获取团组签证拍照上传进度03(相册)
  852. /// </summary>
  853. /// <returns></returns>
  854. [HttpPost]
  855. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  856. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  857. {
  858. if (dto == null)
  859. {
  860. return Ok(JsonView(false, "请求错误:"));
  861. }
  862. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  863. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  864. list.ForEach(s => s.url = url);
  865. return Ok(JsonView(list));
  866. }
  867. /// <summary>
  868. /// IOS获取团组签证拍照上传进度04(图片上传)
  869. /// </summary>
  870. /// <param name="dto"></param>
  871. /// <returns></returns>
  872. [HttpPost]
  873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  874. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  875. {
  876. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  877. //if (!string.IsNullOrEmpty(result))
  878. //{
  879. //}
  880. //else {
  881. // return Ok(JsonView(false, "上传失败"));
  882. //}
  883. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  884. int sucNum = 0;
  885. try
  886. {
  887. foreach (var item in dto.base64DataList)
  888. {
  889. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  890. string result = decodeBase64ToImage(item, imageName);
  891. if (!string.IsNullOrEmpty(result))
  892. {
  893. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  894. pic.CreateUserId = dto.CreateUserId;
  895. pic.PicName = imageName;
  896. pic.PicPath = result;
  897. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  898. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  899. if (insertResult > 0)
  900. {
  901. sucNum++;
  902. }
  903. }
  904. }
  905. }
  906. catch (Exception ex)
  907. {
  908. return Ok(JsonView(false, ex.Message));
  909. }
  910. string msg = string.Format(@"成功上传{0}张", sucNum);
  911. return Ok(JsonView(true, msg));
  912. }
  913. private string decodeBase64ToImage(string base64DataURL, string imgName)
  914. {
  915. string filename = "";//声明一个string类型的相对路径
  916. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  917. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  918. try//会有异常抛出,try,catch一下
  919. {
  920. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  921. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  922. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  923. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  924. //文件名称
  925. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  926. //上传的文件的路径
  927. string filePath = "";
  928. if (!Directory.Exists(fileDir))
  929. {
  930. Directory.CreateDirectory(fileDir);
  931. }
  932. //上传的文件的路径
  933. filePath = fileDir + filename;
  934. //string url = HttpRuntime.AppDomainAppPath.ToString();
  935. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  936. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  937. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  938. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  939. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  940. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  941. ms.Close();//关闭当前流,并释放所有与之关联的资源
  942. bitmap.Dispose();
  943. }
  944. catch (Exception e)
  945. {
  946. string massage = e.Message;
  947. Logs("IOS图片上传Error:" + massage);
  948. //filename = e.Message;
  949. }
  950. return filename;//返回相对路径
  951. }
  952. /// <summary>
  953. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  954. /// </summary>
  955. /// <param name="dto"></param>
  956. /// <returns></returns>
  957. [HttpPost]
  958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  959. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  960. {
  961. if (dto == null)
  962. {
  963. return Ok(JsonView(false, "请求错误:"));
  964. }
  965. string msg = "参数错误";
  966. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  967. {
  968. try
  969. {
  970. //_delegationVisaRep.BeginTran();
  971. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  972. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  973. .Where(s => s.Id == dto.visaProgressCustomerId)
  974. .ExecuteCommandAsync();
  975. if (updCount > 0 && dto.publishCode == 1)
  976. {
  977. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  978. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  979. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  980. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  981. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  982. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  983. if (groupData == null)
  984. {
  985. _delegationVisaRep.RollbackTran();
  986. }
  987. string title = string.Format(@"[签证进度更新]");
  988. string content = string.Format(@"测试文本");
  989. bool rst = await _message.AddMsg(new MessageDto()
  990. {
  991. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  992. IssuerId = dto.publisher,
  993. Title = title,
  994. Content = content,
  995. ReleaseTime = DateTime.Now,
  996. UIdList = new List<int> {
  997. 234
  998. }
  999. });
  1000. if (rst)
  1001. {
  1002. return Ok(JsonView(true, "发送通知成功"));
  1003. }
  1004. }
  1005. //_delegationVisaRep.CommitTran();
  1006. }
  1007. catch (Exception)
  1008. {
  1009. //_delegationVisaRep.RollbackTran();
  1010. }
  1011. }
  1012. return Ok(JsonView(true, msg));
  1013. }
  1014. #endregion
  1015. #region 团组任务分配
  1016. /// <summary>
  1017. /// 团组任务分配初始化
  1018. /// </summary>
  1019. /// <param name="dto"></param>
  1020. /// <returns></returns>
  1021. [HttpPost]
  1022. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1023. public async Task<IActionResult> GetTaskAssignmen()
  1024. {
  1025. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1026. if (groupData.Code != 0)
  1027. {
  1028. return Ok(JsonView(false, groupData.Msg));
  1029. }
  1030. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1031. }
  1032. /// <summary>
  1033. /// 团组任务分配查询
  1034. /// </summary>
  1035. /// <param name="dto"></param>
  1036. /// <returns></returns>
  1037. [HttpPost]
  1038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1039. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1040. {
  1041. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1042. if (groupData.Code != 0)
  1043. {
  1044. return Ok(JsonView(false, groupData.Msg));
  1045. }
  1046. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1047. }
  1048. /// <summary>
  1049. /// 团组任务分配操作
  1050. /// </summary>
  1051. /// <param name="dto"></param>
  1052. /// <returns></returns>
  1053. [HttpPost]
  1054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1055. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1056. {
  1057. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1058. if (groupData.Code != 0)
  1059. {
  1060. return Ok(JsonView(false, groupData.Msg));
  1061. }
  1062. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1063. }
  1064. #endregion
  1065. #region 团组费用审核
  1066. /// <summary>
  1067. /// 费用审核
  1068. /// 团组列表 Page
  1069. /// </summary>
  1070. /// <param name="_dto">团组列表请求dto</param>
  1071. /// <returns></returns>
  1072. [HttpPost]
  1073. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1074. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1075. {
  1076. #region 参数验证
  1077. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1078. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1079. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1080. #region 页面操作权限验证
  1081. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1082. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1083. #endregion
  1084. #endregion
  1085. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1086. {
  1087. string sqlWhere = string.Empty;
  1088. if (_dto.IsSure == 0) //未完成
  1089. {
  1090. sqlWhere += string.Format(@" And IsSure = 0");
  1091. }
  1092. else if (_dto.IsSure == 1) //已完成
  1093. {
  1094. sqlWhere += string.Format(@" And IsSure = 1");
  1095. }
  1096. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1097. {
  1098. string tj = _dto.SearchCriteria;
  1099. 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}%')",
  1100. tj, tj, tj, tj, tj);
  1101. }
  1102. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1103. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1104. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1105. From (
  1106. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1107. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1108. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1109. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1110. From Grp_DelegationInfo gdi
  1111. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1112. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1113. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1114. Where gdi.IsDel = 0 {0}
  1115. ) temp ", sqlWhere);
  1116. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1117. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1118. var _view = new
  1119. {
  1120. PageFuncAuth = pageFunAuthView,
  1121. Data = _DelegationList
  1122. };
  1123. return Ok(JsonView(true, "查询成功!", _view, total));
  1124. }
  1125. else
  1126. {
  1127. return Ok(JsonView(false, "查询失败"));
  1128. }
  1129. }
  1130. /// <summary>
  1131. /// 获取团组费用审核
  1132. /// </summary>
  1133. /// <param name="paras">参数Json字符串</param>
  1134. /// <returns></returns>
  1135. [HttpPost]
  1136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1137. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1138. {
  1139. try
  1140. {
  1141. #region 参数验证
  1142. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1143. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1144. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1145. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1146. #region 页面操作权限验证
  1147. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1148. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1149. #endregion
  1150. #endregion
  1151. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1152. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1153. #region 费用清单
  1154. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1155. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1156. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1157. List<Grp_CreditCardPayment> entityList = _groupRepository
  1158. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1159. .Where(exp.ToExpression())
  1160. .ToList();
  1161. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1162. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1163. /*
  1164. * 76://酒店预订
  1165. */
  1166. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1167. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1168. .ToListAsync();
  1169. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1170. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1171. .ToListAsync();
  1172. /*
  1173. * 79://车/导游地接
  1174. */
  1175. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1176. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1177. .ToListAsync();
  1178. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1179. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1180. .ToListAsync();
  1181. /*
  1182. * 80: //签证
  1183. */
  1184. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1185. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1186. .ToListAsync();
  1187. /*
  1188. *81: //邀请/公务活动
  1189. */
  1190. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1191. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1192. .ToListAsync();
  1193. /*
  1194. * 82: //团组客户保险
  1195. */
  1196. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1197. /*
  1198. * Lable = 85 机票预订
  1199. */
  1200. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1201. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1202. .ToListAsync();
  1203. /*
  1204. * 85 机票预定
  1205. */
  1206. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1207. /*
  1208. * 98 其他款项
  1209. */
  1210. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1211. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1212. .ToListAsync();
  1213. /*
  1214. * 285:收款退还
  1215. */
  1216. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1217. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1218. .ToListAsync();
  1219. /*
  1220. * 1015: //超支费用
  1221. */
  1222. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1223. /*
  1224. * 币种信息
  1225. */
  1226. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1227. /*
  1228. * 车/导游地接 费用类型
  1229. */
  1230. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1231. /*
  1232. * 车/导游地接 费用类型
  1233. */
  1234. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1235. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1236. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1237. /*
  1238. * 用户信息
  1239. */
  1240. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1241. /*
  1242. * 费用模块
  1243. */
  1244. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1245. string priceModule = string.Empty;
  1246. if (sdPriceName != null)
  1247. {
  1248. priceModule = sdPriceName.Name;
  1249. }
  1250. /*
  1251. * 处理详情数据
  1252. */
  1253. foreach (var entity in entityList)
  1254. {
  1255. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1256. _detail.Id = entity.Id;
  1257. _detail.PriceName = priceModule;
  1258. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1259. _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1260. /*
  1261. * 应付款金额
  1262. */
  1263. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1264. string PaymentCurrency_WaitPay = "Unknown";
  1265. string hotelCurrncyCode = "Unknown";
  1266. string hotelCurrncyName = "Unknown";
  1267. if (sdPaymentCurrency_WaitPay != null)
  1268. {
  1269. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1270. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1271. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1272. if (hotelCurrncyCode.Equals("CNY"))
  1273. {
  1274. entity.DayRate = 1.0000M;
  1275. }
  1276. }
  1277. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1278. /*
  1279. * 此次付款金额
  1280. */
  1281. decimal CurrPayStr = 0;
  1282. if (entity.PayPercentage == 0)
  1283. {
  1284. if (entity.PayThenMoney != 0)
  1285. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1286. }
  1287. else
  1288. {
  1289. if (entity.PayMoney != 0)
  1290. {
  1291. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1292. }
  1293. }
  1294. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1295. /*
  1296. * 剩余尾款
  1297. */
  1298. decimal BalanceStr = 0;
  1299. if (CurrPayStr != 0)
  1300. {
  1301. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1302. BalanceStr = 0;
  1303. else
  1304. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1305. }
  1306. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1307. /*
  1308. * Bus名称
  1309. */
  1310. _detail.BusName = "待增加";
  1311. /*
  1312. *费用所属
  1313. */
  1314. switch (entity.CTable)
  1315. {
  1316. case 76://酒店预订
  1317. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1318. if (hotelReservations != null)
  1319. {
  1320. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1321. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1322. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1323. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1324. /*
  1325. * 费用类型
  1326. * 1:房费
  1327. * 2:早餐
  1328. * 3:地税
  1329. * 4:城市税
  1330. * </summary>
  1331. */
  1332. //地税
  1333. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1334. if (governmentRentData != null)
  1335. {
  1336. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1337. governmentRentFee = governmentRentData.Price;
  1338. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1339. if (governmentRentCurrData != null)
  1340. {
  1341. governmentRentCode = governmentRentCurrData.Name;
  1342. governmentRentName = $"({governmentRentCurrData.Remark})";
  1343. }
  1344. }
  1345. //城市税
  1346. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1347. if (cityTaxData != null)
  1348. {
  1349. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1350. cityTaxFee = cityTaxData.Price;
  1351. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1352. if (cityTaxCurrData != null)
  1353. {
  1354. cityTaxCode = cityTaxCurrData.Name;
  1355. cityTaxName = $"({cityTaxCurrData.Remark})";
  1356. }
  1357. }
  1358. //酒店早餐
  1359. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1360. if (breakfastData != null)
  1361. {
  1362. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1363. breakfastFee = breakfastData.Price;
  1364. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1365. if (breakfastCurrData != null)
  1366. {
  1367. breakfastCode = breakfastCurrData.Name;
  1368. breakfastName = $"({breakfastCurrData.Remark})";
  1369. }
  1370. }
  1371. //房间费用
  1372. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1373. if (roomData != null)
  1374. {
  1375. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1376. _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1377. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1378. roomFee = roomData.Price;
  1379. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1380. if (roomCurrData != null)
  1381. {
  1382. roomCode = roomCurrData.Name;
  1383. roomName = $"({roomCurrData.Remark})";
  1384. }
  1385. }
  1386. _detail.PriceMsgContent = $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1387. $"房间说明: {hotelReservations.Remark} <br/>" +
  1388. $"房间费用: {roomFee.ToString("#0.00")} {roomCode} {roomName} 当时汇率{roomData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{roomBool}<br/>" +
  1389. $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率{breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/>" +
  1390. $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率{governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/>" +
  1391. $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率{cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1392. _detail.PriceNameContent = hotelReservations.HotelName;
  1393. }
  1394. break;
  1395. case 79://车/导游地接
  1396. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1397. if (touristGuideGroundReservations != null)
  1398. {
  1399. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1400. {
  1401. _detail.BusName = touristGuideGroundReservations.BusName;
  1402. }
  1403. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1404. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1405. //if (isInt)
  1406. //{
  1407. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1408. // if (cityInfo != null)
  1409. // {
  1410. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1411. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1412. // if (carFeeItem != null)
  1413. // {
  1414. // nameContent += $@"({carFeeItem.Name})";
  1415. // }
  1416. // _detail.PriceNameContent = nameContent;
  1417. // }
  1418. //}
  1419. //else
  1420. //{
  1421. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1422. //}
  1423. List<Grp_CarTouristGuideGroundReservationsContent> touristGuideGroundReservationsContents = _CarTouristGuideGroundReservationsContent
  1424. .Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1425. string priceMsg = string.Empty;
  1426. foreach (var item in touristGuideGroundReservationsContents)
  1427. {
  1428. string typeName = "Unknown";
  1429. string carCurrencyCode = "Unknown";
  1430. string carCurrencyName = "Unknown";
  1431. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1432. if (carTypeData != null) typeName = carTypeData.Name;
  1433. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1434. if (currencyData != null)
  1435. {
  1436. carCurrencyCode = currencyData.Name;
  1437. carCurrencyName = currencyData.Remark;
  1438. }
  1439. priceMsg += typeName + ":" + item.Price.ToString("#0.00") + " " + carCurrencyCode + "(" + carCurrencyName + ")<br/>" +
  1440. "明细:" + item.PriceContent + "<br/>" +
  1441. "备注:" + item.Remark + "<br/><br/>";
  1442. }
  1443. _detail.PriceMsgContent = priceMsg;
  1444. }
  1445. break;
  1446. case 80: //签证
  1447. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1448. if (visaInfo != null)
  1449. {
  1450. _detail.PriceNameContent = getClientNameStr(clientNameList, visaInfo.VisaClient);
  1451. _detail.PriceMsgContent = $"签证描述:{visaInfo.VisaDescription}<br/> 备注:{visaInfo.Remark}";
  1452. }
  1453. break;
  1454. case 81: //邀请/公务活动
  1455. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1456. if (_ioa != null)
  1457. {
  1458. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1459. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1460. sendCurrName = "Unknown", //快递费用币种 Name
  1461. sendCurrCode = "Unknown", //快递费用币种 Code
  1462. eventsCurrName = "Unknown", //公务活动费币种 Name
  1463. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1464. translateCurrName = "Unknown", //公务翻译费 Name
  1465. translateCurrCode = "Unknown"; //公务翻译费 Code
  1466. #region 处理费用币种
  1467. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1468. if (inviteCurrData != null)
  1469. {
  1470. inviteCurrName = inviteCurrData.Remark;
  1471. inviteCurrCode = inviteCurrData.Name;
  1472. }
  1473. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1474. if (sendCurrData != null)
  1475. {
  1476. sendCurrName = sendCurrData.Remark;
  1477. sendCurrCode = sendCurrData.Name;
  1478. }
  1479. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1480. if (eventsCurrData != null)
  1481. {
  1482. eventsCurrName = eventsCurrData.Remark;
  1483. eventsCurrCode = eventsCurrData.Name;
  1484. }
  1485. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1486. if (translateCurrData != null)
  1487. {
  1488. translateCurrName = translateCurrData.Remark;
  1489. translateCurrCode = translateCurrData.Name;
  1490. }
  1491. #endregion
  1492. _detail.PriceNameContent = _ioa.InviterArea;
  1493. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1494. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1495. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1496. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1497. $@"备注:" + _ioa.Remark + "<br/>";
  1498. }
  1499. break;
  1500. case 82: //团组客户保险
  1501. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1502. if (customers != null)
  1503. {
  1504. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1505. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1506. }
  1507. break;
  1508. case 85: //机票预订
  1509. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1510. if (jpRes != null)
  1511. {
  1512. string FlightsDescription = jpRes.FlightsDescription;
  1513. string PriceDescription = jpRes.PriceDescription;
  1514. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1515. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1516. }
  1517. break;
  1518. case 98://其他款项
  1519. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1520. if (gdpRes != null)
  1521. {
  1522. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1523. _detail.PriceNameContent = gdpRes.PriceName;
  1524. }
  1525. break;
  1526. case 285://收款退还
  1527. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1528. if (refundAndOtherMoney != null)
  1529. {
  1530. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1531. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1532. }
  1533. break;
  1534. case 751://酒店早餐
  1535. break;
  1536. case 1015://超支费用
  1537. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1538. if (groupExtraCost != null)
  1539. {
  1540. _detail.PriceNameContent = groupExtraCost.PriceName;
  1541. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1542. }
  1543. break;
  1544. default:
  1545. break;
  1546. }
  1547. /*
  1548. * 申请人
  1549. */
  1550. string operatorName = " - ";
  1551. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1552. if (_opUser != null)
  1553. {
  1554. operatorName = _opUser.CnName;
  1555. }
  1556. _detail.OperatorName = operatorName;
  1557. /*
  1558. * 审核人
  1559. */
  1560. string auditOperatorName = "Unknown";
  1561. if (entity.AuditGMOperate == 0)
  1562. auditOperatorName = " - ";
  1563. else if (entity.AuditGMOperate == 4)
  1564. auditOperatorName = "自动审核";
  1565. else
  1566. {
  1567. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1568. if (_adUser != null)
  1569. {
  1570. auditOperatorName = _adUser.CnName;
  1571. }
  1572. }
  1573. _detail.AuditOperatorName = auditOperatorName;
  1574. /*
  1575. * 超预算比例
  1576. */
  1577. string overBudgetStr = "";
  1578. if (entity.ExceedBudget == -1)
  1579. overBudgetStr = sdPriceName.Name + "尚无预算";
  1580. else if (entity.ExceedBudget == 0)
  1581. overBudgetStr = "未超预算";
  1582. else
  1583. overBudgetStr = entity.ExceedBudget.ToString("P");
  1584. _detail.OverBudget = overBudgetStr;
  1585. /*
  1586. * 费用总计
  1587. */
  1588. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1589. {
  1590. CurrencyId = entity.PaymentCurrency,
  1591. CurrencyName = PaymentCurrency_WaitPay,
  1592. AmountPayable = entity.PayMoney,
  1593. ThisPayment = CurrPayStr,
  1594. BalancePayment = BalanceStr,
  1595. AuditedFunds = CurrPayStr
  1596. });
  1597. _detail.IsAuditGM = entity.IsAuditGM;
  1598. detailList.Add(_detail);
  1599. }
  1600. #endregion
  1601. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1602. /*
  1603. * 下方描述处理
  1604. */
  1605. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1606. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1607. if (ccpCurrencyPrice != null)
  1608. {
  1609. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1610. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1611. }
  1612. else
  1613. {
  1614. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1615. }
  1616. string amountPayableStr = string.Format(@"应付款总金额: ");
  1617. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1618. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1619. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1620. foreach (var item in nonDuplicat)
  1621. {
  1622. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1623. if (strs.Count > 0)
  1624. {
  1625. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1626. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1627. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1628. //单独处理此次付款金额
  1629. if (item.CurrencyId == 836) //人民币
  1630. {
  1631. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1632. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1633. }
  1634. else
  1635. {
  1636. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1637. }
  1638. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1639. //单独处理已审核费用
  1640. if (item.CurrencyId == 836) //人民币
  1641. {
  1642. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1643. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1644. }
  1645. else
  1646. {
  1647. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1648. }
  1649. }
  1650. }
  1651. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1652. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1653. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1654. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1655. var _view1 = new
  1656. {
  1657. PageFuncAuth = pageFunAuthView,
  1658. Data = _view
  1659. };
  1660. return Ok(JsonView(_view1));
  1661. }
  1662. catch (Exception ex)
  1663. {
  1664. return Ok(JsonView(false, ex.Message));
  1665. }
  1666. }
  1667. /// <summary>
  1668. /// 费用审核
  1669. /// 修改团组费用审核状态
  1670. /// </summary>
  1671. /// <param name="_dto">参数Json字符串</param>
  1672. /// <returns></returns>
  1673. [HttpPost]
  1674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1675. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1676. {
  1677. #region 参数验证
  1678. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1679. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1680. #endregion
  1681. #region 页面操作权限验证
  1682. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1683. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1684. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1685. #endregion
  1686. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1687. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1688. DateTime dtNow = DateTime.Now;
  1689. _groupRepository.BeginTran();
  1690. int rst = 0;
  1691. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1692. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1693. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1694. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1695. List<dynamic> msgDatas = new List<dynamic>();
  1696. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1697. foreach (var item in idList)
  1698. {
  1699. int CreditId = int.Parse(item);
  1700. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1701. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1702. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1703. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1704. .Where(s => s.Id == CreditId)
  1705. .ExecuteCommandAsync();
  1706. if (result < 1)
  1707. {
  1708. rst = -1;
  1709. _groupRepository.RollbackTran();
  1710. return Ok(JsonView(false, "操作失败并回滚!"));
  1711. }
  1712. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1713. if (creditData != null)
  1714. {
  1715. #region 应用通知配置
  1716. try
  1717. {
  1718. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  1719. }
  1720. catch (Exception ex)
  1721. {
  1722. }
  1723. #endregion
  1724. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1725. string groupNameStr = string.Empty;
  1726. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1727. if (groupData != null) groupNameStr = groupData.TeamName;
  1728. string creditTypeStr = string.Empty;
  1729. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1730. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1731. string creditCurrency = string.Empty;
  1732. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1733. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1734. if (creditCurrency.Equals("CNY"))
  1735. {
  1736. creditData.DayRate = 1.0000M;
  1737. }
  1738. if (creditData.PayPercentage == 0.00M)
  1739. {
  1740. creditData.PayPercentage = 100M;
  1741. }
  1742. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1743. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1744. string msgContent = "";
  1745. if (creditCurrency.Equals("CNY"))
  1746. {
  1747. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1748. }
  1749. else
  1750. {
  1751. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1752. }
  1753. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1754. }
  1755. }
  1756. if (rst == 0)
  1757. {
  1758. _groupRepository.CommitTran();
  1759. foreach (var item in msgDatas)
  1760. {
  1761. //发送消息
  1762. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1763. }
  1764. #region 应用推送
  1765. try
  1766. {
  1767. foreach (var ccpId in dic_ccp_user.Keys)
  1768. {
  1769. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  1770. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  1771. }
  1772. }
  1773. catch (Exception)
  1774. {
  1775. }
  1776. #endregion
  1777. return Ok(JsonView(true, "操作成功!"));
  1778. }
  1779. return Ok(JsonView(false, "操作失败!"));
  1780. }
  1781. #endregion
  1782. #region 机票费用录入
  1783. /// <summary>
  1784. /// 机票录入当前登录人可操作团组
  1785. /// </summary>
  1786. /// <param name="dto"></param>
  1787. /// <returns></returns>
  1788. [HttpPost]
  1789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1790. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1791. {
  1792. try
  1793. {
  1794. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1795. if (groupData.Code != 0)
  1796. {
  1797. return Ok(JsonView(false, groupData.Msg));
  1798. }
  1799. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1800. }
  1801. catch (Exception ex)
  1802. {
  1803. return Ok(JsonView(false, "程序错误!"));
  1804. throw;
  1805. }
  1806. }
  1807. /// <summary>
  1808. /// 机票费用录入列表
  1809. /// </summary>
  1810. /// <param name="dto"></param>
  1811. /// <returns></returns>
  1812. [HttpPost]
  1813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1814. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1815. {
  1816. try
  1817. {
  1818. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1819. if (groupData.Code != 0)
  1820. {
  1821. return Ok(JsonView(false, groupData.Msg));
  1822. }
  1823. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1824. }
  1825. catch (Exception ex)
  1826. {
  1827. return Ok(JsonView(false, ex.Message));
  1828. throw;
  1829. }
  1830. }
  1831. /// <summary>
  1832. /// 根据id查询费用录入信息
  1833. /// </summary>
  1834. /// <param name="dto"></param>
  1835. /// <returns></returns>
  1836. [HttpPost]
  1837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1838. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1839. {
  1840. try
  1841. {
  1842. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1843. if (groupData.Code != 0)
  1844. {
  1845. return Ok(JsonView(false, groupData.Msg));
  1846. }
  1847. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1848. }
  1849. catch (Exception ex)
  1850. {
  1851. return Ok(JsonView(false, "程序错误!"));
  1852. throw;
  1853. }
  1854. }
  1855. /// <summary>
  1856. /// 机票费用录入操作(Status:1.新增,2.修改)
  1857. /// </summary>
  1858. /// <param name="dto"></param>
  1859. /// <returns></returns>
  1860. [HttpPost]
  1861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1862. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1863. {
  1864. try
  1865. {
  1866. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  1867. if (groupData.Code != 0)
  1868. {
  1869. return Ok(JsonView(false, groupData.Msg));
  1870. }
  1871. #region 应用推送
  1872. try
  1873. {
  1874. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  1875. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  1876. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  1877. }
  1878. catch (Exception ex)
  1879. {
  1880. }
  1881. #endregion
  1882. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1883. }
  1884. catch (Exception ex)
  1885. {
  1886. return Ok(JsonView(false, "程序错误!"));
  1887. throw;
  1888. }
  1889. }
  1890. /// <summary>
  1891. /// 根据舱位类型查询接团客户名单信息
  1892. /// </summary>
  1893. /// <param name="dto"></param>
  1894. /// <returns></returns>
  1895. [HttpPost]
  1896. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1897. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  1898. {
  1899. try
  1900. {
  1901. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  1902. if (crm_Groups.Count != 0)
  1903. {
  1904. List<dynamic> Customer = new List<dynamic>();
  1905. foreach (var item in crm_Groups)
  1906. {
  1907. var data = new
  1908. {
  1909. Id = item.Id,
  1910. Pinyin = item.Pinyin,
  1911. Name = item.LastName + item.FirstName
  1912. };
  1913. Customer.Add(data);
  1914. }
  1915. return Ok(JsonView(true, "查询成功!", Customer));
  1916. }
  1917. return Ok(JsonView(true, "暂无数据", crm_Groups));
  1918. }
  1919. catch (Exception ex)
  1920. {
  1921. return Ok(JsonView(false, "程序错误!"));
  1922. throw;
  1923. }
  1924. }
  1925. /// <summary>
  1926. /// 根据团号获取客户信息
  1927. /// </summary>
  1928. /// <param name="dto"></param>
  1929. /// <returns></returns>
  1930. [HttpPost]
  1931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1932. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  1933. {
  1934. var jw = JsonView(false);
  1935. if (dto.DIID < 1)
  1936. {
  1937. jw.Msg += "请输入正确的diid";
  1938. return Ok(jw);
  1939. }
  1940. var arr = getSimplClientList(dto.DIID);
  1941. jw = JsonView(true, "获取成功!", arr);
  1942. return Ok(jw);
  1943. }
  1944. private List<SimplClientInfo> getSimplClientList(int diId)
  1945. {
  1946. 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);
  1947. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  1948. return arr;
  1949. }
  1950. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  1951. {
  1952. string result = origin;
  1953. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  1954. {
  1955. string[] temparr = origin.Split(',');
  1956. string fistrStr = temparr[0];
  1957. int count = temparr.Count();
  1958. int tempId;
  1959. bool success = int.TryParse(fistrStr, out tempId);
  1960. if (success)
  1961. {
  1962. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  1963. if (tempInfo != null)
  1964. {
  1965. if (count > 1)
  1966. {
  1967. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  1968. }
  1969. else
  1970. {
  1971. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  1972. }
  1973. }
  1974. }
  1975. }
  1976. return result;
  1977. }
  1978. /// <summary>
  1979. /// 机票费用录入,删除
  1980. /// </summary>
  1981. /// <param name="dto"></param>
  1982. /// <returns></returns>
  1983. [HttpPost]
  1984. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1985. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  1986. {
  1987. try
  1988. {
  1989. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  1990. if (res)
  1991. {
  1992. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  1993. {
  1994. IsDel = 1,
  1995. DeleteUserId = dto.DeleteUserId,
  1996. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1997. }).ExecuteCommandAsync();
  1998. return Ok(JsonView(true, "删除成功!"));
  1999. }
  2000. return Ok(JsonView(false, "删除失败!"));
  2001. }
  2002. catch (Exception ex)
  2003. {
  2004. return Ok(JsonView(false, "程序错误!"));
  2005. throw;
  2006. }
  2007. }
  2008. /// <summary>
  2009. /// 导出机票录入报表
  2010. /// </summary>
  2011. /// <param name="dto"></param>
  2012. /// <returns></returns>
  2013. [HttpPost]
  2014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2015. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2016. {
  2017. try
  2018. {
  2019. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2020. if (groupData.Code != 0)
  2021. {
  2022. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2023. }
  2024. else
  2025. {
  2026. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2027. if (AirTicketReservations.Count != 0)
  2028. {
  2029. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2030. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2031. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2032. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2033. WorkbookDesigner designer = new WorkbookDesigner();
  2034. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2035. decimal countCost = 0;
  2036. foreach (var item in AirTicketReservations)
  2037. {
  2038. #region 处理客人姓名
  2039. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2040. item.ClientName = clientNames;
  2041. #endregion
  2042. if (item.BankType == "其他")
  2043. {
  2044. item.BankNo = "--";
  2045. }
  2046. else
  2047. {
  2048. if (!string.IsNullOrEmpty(item.BankType))
  2049. {
  2050. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2051. }
  2052. }
  2053. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2054. item.Price = System.Decimal.Round(item.Price, 2);
  2055. countCost += Convert.ToDecimal(item.Price);
  2056. }
  2057. designer.SetDataSource("Export", AirTicketReservations);
  2058. designer.SetDataSource("ExportDiCode", diCode);
  2059. designer.SetDataSource("ExportDiName", diName);
  2060. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2061. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2062. designer.Process();
  2063. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2064. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2065. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2066. return Ok(JsonView(true, "成功", url = rst));
  2067. }
  2068. else
  2069. {
  2070. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2071. }
  2072. }
  2073. }
  2074. catch (Exception ex)
  2075. {
  2076. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2077. throw;
  2078. }
  2079. }
  2080. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2081. /// <summary>
  2082. /// 行程单导出
  2083. /// </summary>
  2084. /// <param name="dto"></param>
  2085. /// <returns></returns>
  2086. [HttpPost]
  2087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2088. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2089. {
  2090. try
  2091. {
  2092. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2093. if (groupData.Code != 0)
  2094. {
  2095. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2096. }
  2097. else
  2098. {
  2099. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2100. if (dto.Language == "CN")
  2101. {
  2102. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2103. DocumentBuilder builder = new DocumentBuilder(doc);
  2104. int tableIndex = 0;//表格索引
  2105. //得到文档中的第一个表格
  2106. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2107. foreach (var item in _AirTicketReservations)
  2108. {
  2109. #region 处理固定数据
  2110. string[] FlightsCode = item.FlightsCode.Split('/');
  2111. if (FlightsCode.Length != 0)
  2112. {
  2113. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2114. if (_AirCompany != null)
  2115. {
  2116. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2117. }
  2118. else
  2119. {
  2120. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2121. }
  2122. }
  2123. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2124. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2125. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2126. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2127. string name = "";
  2128. foreach (string clientName in nameArray)
  2129. {
  2130. if (!name.Contains(clientName))
  2131. {
  2132. name += clientName + ",";
  2133. }
  2134. }
  2135. if (!string.IsNullOrWhiteSpace(name))
  2136. {
  2137. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2138. }
  2139. else
  2140. {
  2141. table.Range.Bookmarks["ClientName"].Text = "--";
  2142. }
  2143. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2144. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2145. table.Range.Bookmarks["JointTicket"].Text = "--";
  2146. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2147. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2148. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2149. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2150. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2151. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2152. #endregion
  2153. #region 循环数据处理
  2154. List<AirInfo> airs = new List<AirInfo>();
  2155. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2156. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2157. for (int i = 0; i < FlightsCode.Length; i++)
  2158. {
  2159. AirInfo air = new AirInfo();
  2160. string[] tempstr = DayArray[i]
  2161. .Replace("\r\n", string.Empty)
  2162. .Replace("\\r\\n", string.Empty)
  2163. .TrimStart().TrimEnd()
  2164. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2165. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2166. string starCity = "";
  2167. if (star_Three != null)
  2168. {
  2169. starCity = star_Three.AirPort;
  2170. }
  2171. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2172. string EndCity = "";
  2173. if (End_Three != null)
  2174. {
  2175. EndCity = End_Three.AirPort;
  2176. }
  2177. air.Destination = starCity + "/" + EndCity;
  2178. air.Flight = FlightsCode[i];
  2179. air.SeatingClass = item.CTypeName;
  2180. string dateTime = tempstr[2];
  2181. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2182. air.FlightDate = DateTemp;
  2183. air.DepartureTime = tempstr[5];
  2184. air.LandingTime = tempstr[6];
  2185. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2186. air.TicketStatus = "--";
  2187. air.Luggage = "--";
  2188. air.DepartureTerminal = "--";
  2189. air.LandingTerminal = "--";
  2190. airs.Add(air);
  2191. }
  2192. int row = 13;
  2193. for (int i = 0; i < airs.Count; i++)
  2194. {
  2195. if (airs.Count > 2)
  2196. {
  2197. for (int j = 0; j < airs.Count - 2; j++)
  2198. {
  2199. var CopyRow = table.Rows[12].Clone(true);
  2200. table.Rows.Add(CopyRow);
  2201. }
  2202. }
  2203. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2204. int index = 0;
  2205. foreach (PropertyInfo property in properties)
  2206. {
  2207. string value = property.GetValue(airs[i]).ToString();
  2208. Cell ishcel0 = table.Rows[row].Cells[index];
  2209. Paragraph p = new Paragraph(doc);
  2210. string s = value;
  2211. p.AppendChild(new Run(doc, s));
  2212. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2213. ishcel0.AppendChild(p);
  2214. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2215. index++;
  2216. }
  2217. row++;
  2218. }
  2219. #endregion
  2220. Paragraph lastParagraph = new Paragraph(doc);
  2221. //第一个表格末尾加段落
  2222. table.ParentNode.InsertAfter(lastParagraph, table);
  2223. //复制第一个表格
  2224. Table cloneTable = (Table)table.Clone(true);
  2225. //在文档末尾段落后面加入复制的表格
  2226. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2227. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2228. {
  2229. int rownewsIndex = 13;
  2230. for (int i = 0; i < 2; i++)
  2231. {
  2232. var CopyRow = table.Rows[12].Clone(true);
  2233. table.Rows.RemoveAt(13);
  2234. table.Rows.Add(CopyRow);
  2235. rownewsIndex++;
  2236. }
  2237. }
  2238. else
  2239. {
  2240. table.Rows.RemoveAt(12);
  2241. }
  2242. cloneTable.Rows.RemoveAt(12);
  2243. }
  2244. if (_AirTicketReservations.Count != 0)
  2245. {
  2246. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2247. if (FlightsCode.Length != 0)
  2248. {
  2249. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2250. if (_AirCompany != null)
  2251. {
  2252. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2253. }
  2254. else
  2255. {
  2256. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2257. }
  2258. }
  2259. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2260. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2261. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2262. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2263. string name = "";
  2264. foreach (string clientName in nameArray)
  2265. {
  2266. if (!name.Contains(clientName))
  2267. {
  2268. name += clientName + ",";
  2269. }
  2270. }
  2271. if (!string.IsNullOrWhiteSpace(name))
  2272. {
  2273. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2274. }
  2275. else
  2276. {
  2277. table.Range.Bookmarks["ClientName"].Text = "--";
  2278. }
  2279. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2280. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2281. table.Range.Bookmarks["JointTicket"].Text = "--";
  2282. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2283. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2284. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2285. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2286. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2287. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2288. }
  2289. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2290. //保存合并后的文档
  2291. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2292. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2293. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2294. return Ok(JsonView(true, "成功!", rst));
  2295. }
  2296. else
  2297. {
  2298. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2299. DocumentBuilder builder = new DocumentBuilder(doc);
  2300. int tableIndex = 0;//表格索引
  2301. //得到文档中的第一个表格
  2302. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2303. List<string> texts = new List<string>();
  2304. foreach (var item in _AirTicketReservations)
  2305. {
  2306. string[] FlightsCode = item.FlightsCode.Split('/');
  2307. if (FlightsCode.Length != 0)
  2308. {
  2309. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2310. if (_AirCompany != null)
  2311. {
  2312. if (!transDic.ContainsKey(_AirCompany.CnName))
  2313. {
  2314. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2315. }
  2316. }
  2317. else
  2318. {
  2319. if (!transDic.ContainsKey("--"))
  2320. {
  2321. transDic.Add("--", "--");
  2322. }
  2323. }
  2324. }
  2325. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2326. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2327. string name = "";
  2328. foreach (string clientName in nameArray)
  2329. {
  2330. name += clientName + ",";
  2331. }
  2332. if (!texts.Contains(name))
  2333. {
  2334. texts.Add(name);
  2335. }
  2336. List<AirInfo> airs = new List<AirInfo>();
  2337. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2338. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2339. for (int i = 0; i < FlightsCode.Length; i++)
  2340. {
  2341. AirInfo air = new AirInfo();
  2342. string[] tempstr = DayArray[i]
  2343. .Replace("\r\n", string.Empty)
  2344. .Replace("\\r\\n", string.Empty)
  2345. .TrimStart().TrimEnd()
  2346. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2347. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2348. if (star_Three != null)
  2349. {
  2350. if (!transDic.ContainsKey(star_Three.AirPort))
  2351. {
  2352. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2353. }
  2354. }
  2355. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2356. if (End_Three != null)
  2357. {
  2358. if (!transDic.ContainsKey(End_Three.AirPort))
  2359. {
  2360. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2361. }
  2362. }
  2363. if (!texts.Contains(item.CTypeName))
  2364. {
  2365. texts.Add(item.CTypeName);
  2366. }
  2367. }
  2368. }
  2369. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2370. if (transData.Count > 0)
  2371. {
  2372. foreach (TranslateResult item in transData)
  2373. {
  2374. if (!transDic.ContainsKey(item.Query))
  2375. {
  2376. transDic.Add(item.Query, item.Translation);
  2377. }
  2378. }
  2379. }
  2380. foreach (var item in _AirTicketReservations)
  2381. {
  2382. #region 处理固定数据
  2383. string[] FlightsCode = item.FlightsCode.Split('/');
  2384. if (FlightsCode.Length != 0)
  2385. {
  2386. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2387. if (_AirCompany != null)
  2388. {
  2389. string str = "--";
  2390. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2391. if (!string.IsNullOrEmpty(translateResult))
  2392. {
  2393. str = translateResult;
  2394. str = _airTicketResRep.Processing(str);
  2395. }
  2396. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2397. }
  2398. else
  2399. {
  2400. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2401. }
  2402. }
  2403. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2404. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2405. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2406. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2407. string names = "";
  2408. foreach (string clientName in nameArray)
  2409. {
  2410. names += clientName + ",";
  2411. }
  2412. if (!string.IsNullOrWhiteSpace(names))
  2413. {
  2414. string str = "--";
  2415. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2416. if (!string.IsNullOrEmpty(translateResult))
  2417. {
  2418. str = translateResult;
  2419. str = _airTicketResRep.Processing(str);
  2420. }
  2421. table.Range.Bookmarks["ClientName"].Text = str;
  2422. }
  2423. else
  2424. {
  2425. table.Range.Bookmarks["ClientName"].Text = "--";
  2426. }
  2427. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2428. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2429. table.Range.Bookmarks["JointTicket"].Text = "--";
  2430. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2431. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2432. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2433. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2434. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2435. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2436. #endregion
  2437. #region 循环数据处理
  2438. List<AirInfo> airs = new List<AirInfo>();
  2439. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2440. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2441. for (int i = 0; i < FlightsCode.Length; i++)
  2442. {
  2443. AirInfo air = new AirInfo();
  2444. string[] tempstr = DayArray[i]
  2445. .Replace("\r\n", string.Empty)
  2446. .Replace("\\r\\n", string.Empty)
  2447. .TrimStart().TrimEnd()
  2448. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2449. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2450. string starCity = "";
  2451. if (star_Three != null)
  2452. {
  2453. string str2 = "--";
  2454. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2455. if (!string.IsNullOrEmpty(translateResult2))
  2456. {
  2457. str2 = translateResult2;
  2458. str2 = _airTicketResRep.Processing(str2);
  2459. }
  2460. starCity = str2;
  2461. }
  2462. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2463. string EndCity = "";
  2464. if (End_Three != null)
  2465. {
  2466. string str1 = "--";
  2467. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2468. if (!string.IsNullOrEmpty(translateResult1))
  2469. {
  2470. str1 = translateResult1;
  2471. str1 = _airTicketResRep.Processing(str1);
  2472. }
  2473. EndCity = str1;
  2474. }
  2475. air.Destination = starCity + "/" + EndCity;
  2476. air.Flight = FlightsCode[i];
  2477. string str = "--";
  2478. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2479. if (!string.IsNullOrEmpty(translateResult))
  2480. {
  2481. str = translateResult;
  2482. str = _airTicketResRep.Processing(str);
  2483. }
  2484. air.SeatingClass = str;
  2485. string dateTime = tempstr[2];
  2486. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2487. air.FlightDate = DateTemp;
  2488. air.DepartureTime = tempstr[5];
  2489. air.LandingTime = tempstr[6];
  2490. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2491. air.TicketStatus = "--";
  2492. air.Luggage = "--";
  2493. air.DepartureTerminal = "--";
  2494. air.LandingTerminal = "--";
  2495. airs.Add(air);
  2496. }
  2497. int row = 13;
  2498. for (int i = 0; i < airs.Count; i++)
  2499. {
  2500. if (airs.Count > 2)
  2501. {
  2502. for (int j = 0; j < airs.Count - 2; j++)
  2503. {
  2504. var CopyRow = table.Rows[12].Clone(true);
  2505. table.Rows.Add(CopyRow);
  2506. }
  2507. }
  2508. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2509. int index = 0;
  2510. foreach (PropertyInfo property in properties)
  2511. {
  2512. string value = property.GetValue(airs[i]).ToString();
  2513. Cell ishcel0 = table.Rows[row].Cells[index];
  2514. Paragraph p = new Paragraph(doc);
  2515. string s = value;
  2516. p.AppendChild(new Run(doc, s));
  2517. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2518. ishcel0.AppendChild(p);
  2519. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2520. //ishcel0.CellFormat.VerticalAlignment=
  2521. index++;
  2522. }
  2523. row++;
  2524. }
  2525. #endregion
  2526. Paragraph lastParagraph = new Paragraph(doc);
  2527. //第一个表格末尾加段落
  2528. table.ParentNode.InsertAfter(lastParagraph, table);
  2529. //复制第一个表格
  2530. Table cloneTable = (Table)table.Clone(true);
  2531. //在文档末尾段落后面加入复制的表格
  2532. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2533. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2534. {
  2535. int rownewsIndex = 13;
  2536. for (int i = 0; i < 2; i++)
  2537. {
  2538. var CopyRow = table.Rows[12].Clone(true);
  2539. table.Rows.RemoveAt(13);
  2540. table.Rows.Add(CopyRow);
  2541. rownewsIndex++;
  2542. }
  2543. }
  2544. else
  2545. {
  2546. table.Rows.RemoveAt(12);
  2547. }
  2548. cloneTable.Rows.RemoveAt(12);
  2549. }
  2550. if (_AirTicketReservations.Count != 0)
  2551. {
  2552. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2553. if (FlightsCode.Length != 0)
  2554. {
  2555. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2556. if (_AirCompany != null)
  2557. {
  2558. string str = "--";
  2559. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2560. if (!string.IsNullOrEmpty(translateResult))
  2561. {
  2562. str = translateResult;
  2563. str = _airTicketResRep.Processing(str);
  2564. }
  2565. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2566. }
  2567. else
  2568. {
  2569. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2570. }
  2571. }
  2572. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2573. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2574. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2575. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2576. string names = "";
  2577. foreach (string clientName in nameArray)
  2578. {
  2579. names += clientName + ",";
  2580. }
  2581. if (!string.IsNullOrWhiteSpace(names))
  2582. {
  2583. string str = "--";
  2584. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2585. if (!string.IsNullOrEmpty(translateResult))
  2586. {
  2587. str = translateResult;
  2588. str = _airTicketResRep.Processing(str);
  2589. }
  2590. table.Range.Bookmarks["ClientName"].Text = str;
  2591. }
  2592. else
  2593. {
  2594. table.Range.Bookmarks["ClientName"].Text = "--";
  2595. }
  2596. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2597. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2598. table.Range.Bookmarks["JointTicket"].Text = "--";
  2599. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2600. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2601. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2602. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2603. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2604. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2605. }
  2606. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2607. //保存合并后的文档
  2608. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2609. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2610. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2611. return Ok(JsonView(true, "成功!", rst));
  2612. }
  2613. }
  2614. }
  2615. catch (Exception ex)
  2616. {
  2617. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2618. throw;
  2619. }
  2620. }
  2621. #endregion
  2622. #region 团组增减款项 --> 其他款项
  2623. /// <summary>
  2624. /// 团组增减款项下拉框绑定
  2625. /// </summary>
  2626. /// <param name="dto"></param>
  2627. /// <returns></returns>
  2628. [HttpPost]
  2629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2630. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2631. {
  2632. #region 参数验证
  2633. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2634. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2635. #endregion
  2636. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2637. }
  2638. /// <summary>
  2639. /// 根据团组Id查询团组增减款项
  2640. /// </summary>
  2641. /// <param name="dto"></param>
  2642. /// <returns></returns>
  2643. [HttpPost]
  2644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2645. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2646. {
  2647. #region 参数验证
  2648. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2649. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2650. #endregion
  2651. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2652. }
  2653. /// <summary>
  2654. /// 团组增减款项操作(Status:1.新增,2.修改)
  2655. /// </summary>
  2656. /// <param name="dto"></param>
  2657. /// <returns></returns>
  2658. [HttpPost]
  2659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2660. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2661. {
  2662. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2663. if (groupData.Code != 200)
  2664. {
  2665. return Ok(JsonView(false, groupData.Msg));
  2666. }
  2667. #region 应用推送
  2668. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2669. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2670. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2671. #endregion
  2672. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2673. }
  2674. /// <summary>
  2675. /// 团组增减款项操作 删除
  2676. /// </summary>
  2677. /// <param name="dto"></param>
  2678. /// <returns></returns>
  2679. [HttpPost]
  2680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2681. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2682. {
  2683. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  2684. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  2685. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  2686. if (res.Code == 0)
  2687. {
  2688. return Ok(JsonView(true, "删除成功!"));
  2689. }
  2690. return Ok(JsonView(false, "删除失败!"));
  2691. }
  2692. /// <summary>
  2693. /// 根据团组增减款项Id查询
  2694. /// </summary>
  2695. /// <param name="dto"></param>
  2696. /// <returns></returns>
  2697. [HttpPost]
  2698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2699. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2700. {
  2701. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  2702. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  2703. }
  2704. /// <summary>
  2705. /// 查询供应商名称
  2706. /// </summary>
  2707. /// <param name="dto"></param>
  2708. /// <returns></returns>
  2709. [HttpPost]
  2710. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  2711. {
  2712. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  2713. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  2714. ?? new List<Grp_DecreasePayments>();
  2715. dbResult = dbResult.Distinct(new
  2716. ProductComparer()).ToList();
  2717. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  2718. {
  2719. x.Id,
  2720. x.SupplierAddress,
  2721. x.SupplierArea,
  2722. x.SupplierContact,
  2723. x.SupplierContactNumber,
  2724. x.SupplierEmail,
  2725. x.SupplierName,
  2726. x.SupplierSocialAccount,
  2727. x.SupplierTypeId,
  2728. }).ToList());
  2729. return Ok(jw);
  2730. }
  2731. #endregion
  2732. #region 文件上传、删除
  2733. /// <summary>
  2734. /// region 文件上传 可以带参数
  2735. /// </summary>
  2736. /// <param name="file"></param>
  2737. /// <returns></returns>
  2738. [HttpPost]
  2739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2740. public async Task<IActionResult> UploadProject(IFormFile file)
  2741. {
  2742. try
  2743. {
  2744. var TypeName = Request.Headers["TypeName"].ToString();
  2745. if (file != null)
  2746. {
  2747. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2748. //文件名称
  2749. string projectFileName = file.FileName;
  2750. //上传的文件的路径
  2751. string filePath = "";
  2752. if (TypeName == "A")//A代表团组增减款项
  2753. {
  2754. if (!Directory.Exists(fileDir))
  2755. {
  2756. Directory.CreateDirectory(fileDir);
  2757. }
  2758. //上传的文件的路径
  2759. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2760. }
  2761. else if (TypeName == "B")//B代表商邀相关文件
  2762. {
  2763. if (!Directory.Exists(fileDir))
  2764. {
  2765. Directory.CreateDirectory(fileDir);
  2766. }
  2767. //上传的文件的路径
  2768. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2769. }
  2770. using (FileStream fs = System.IO.File.Create(filePath))
  2771. {
  2772. file.CopyTo(fs);
  2773. fs.Flush();
  2774. }
  2775. return Ok(JsonView(true, "上传成功!", projectFileName));
  2776. }
  2777. else
  2778. {
  2779. return Ok(JsonView(false, "上传失败!"));
  2780. }
  2781. }
  2782. catch (Exception ex)
  2783. {
  2784. return Ok(JsonView(false, "程序错误!"));
  2785. throw;
  2786. }
  2787. }
  2788. /// <summary>
  2789. /// 删除指定文件
  2790. /// </summary>
  2791. /// <param name="dto"></param>
  2792. /// <returns></returns>
  2793. [HttpPost]
  2794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2795. public async Task<IActionResult> DelFile(DelFileDto dto)
  2796. {
  2797. try
  2798. {
  2799. var TypeName = Request.Headers["TypeName"].ToString();
  2800. string filePath = "";
  2801. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2802. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2803. int id = 0;
  2804. if (TypeName == "A")
  2805. {
  2806. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2807. // 删除该文件
  2808. System.IO.File.Delete(filePath);
  2809. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2810. }
  2811. else if (TypeName == "B")
  2812. {
  2813. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2814. // 删除该文件
  2815. System.IO.File.Delete(filePath);
  2816. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2817. }
  2818. if (id != 0)
  2819. {
  2820. return Ok(JsonView(true, "成功!"));
  2821. }
  2822. else
  2823. {
  2824. return Ok(JsonView(false, "失败!"));
  2825. }
  2826. }
  2827. catch (Exception ex)
  2828. {
  2829. return Ok(JsonView(false, "程序错误!"));
  2830. throw;
  2831. }
  2832. }
  2833. #endregion
  2834. #region 商邀费用录入
  2835. /// <summary>
  2836. /// 根据团组Id查询商邀费用列表
  2837. /// </summary>
  2838. /// <param name="dto"></param>
  2839. /// <returns></returns>
  2840. [HttpPost]
  2841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2842. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2843. {
  2844. try
  2845. {
  2846. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2847. if (groupData.Code != 0)
  2848. {
  2849. return Ok(JsonView(false, groupData.Msg));
  2850. }
  2851. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2852. }
  2853. catch (Exception ex)
  2854. {
  2855. return Ok(JsonView(false, "程序错误!"));
  2856. throw;
  2857. }
  2858. }
  2859. //
  2860. /// <summary>
  2861. /// 商邀费用 Info Page 基础数据源
  2862. /// </summary>
  2863. /// <param name="dto"></param>
  2864. /// <returns></returns>
  2865. [HttpPost]
  2866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2867. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  2868. {
  2869. try
  2870. {
  2871. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  2872. if (groupData.Code != 0)
  2873. {
  2874. return Ok(JsonView(false, groupData.Msg));
  2875. }
  2876. return Ok(JsonView(true, "操作成功", groupData.Data));
  2877. }
  2878. catch (Exception ex)
  2879. {
  2880. return Ok(JsonView(false, ex.Message));
  2881. throw;
  2882. }
  2883. }
  2884. /// <summary>
  2885. /// 根据商邀费用ID查询C表和商邀费用数据
  2886. /// </summary>
  2887. /// <param name="dto"></param>
  2888. /// <returns></returns>
  2889. [HttpPost]
  2890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2891. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  2892. {
  2893. try
  2894. {
  2895. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  2896. if (groupData.Code != 0)
  2897. {
  2898. return Ok(JsonView(false, groupData.Msg));
  2899. }
  2900. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2901. }
  2902. catch (Exception ex)
  2903. {
  2904. return Ok(JsonView(false, ex.Message));
  2905. throw;
  2906. }
  2907. }
  2908. /// <summary>
  2909. /// 商邀费用录入操作(Status:1.新增,2.修改)
  2910. /// </summary>
  2911. /// <param name="dto"></param>
  2912. /// <returns></returns>
  2913. [HttpPost]
  2914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2915. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  2916. {
  2917. try
  2918. {
  2919. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  2920. if (groupData.Code != 0)
  2921. {
  2922. return Ok(JsonView(false, groupData.Msg));
  2923. }
  2924. #region 应用推送
  2925. try
  2926. {
  2927. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2928. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2929. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2930. }
  2931. catch (Exception ex)
  2932. {
  2933. }
  2934. #endregion
  2935. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2936. }
  2937. catch (Exception ex)
  2938. {
  2939. return Ok(JsonView(false, "程序错误!"));
  2940. throw;
  2941. }
  2942. }
  2943. /// <summary>
  2944. /// 商邀删除
  2945. /// </summary>
  2946. /// <param name="dto"></param>
  2947. /// <returns></returns>
  2948. [HttpPost]
  2949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2950. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  2951. {
  2952. try
  2953. {
  2954. _sqlSugar.BeginTran();
  2955. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  2956. .SetColumns(it => new Grp_InvitationOfficialActivities()
  2957. {
  2958. IsDel = 1,
  2959. DeleteUserId = dto.DeleteUserId,
  2960. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2961. })
  2962. .Where(it => it.Id == dto.Id)
  2963. .ExecuteCommand();
  2964. if (res1 > 0)
  2965. {
  2966. int _diId = 0;
  2967. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  2968. if (_ioaInfo != null)
  2969. {
  2970. _diId = _ioaInfo.DiId;
  2971. }
  2972. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  2973. .SetColumns(a => new Grp_CreditCardPayment()
  2974. {
  2975. IsDel = 1,
  2976. DeleteUserId = dto.DeleteUserId,
  2977. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2978. })
  2979. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  2980. .ExecuteCommand();
  2981. if (res2 > 0)
  2982. {
  2983. _sqlSugar.CommitTran();
  2984. return Ok(JsonView(true, "删除成功!"));
  2985. }
  2986. }
  2987. _sqlSugar.RollbackTran();
  2988. return Ok(JsonView(false, "删除失败"));
  2989. }
  2990. catch (Exception ex)
  2991. {
  2992. _sqlSugar.RollbackTran();
  2993. return Ok(JsonView(false, ex.Message));
  2994. }
  2995. }
  2996. #endregion
  2997. #region 团组英文资料
  2998. /// <summary>
  2999. /// 查询团组英文所有资料
  3000. /// </summary>
  3001. /// <param name="dto"></param>
  3002. /// <returns></returns>
  3003. [HttpPost]
  3004. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3005. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3006. {
  3007. try
  3008. {
  3009. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3010. if (groupData.Code != 0)
  3011. {
  3012. return Ok(JsonView(false, groupData.Msg));
  3013. }
  3014. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3015. }
  3016. catch (Exception ex)
  3017. {
  3018. return Ok(JsonView(false, "程序错误!"));
  3019. throw;
  3020. }
  3021. }
  3022. /// <summary>
  3023. /// 团组英文资料操作(Status:1.新增,2.修改)
  3024. /// </summary>
  3025. /// <param name="dto"></param>
  3026. /// <returns></returns>
  3027. [HttpPost]
  3028. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3029. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3030. {
  3031. try
  3032. {
  3033. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3034. if (groupData.Code != 0)
  3035. {
  3036. return Ok(JsonView(false, groupData.Msg));
  3037. }
  3038. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3039. }
  3040. catch (Exception ex)
  3041. {
  3042. return Ok(JsonView(false, "程序错误!"));
  3043. throw;
  3044. }
  3045. }
  3046. /// <summary>
  3047. /// 团组英文资料Id查询数据
  3048. /// </summary>
  3049. /// <param name="dto"></param>
  3050. /// <returns></returns>
  3051. [HttpPost]
  3052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3053. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3054. {
  3055. try
  3056. {
  3057. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3058. if (_DelegationEnData != null)
  3059. {
  3060. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3061. }
  3062. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3063. }
  3064. catch (Exception ex)
  3065. {
  3066. return Ok(JsonView(false, "程序错误!"));
  3067. throw;
  3068. }
  3069. }
  3070. /// <summary>
  3071. /// 团组英文资料删除
  3072. /// </summary>
  3073. /// <param name="dto"></param>
  3074. /// <returns></returns>
  3075. [HttpPost]
  3076. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3077. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3078. {
  3079. try
  3080. {
  3081. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3082. if (!res)
  3083. {
  3084. return Ok(JsonView(false, "删除失败"));
  3085. }
  3086. return Ok(JsonView(true, "删除成功!"));
  3087. }
  3088. catch (Exception ex)
  3089. {
  3090. return Ok(JsonView(false, "程序错误!"));
  3091. throw;
  3092. }
  3093. }
  3094. #endregion
  3095. #region 导出邀请函
  3096. /// <summary>
  3097. /// 导出邀请函页面初始化
  3098. /// </summary>
  3099. /// <param name="dto"></param>
  3100. /// <returns></returns>
  3101. [HttpPost]
  3102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3103. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3104. {
  3105. try
  3106. {
  3107. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3108. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3109. if (dto.DiId == 0)
  3110. {
  3111. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3112. }
  3113. else
  3114. {
  3115. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3116. }
  3117. return Ok(JsonView(true, "查询成功!", new
  3118. {
  3119. deleClient = crm_Deles,
  3120. delegations = grp_Delegations
  3121. }));
  3122. }
  3123. catch (Exception ex)
  3124. {
  3125. return Ok(JsonView(false, "程序错误!"));
  3126. throw;
  3127. }
  3128. }
  3129. /// <summary>
  3130. /// 导出邀请函
  3131. /// </summary>
  3132. /// <param name="dto"></param>
  3133. /// <returns></returns>
  3134. [HttpPost]
  3135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3136. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3137. {
  3138. #region 参数验证
  3139. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3140. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3141. #endregion
  3142. try
  3143. {
  3144. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3145. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3146. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3147. From Grp_TourClientList tcl
  3148. Left Join
  3149. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3150. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3151. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3152. From Crm_DeleClient dc
  3153. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3154. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3155. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3156. Where dc.IsDel = 0) temp
  3157. On temp.DcId =tcl.ClientId
  3158. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3159. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3160. List<string> texts = new List<string>();
  3161. if (datas.Count != 0)
  3162. {
  3163. foreach (TourClientListDetailsView item in datas)
  3164. {
  3165. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3166. {
  3167. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3168. }
  3169. else
  3170. {
  3171. string name = item.LastName + item.FirstName;
  3172. texts.Add(name);
  3173. }
  3174. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3175. {
  3176. if (!transDic.ContainsKey(item.Job))
  3177. {
  3178. texts.Add(item.Job);
  3179. }
  3180. }
  3181. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3182. {
  3183. texts.Add(item.CompanyFullName);
  3184. }
  3185. }
  3186. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3187. if (transData.Count > 0)
  3188. {
  3189. foreach (TranslateResult item in transData)
  3190. {
  3191. if (!transDic.ContainsKey(item.Query))
  3192. {
  3193. transDic.Add(item.Query, item.Translation);
  3194. }
  3195. }
  3196. }
  3197. List<GuestList> list = new List<GuestList>();
  3198. foreach (TourClientListDetailsView dele in datas)
  3199. {
  3200. GuestList guestList = new GuestList();
  3201. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3202. {
  3203. guestList.Name = dele.Pinyin;
  3204. }
  3205. else
  3206. {
  3207. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3208. guestList.Name = Name;
  3209. }
  3210. if (dele.Sex == 0)
  3211. {
  3212. guestList.Sex = "Male";
  3213. }
  3214. else if (dele.Sex == 1)
  3215. {
  3216. guestList.Sex = "Female";
  3217. }
  3218. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3219. if (!string.IsNullOrEmpty(dele.Job))
  3220. {
  3221. guestList.Job = dele.Job;
  3222. }
  3223. list.Add(guestList);
  3224. }
  3225. //载入模板
  3226. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3227. DocumentBuilder builder = new DocumentBuilder(doc);
  3228. //获取word里所有表格
  3229. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3230. //获取所填表格的序数
  3231. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3232. var rowStart = tableOne.Rows[0]; //获取第1行
  3233. //循环赋值
  3234. for (int i = 0; i < list.Count; i++)
  3235. {
  3236. builder.MoveToCell(0, i + 1, 0, 0);
  3237. builder.Write(list[i].Name.ToString());
  3238. builder.MoveToCell(0, i + 1, 1, 0);
  3239. builder.Write(list[i].Sex.ToString());
  3240. builder.MoveToCell(0, i + 1, 2, 0);
  3241. builder.Write(list[i].DOB.ToString());
  3242. builder.MoveToCell(0, i + 1, 3, 0);
  3243. builder.Write(list[i].Job.ToString());
  3244. }
  3245. //删除多余行
  3246. while (tableOne.Rows.Count > list.Count + 1)
  3247. {
  3248. tableOne.Rows.RemoveAt(list.Count + 1);
  3249. }
  3250. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3251. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3252. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3253. doc.Save(filePath);
  3254. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3255. return Ok(JsonView(true, "操作成功!", Url));
  3256. }
  3257. else
  3258. {
  3259. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3260. }
  3261. }
  3262. catch (Exception ex)
  3263. {
  3264. return Ok(JsonView(false, ex.Message));
  3265. throw;
  3266. }
  3267. }
  3268. #endregion
  3269. #region 团组经理模块 出入境费用
  3270. ///// <summary>
  3271. ///// 团组模块 - 出入境费用
  3272. ///// </summary>
  3273. ///// <returns></returns>
  3274. //[HttpPost]
  3275. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3276. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3277. //{
  3278. // try
  3279. // {
  3280. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3281. // if (data.Code != 0)
  3282. // {
  3283. // return Ok(JsonView(false, data.Msg));
  3284. // }
  3285. // return Ok(JsonView(true, "查询成功!"));
  3286. // }
  3287. // catch (Exception ex)
  3288. // {
  3289. // return Ok(JsonView(false, ex.Message));
  3290. // throw;
  3291. // }
  3292. //}
  3293. /// <summary>
  3294. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3295. /// </summary>
  3296. /// <returns></returns>
  3297. [HttpPost]
  3298. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3299. public async Task<IActionResult> SetDayAndCostAreaChange()
  3300. {
  3301. try
  3302. {
  3303. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3304. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3305. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3306. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3307. foreach (var item in unite) //处理交集数据
  3308. {
  3309. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3310. }
  3311. foreach (var item in merge) //处理差集数据
  3312. {
  3313. int nationalTravelFeeId = 0;
  3314. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3315. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3316. else
  3317. {
  3318. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3319. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3320. }
  3321. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3322. }
  3323. //只更新dayAndCost 的 nationalTravelFeeId;
  3324. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3325. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3326. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3327. }
  3328. catch (Exception ex)
  3329. {
  3330. return Ok(JsonView(false, ex.Message));
  3331. throw;
  3332. }
  3333. }
  3334. /// <summary>
  3335. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3336. /// </summary>
  3337. /// <returns></returns>
  3338. [HttpPost]
  3339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3340. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3341. {
  3342. try
  3343. {
  3344. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3345. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3346. //SetDataInfoView
  3347. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3348. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3349. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3350. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3351. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3352. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3353. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3354. //默认币种显示
  3355. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3356. {
  3357. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3358. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3359. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3360. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3361. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3362. };
  3363. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3364. if (_currencyRate.Count > 0)
  3365. {
  3366. foreach (var item in _currencyInfos)
  3367. {
  3368. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3369. if (rateInfo != null)
  3370. {
  3371. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3372. rate1 *= 1.03M;
  3373. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3374. }
  3375. }
  3376. }
  3377. return Ok(JsonView(true, "查询成功!", new
  3378. {
  3379. GroupNameData = groupNameData.Data,
  3380. CurrencyData = _CurrencyData,
  3381. WordTypeData = _WordTypeData,
  3382. ExcelTypeData = _ExcelTypeData,
  3383. CurrencyInit = _currencyInfos
  3384. }));
  3385. }
  3386. catch (Exception ex)
  3387. {
  3388. return Ok(JsonView(false, ex.Message));
  3389. throw;
  3390. }
  3391. }
  3392. /// <summary>
  3393. /// 团组模块 - 出入境费用
  3394. /// 实时汇率 tips
  3395. /// 签证费用 tips
  3396. /// </summary>
  3397. /// <returns></returns>
  3398. [HttpPost]
  3399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3400. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  3401. {
  3402. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  3403. //默认币种显示
  3404. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3405. {
  3406. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3407. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3408. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3409. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3410. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3411. };
  3412. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3413. List<dynamic> reteInfos = new List<dynamic>();
  3414. if (_currencyRate.Count > 0)
  3415. {
  3416. foreach (var item in _currencyInfos)
  3417. {
  3418. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3419. if (rateInfo != null)
  3420. {
  3421. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3422. decimal rate1 = item.Rate;
  3423. rate1 *= 1.03M;
  3424. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3425. reteInfos.Add(new
  3426. {
  3427. currCode = item.CurrencyCode,
  3428. currName = item.CurrencyName,
  3429. rate = rate2,
  3430. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3431. });
  3432. }
  3433. }
  3434. }
  3435. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  3436. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  3437. return Ok(JsonView(true, "查询成功!", new
  3438. {
  3439. //GroupNameData = groupNameData.Data,
  3440. visaData = visaData.Data,
  3441. airData = airData.Data,
  3442. reteInfos = reteInfos
  3443. }));
  3444. }
  3445. /// <summary>
  3446. /// 团组模块 - 出入境费用 - Info
  3447. /// </summary>
  3448. /// <returns></returns>
  3449. [HttpPost]
  3450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3451. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3452. {
  3453. try
  3454. {
  3455. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3456. if (data.Code != 0)
  3457. {
  3458. return Ok(JsonView(false, data.Msg));
  3459. }
  3460. return Ok(JsonView(true, "查询成功!", data.Data));
  3461. }
  3462. catch (Exception ex)
  3463. {
  3464. return Ok(JsonView(false, ex.Message));
  3465. }
  3466. }
  3467. /// <summary>
  3468. /// 团组模块 - 出入境费用 - Add And Update
  3469. /// </summary>
  3470. /// <returns></returns>
  3471. [HttpPost]
  3472. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3473. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3474. {
  3475. try
  3476. {
  3477. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3478. if (data.Code != 0)
  3479. {
  3480. return Ok(JsonView(false, data.Msg));
  3481. }
  3482. return Ok(JsonView(true, data.Msg, data.Data));
  3483. }
  3484. catch (Exception ex)
  3485. {
  3486. return Ok(JsonView(false, ex.Message));
  3487. }
  3488. }
  3489. /// <summary>
  3490. /// 团组模块 - 出入境费用 - File downlaod
  3491. /// </summary>
  3492. /// <param name="dto"></param>
  3493. /// <returns></returns>
  3494. [HttpPost]
  3495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3496. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  3497. {
  3498. try
  3499. {
  3500. if (dto.DiId < 1)
  3501. {
  3502. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  3503. }
  3504. if (dto.ExportType < 1)
  3505. {
  3506. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  3507. }
  3508. if (dto.SubTypeId < 1)
  3509. {
  3510. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  3511. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  3512. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  3513. 3 团组成员名单 1 团组成员名单"));
  3514. }
  3515. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3516. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  3517. if (_EnterExitCosts == null)
  3518. {
  3519. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  3520. }
  3521. //数据源
  3522. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  3523. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  3524. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  3525. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  3526. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3527. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  3528. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  3529. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  3530. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  3531. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  3532. .Select((tcl, dc, cc) => new
  3533. {
  3534. Name = dc.LastName + dc.FirstName,
  3535. Sex = dc.Sex,
  3536. Birthday = dc.BirthDay,
  3537. Company = cc.CompanyFullName,
  3538. Job = dc.Job
  3539. })
  3540. .ToList();
  3541. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3542. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  3543. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  3544. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  3545. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  3546. if (dto.ExportType == 1) //明细表
  3547. {
  3548. if (dto.SubTypeId == 1005) //1005(默认明细表)
  3549. {
  3550. //获取模板
  3551. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  3552. //载入模板
  3553. Document doc = new Document(tempPath);
  3554. DocumentBuilder builder = new DocumentBuilder(doc);
  3555. //利用键值对存放数据
  3556. Dictionary<string, string> dic = new Dictionary<string, string>();
  3557. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  3558. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  3559. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  3560. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  3561. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  3562. string row1_1 = "";
  3563. if (_EnterExitCosts.Visa > 0)
  3564. {
  3565. //insidePayTotal += _EnterExitCosts.Visa;
  3566. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  3567. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  3568. {
  3569. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  3570. }
  3571. }
  3572. string row1_2 = "";
  3573. if (_EnterExitCosts.YiMiao > 0)
  3574. {
  3575. //insidePayTotal += _EnterExitCosts.YiMiao;
  3576. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  3577. }
  3578. if (_EnterExitCosts.HeSuan > 0)
  3579. {
  3580. //insidePayTotal += _EnterExitCosts.HeSuan;
  3581. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  3582. }
  3583. if (_EnterExitCosts.Service > 0)
  3584. {
  3585. //insidePayTotal += _EnterExitCosts.Service;
  3586. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  3587. }
  3588. string row1_3 = "";
  3589. if (_EnterExitCosts.Safe > 0)
  3590. {
  3591. //insidePayTotal += _EnterExitCosts.Safe;
  3592. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  3593. }
  3594. if (_EnterExitCosts.Ticket > 0)
  3595. {
  3596. //insidePayTotal += _EnterExitCosts.Ticket;
  3597. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  3598. }
  3599. string row1 = "";
  3600. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  3601. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  3602. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  3603. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  3604. dic.Add("Row1Str", row1);
  3605. dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  3606. dic.Add("OutsaideGW", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
  3607. dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3608. dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
  3609. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3610. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  3611. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  3612. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  3613. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  3614. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  3615. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
  3616. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsaideGWPay;
  3617. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  3618. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  3619. #region 填充word模板书签内容
  3620. foreach (var key in dic.Keys)
  3621. {
  3622. builder.MoveToBookmark(key);
  3623. builder.Write(dic[key]);
  3624. }
  3625. #endregion
  3626. #region 填充word表格内容
  3627. ////获读取指定表格方法二
  3628. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3629. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3630. for (int i = 0; i < dac1.Count; i++)
  3631. {
  3632. Grp_DayAndCost dac = dac1[i];
  3633. if (dac == null) continue;
  3634. builder.MoveToCell(0, i, 0, 0);
  3635. builder.Write("第" + dac.Days.ToString() + "晚:");
  3636. builder.MoveToCell(0, i, 1, 0);
  3637. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3638. //builder.Write(dac.Place == null ? "" : dac.Place);
  3639. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3640. builder.MoveToCell(0, i, 2, 0);
  3641. builder.Write("费用标准:");
  3642. string curr = "";
  3643. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3644. if (currData != null)
  3645. {
  3646. curr = currData.Name;
  3647. }
  3648. builder.MoveToCell(0, i, 3, 0);
  3649. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3650. builder.MoveToCell(0, i, 4, 0);
  3651. builder.Write("费用小计:");
  3652. builder.MoveToCell(0, i, 5, 0);
  3653. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3654. }
  3655. //删除多余行
  3656. while (table1.Rows.Count > dac1.Count)
  3657. {
  3658. table1.Rows.RemoveAt(dac1.Count);
  3659. }
  3660. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  3661. for (int i = 0; i < dac2.Count; i++)
  3662. {
  3663. Grp_DayAndCost dac = dac2[i];
  3664. if (dac == null) continue;
  3665. builder.MoveToCell(1, i, 0, 0);
  3666. builder.Write("第" + dac.Days.ToString() + "天:");
  3667. builder.MoveToCell(1, i, 1, 0);
  3668. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3669. builder.MoveToCell(1, i, 2, 0);
  3670. builder.Write("费用标准:");
  3671. string curr = "";
  3672. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3673. if (currData != null)
  3674. {
  3675. curr = currData.Name;
  3676. }
  3677. builder.MoveToCell(1, i, 3, 0);
  3678. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3679. builder.MoveToCell(1, i, 4, 0);
  3680. builder.Write("费用小计:");
  3681. builder.MoveToCell(1, i, 5, 0);
  3682. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3683. }
  3684. //删除多余行
  3685. while (table2.Rows.Count > dac2.Count)
  3686. {
  3687. table2.Rows.RemoveAt(dac2.Count);
  3688. }
  3689. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  3690. for (int i = 0; i < dac3.Count; i++)
  3691. {
  3692. Grp_DayAndCost dac = dac3[i];
  3693. if (dac == null) continue;
  3694. builder.MoveToCell(2, i, 0, 0);
  3695. builder.Write("第" + dac.Days.ToString() + "天:");
  3696. builder.MoveToCell(2, i, 1, 0);
  3697. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3698. builder.MoveToCell(2, i, 2, 0);
  3699. builder.Write("费用标准:");
  3700. string curr = "";
  3701. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3702. if (currData != null)
  3703. {
  3704. curr = currData.Name;
  3705. }
  3706. builder.MoveToCell(2, i, 3, 0);
  3707. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3708. builder.MoveToCell(2, i, 4, 0);
  3709. builder.Write("费用小计:");
  3710. builder.MoveToCell(2, i, 5, 0);
  3711. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3712. }
  3713. //删除多余行
  3714. while (table3.Rows.Count > dac3.Count)
  3715. {
  3716. table3.Rows.RemoveAt(dac3.Count);
  3717. }
  3718. #endregion
  3719. //文件名
  3720. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  3721. AsposeHelper.removewatermark_v2180();
  3722. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3723. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3724. return Ok(JsonView(true, "成功", new { Url = url }));
  3725. }
  3726. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  3727. {
  3728. //获取模板
  3729. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  3730. //载入模板
  3731. Document doc = new Document(tempPath);
  3732. DocumentBuilder builder = new DocumentBuilder(doc);
  3733. Dictionary<string, string> dic = new Dictionary<string, string>();
  3734. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3735. {
  3736. List<string> list = new List<string>();
  3737. try
  3738. {
  3739. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3740. foreach (var item in spilitArr)
  3741. {
  3742. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3743. var depCode = spDotandEmpty[2].Substring(0, 3);
  3744. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3745. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  3746. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  3747. list.Add(depName);
  3748. list.Add(arrName);
  3749. }
  3750. list = list.Distinct().ToList();
  3751. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3752. }
  3753. catch (Exception)
  3754. {
  3755. dic.Add("ReturnCode", "行程录入不正确!");
  3756. }
  3757. }
  3758. else
  3759. {
  3760. dic.Add("ReturnCode", "未录入行程!");
  3761. }
  3762. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3763. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3764. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3765. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3766. {
  3767. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3768. dic.Add("Day", sp.Days.ToString());
  3769. }
  3770. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3771. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3772. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3773. //dic.Add("Names", Names);
  3774. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3775. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3776. decimal dac1totalPrice = 0.00M;
  3777. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  3778. foreach (var dac in dac1)
  3779. {
  3780. if (dac.SubTotal == 0.00M)
  3781. {
  3782. continue;
  3783. }
  3784. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3785. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3786. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3787. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3788. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3789. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3790. builder.Write(currency);//币种
  3791. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3792. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3793. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3794. builder.Write("");//人数
  3795. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3796. builder.Write("");//天数
  3797. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3798. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3799. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3800. decimal rate = 0.00M;
  3801. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3802. builder.Write(rate.ToString("#0.0000"));//汇率
  3803. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3804. decimal rbmPrice = dac.SubTotal;
  3805. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3806. accommodationStartIndex++;
  3807. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3808. }
  3809. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3810. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  3811. {
  3812. table1.Rows.RemoveAt(i - 1);
  3813. foodandotherStartIndex--;
  3814. }
  3815. if (dac2.Count == dac3.Count)//国家 币种 金额
  3816. {
  3817. for (int i = 0; i < dac2.Count; i++)
  3818. {
  3819. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3820. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3821. }
  3822. }
  3823. decimal dac2totalPrice = 0.00M;
  3824. foreach (var dac in dac2)
  3825. {
  3826. if (dac.SubTotal == 0)
  3827. {
  3828. continue;
  3829. }
  3830. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3831. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3832. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3833. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3834. builder.Write(currency);//币种
  3835. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  3836. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3837. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  3838. builder.Write("");//人数
  3839. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  3840. builder.Write("");//天数
  3841. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  3842. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3843. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  3844. decimal rate = 0.00M;
  3845. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3846. builder.Write(rate.ToString("#0.0000"));//汇率
  3847. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  3848. decimal rbmPrice = dac.SubTotal;
  3849. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3850. foodandotherStartIndex++;
  3851. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3852. }
  3853. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  3854. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  3855. {
  3856. table1.Rows.RemoveAt(i - 1);
  3857. }
  3858. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3859. string otherFeeStr = "";
  3860. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  3861. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  3862. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  3863. if (otherFeeStr.Length > 0)
  3864. {
  3865. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  3866. otherFeeStr = $"({otherFeeStr})";
  3867. dic.Add("OtherFeeStr", otherFeeStr);
  3868. }
  3869. //总计
  3870. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  3871. //国际旅费
  3872. string outsideJJ = "";
  3873. string allPriceJJ = "";
  3874. if (_EnterExitCosts.SumJJC == 1)
  3875. {
  3876. outsideJJ = string.Format(@"经济舱:{0} 元/人", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3877. allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  3878. }
  3879. string outsideGW = "";
  3880. string allPriceGW = "";
  3881. if (_EnterExitCosts.SumGWC == 1)
  3882. {
  3883. outsideGW = string.Format(@"公务舱:{0} 元/人", _EnterExitCosts.AirGW.ToString("#0.00"));
  3884. allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  3885. }
  3886. if (_EnterExitCosts.SumJJC == 1 || _EnterExitCosts.SumGWC == 1)
  3887. {
  3888. string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
  3889. dic.Add("InTravelPrice", InTravelPriceStr);
  3890. string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
  3891. dic.Add("FinalSumPrice", FinalSumPriceStr);
  3892. }
  3893. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  3894. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  3895. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  3896. foreach (var key in dic.Keys)
  3897. {
  3898. builder.MoveToBookmark(key);
  3899. builder.Write(dic[key]);
  3900. }
  3901. //模板文件名
  3902. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  3903. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3904. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3905. return Ok(JsonView(true, "成功", new { Url = url }));
  3906. }
  3907. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  3908. {
  3909. //获取模板
  3910. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  3911. //载入模板
  3912. WorkbookDesigner designer = new WorkbookDesigner();
  3913. designer.Workbook = new Workbook(tempPath);
  3914. Dictionary<string, string> dic = new Dictionary<string, string>();
  3915. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3916. {
  3917. List<string> list = new List<string>();
  3918. try
  3919. {
  3920. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3921. foreach (var item in spilitArr)
  3922. {
  3923. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3924. var depCode = spDotandEmpty[2].Substring(0, 3);
  3925. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3926. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  3927. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  3928. list.Add(depName);
  3929. list.Add(arrName);
  3930. }
  3931. list = list.Distinct().ToList();
  3932. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3933. }
  3934. catch (Exception)
  3935. {
  3936. dic.Add("ReturnCode", "行程录入不正确!");
  3937. }
  3938. }
  3939. else
  3940. {
  3941. dic.Add("ReturnCode", "未录入行程!");
  3942. }
  3943. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3944. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3945. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3946. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3947. {
  3948. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3949. dic.Add("Day", sp.Days.ToString());
  3950. }
  3951. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3952. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3953. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3954. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  3955. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  3956. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  3957. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  3958. designer.SetDataSource("Name", Names);
  3959. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  3960. designer.SetDataSource("Day", dic["Day"] + "天");
  3961. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  3962. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  3963. int startIndex = 10;
  3964. const int startIndexcopy = 10;
  3965. if (dac2.Count == dac3.Count)//国家 币种 金额
  3966. {
  3967. for (int i = 0; i < dac2.Count; i++)
  3968. {
  3969. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3970. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3971. }
  3972. }
  3973. DataTable dtdac1 = new DataTable();
  3974. List<string> place = new List<string>();
  3975. dtdac1.Columns.AddRange(new DataColumn[] {
  3976. new DataColumn(){ ColumnName = "city"},
  3977. new DataColumn(){ ColumnName = "curr"},
  3978. new DataColumn(){ ColumnName = "criterion"},
  3979. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3980. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3981. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  3982. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3983. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  3984. });
  3985. DataTable dtdac2 = new DataTable();
  3986. dtdac2.Columns.AddRange(new DataColumn[] {
  3987. new DataColumn(){ ColumnName = "city"},
  3988. new DataColumn(){ ColumnName = "curr"},
  3989. new DataColumn(){ ColumnName = "criterion"},
  3990. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3991. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3992. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  3993. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3994. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  3995. });
  3996. dtdac1.TableName = "tb1";
  3997. dtdac2.TableName = "tb2";
  3998. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  3999. foreach (var item in dac1)
  4000. {
  4001. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4002. if (place.Contains(item.Place))
  4003. {
  4004. continue;
  4005. }
  4006. DataRow row = dtdac1.NewRow();
  4007. row["city"] = item.Place;
  4008. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4009. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4010. row["curr"] = currency;
  4011. row["rate"] = rate.ToString("#0.0000");
  4012. row["criterion"] = item.Cost.ToString("#0.00");
  4013. row["number"] = 1;
  4014. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4015. //row["costRMB"] = rbmPrice;
  4016. dtdac1.Rows.Add(row);
  4017. place.Add(item.Place);
  4018. }
  4019. place = new List<string>();
  4020. foreach (var item in dac2)
  4021. {
  4022. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4023. if (place.Contains(item.Place))
  4024. {
  4025. continue;
  4026. }
  4027. DataRow row = dtdac2.NewRow();
  4028. row["city"] = item.Place;
  4029. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4030. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4031. row["curr"] = currency;
  4032. row["rate"] = rate.ToString("#0.0000");
  4033. row["criterion"] = item.Cost.ToString("#0.00");
  4034. row["number"] = 1;
  4035. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4036. //row["cost"] = item.SubTotal;
  4037. //row["costRMB"] = rbmPrice;
  4038. dtdac2.Rows.Add(row);
  4039. place.Add(item.Place);
  4040. //dac2totalPrice += rbmPrice;
  4041. }
  4042. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4043. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4044. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4045. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4046. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4047. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4048. string cell4Str = $" 4.国际旅费:经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人";
  4049. string cellStr = $" 5.其他费用(";
  4050. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4051. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4052. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4053. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4054. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4055. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4056. if (cellStr.Length > 8)
  4057. {
  4058. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4059. }
  4060. cellStr += ")";
  4061. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4062. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay + otherFee;
  4063. decimal pxFee = dac4.Sum(it => it.Cost);
  4064. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay;
  4065. string celllastStr1 = "";
  4066. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4067. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4068. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4069. celllastStr1 += $",国际旅费 元";
  4070. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4071. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4072. designer.SetDataSource("cell4Str", cell4Str);
  4073. designer.SetDataSource("cellStr", cellStr);
  4074. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4075. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  4076. designer.SetDataSource("celllastStr", celllastStr);
  4077. Workbook wb = designer.Workbook;
  4078. var sheet = wb.Worksheets[0];
  4079. //绑定datatable数据集
  4080. designer.SetDataSource(dtdac1);
  4081. designer.SetDataSource(dtdac2);
  4082. designer.Process();
  4083. var rowStart = dtdac1.Rows.Count;
  4084. while (rowStart > 0)
  4085. {
  4086. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4087. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4088. startIndex++;
  4089. rowStart--;
  4090. }
  4091. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4092. startIndex += 1; //总计行
  4093. rowStart = dtdac2.Rows.Count;
  4094. while (rowStart > 0)
  4095. {
  4096. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4097. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4098. startIndex++;
  4099. rowStart--;
  4100. }
  4101. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4102. wb.CalculateFormula(true);
  4103. //模板文件名
  4104. string strFileName = $"四川省商务厅出国经费财政先行审核表.xls";
  4105. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4106. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4107. return Ok(JsonView(true, "成功", new { Url = url }));
  4108. }
  4109. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4110. {
  4111. //获取模板
  4112. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4113. //载入模板
  4114. Document doc = new Document(tempPath);
  4115. DocumentBuilder builder = new DocumentBuilder(doc);
  4116. Dictionary<string, string> dic = new Dictionary<string, string>();
  4117. dic.Add("GroupName", _DelegationInfo.TeamName);
  4118. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4119. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4120. string missionLeaderJob = "";//负责人job
  4121. int groupNumber = 0; //团人数
  4122. if (DeleClientList.Count > 0)
  4123. {
  4124. missionLeader = DeleClientList[0]?.Name ?? "";
  4125. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4126. }
  4127. dic.Add("MissionLeader", missionLeader); //团负责人
  4128. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4129. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4130. #region MyRegion
  4131. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4132. //{
  4133. // List<string> list = new List<string>();
  4134. // try
  4135. // {
  4136. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4137. // foreach (var item in spilitArr)
  4138. // {
  4139. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4140. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4141. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4142. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4143. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4144. // list.Add(depName);
  4145. // list.Add(arrName);
  4146. // }
  4147. // list = list.Distinct().ToList();
  4148. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4149. // }
  4150. // catch (Exception)
  4151. // {
  4152. // dic.Add("ReturnCode", "行程录入不正确!");
  4153. // }
  4154. //}
  4155. //else
  4156. //{
  4157. // dic.Add("ReturnCode", "未录入行程!");
  4158. //}
  4159. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4160. dic.Add("ReturnCode", string.Join("、", countrys));
  4161. #endregion
  4162. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4163. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4164. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4165. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4166. //{
  4167. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4168. // dic.Add("Day", sp.Days.ToString());
  4169. //}
  4170. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4171. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4172. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4173. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4174. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4175. //培训人员名单
  4176. int cultivateRowIndex = 7;
  4177. foreach (var item in DeleClientList)
  4178. {
  4179. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4180. builder.Write(item.Name);
  4181. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4182. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4183. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4184. string birthDay = "";
  4185. if (item.Birthday != null)
  4186. {
  4187. DateTime dt = Convert.ToDateTime(item.Birthday);
  4188. birthDay = $"{dt.Year}.{dt.Month}";
  4189. }
  4190. builder.Write(birthDay);
  4191. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4192. builder.Write(item.Company);
  4193. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4194. builder.Write(item.Job);
  4195. cultivateRowIndex++;
  4196. }
  4197. //删除多余行
  4198. //cultivateRowIndex -= 2;
  4199. int delRows = 10 + 7 - cultivateRowIndex;
  4200. if (delRows > 0)
  4201. {
  4202. for (int i = 0; i < delRows; i++)
  4203. {
  4204. table1.Rows.RemoveAt(cultivateRowIndex);
  4205. //cultivateRowIndex++;
  4206. }
  4207. }
  4208. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4209. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4210. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4211. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4212. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4213. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4214. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4215. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4216. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4217. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4218. //其他费用
  4219. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4220. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4221. //其他费用合计
  4222. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4223. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4224. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4225. //公务舱合计
  4226. //国际旅费
  4227. string outsideJJ = "";
  4228. string allPriceJJ = "";
  4229. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  4230. {
  4231. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4232. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4233. }
  4234. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  4235. {
  4236. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  4237. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4238. }
  4239. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  4240. {
  4241. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  4242. dic.Add("AirFeeTotal", airFeeTotalStr);
  4243. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4244. dic.Add("FeeTotal", feeTotalStr);
  4245. }
  4246. foreach (var key in dic.Keys)
  4247. {
  4248. builder.MoveToBookmark(key);
  4249. builder.Write(dic[key]);
  4250. }
  4251. //模板文件名
  4252. string strFileName = $"{_DelegationInfo.TeamName}成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4253. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4254. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4255. return Ok(JsonView(true, "成功", new { Url = url }));
  4256. }
  4257. }
  4258. else if (dto.ExportType == 2) //表格
  4259. {
  4260. //利用键值对存放数据
  4261. Dictionary<string, string> dic = new Dictionary<string, string>();
  4262. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4263. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4264. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4265. dic.Add("Day", sp.Days.ToString());
  4266. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4267. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4268. {
  4269. //获取模板
  4270. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4271. //载入模板
  4272. Document doc = new Document(tempPath);
  4273. DocumentBuilder builder = new DocumentBuilder(doc);
  4274. dic.Add("TeamName", _DelegationInfo.TeamName);
  4275. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4276. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4277. string missionLeaderName = "",
  4278. missionLeaderJob = "";
  4279. if (DeleClientList.Count > 0)
  4280. {
  4281. missionLeaderName = DeleClientList[0].Name;
  4282. missionLeaderJob = DeleClientList[0].Job;
  4283. }
  4284. dic.Add("MissionLeaderName", missionLeaderName);
  4285. dic.Add("MissionLeaderJob", missionLeaderJob);
  4286. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4287. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4288. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4289. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4290. int rowCount = 10;//总人数行
  4291. int startRowIndex = 7; //起始行
  4292. for (int i = 0; i < DeleClientList.Count; i++)
  4293. {
  4294. builder.MoveToCell(0, startRowIndex, 0, 0);
  4295. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4296. builder.MoveToCell(0, startRowIndex, 1, 0);
  4297. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4298. builder.Write(sex);//性别
  4299. builder.MoveToCell(0, startRowIndex, 2, 0);
  4300. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4301. builder.MoveToCell(0, startRowIndex, 3, 0);
  4302. builder.Write(DeleClientList[i].Company);//工作单位
  4303. builder.MoveToCell(0, startRowIndex, 4, 0);
  4304. builder.Write(DeleClientList[i].Job);//职务及级别
  4305. builder.MoveToCell(0, startRowIndex, 5, 0);
  4306. builder.Write("");//人员属性
  4307. builder.MoveToCell(0, startRowIndex, 6, 0);
  4308. builder.Write("");//上次出国时间
  4309. startRowIndex++;
  4310. }
  4311. int nullRow = rowCount - DeleClientList.Count;//空行
  4312. for (int i = 0; i < nullRow; i++)
  4313. {
  4314. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4315. }
  4316. foreach (var key in dic.Keys)
  4317. {
  4318. builder.MoveToBookmark(key);
  4319. builder.Write(dic[key]);
  4320. }
  4321. //模板文件名
  4322. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4323. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4324. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4325. return Ok(JsonView(true, "成功", new { Url = url }));
  4326. }
  4327. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4328. {
  4329. //获取模板
  4330. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4331. //载入模板
  4332. Document doc = new Document(tempPath);
  4333. DocumentBuilder builder = new DocumentBuilder(doc);
  4334. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4335. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4336. dic.Add("Names", Names);
  4337. int accommodationRows = 12, foodandotherRows = 12;
  4338. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4339. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4340. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4341. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4342. int accommodationStartIndex = 6;
  4343. decimal dac1totalPrice = 0.00M;
  4344. foreach (var dac in dac1)
  4345. {
  4346. if (dac.SubTotal == 0)
  4347. {
  4348. continue;
  4349. }
  4350. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4351. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4352. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4353. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4354. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4355. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4356. builder.Write(currency);//币种
  4357. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4358. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4359. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4360. builder.Write("");//人数
  4361. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4362. builder.Write("");//天数
  4363. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4364. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4365. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4366. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4367. builder.Write(rate.ToString("#0.0000"));//汇率
  4368. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4369. decimal rbmPrice = rate * dac.SubTotal;
  4370. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4371. accommodationStartIndex++;
  4372. dac1totalPrice += rbmPrice;
  4373. }
  4374. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4375. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4376. builder.Write("小计");
  4377. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4378. builder.Write(dac1totalPrice.ToString("#0.00"));
  4379. accommodationStartIndex++;
  4380. int nullRow = accommodationRows - dac1.Count;
  4381. //删除空行
  4382. //if (nullRow > 0)
  4383. //{
  4384. // int rowIndex = accommodationStartIndex;
  4385. // for (int i = 0; i < nullRow; i++)
  4386. // {
  4387. // Row row = table1.Rows[rowIndex];
  4388. // row.Remove();
  4389. // rowIndex++;
  4390. // }
  4391. //}
  4392. if (dac2.Count == dac3.Count)//国家 币种 金额
  4393. {
  4394. for (int i = 0; i < dac2.Count; i++)
  4395. {
  4396. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4397. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4398. }
  4399. }
  4400. int foodandotherStartIndex = 19;//
  4401. decimal dac2totalPrice = 0.00M;
  4402. foreach (var dac in dac2)
  4403. {
  4404. if (dac.SubTotal == 0)
  4405. {
  4406. continue;
  4407. }
  4408. //foodandotherStartIndex = 12;
  4409. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4410. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4411. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4412. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4413. builder.Write(currency);//币种
  4414. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4415. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4416. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4417. builder.Write("");//人数
  4418. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4419. builder.Write("");//天数
  4420. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4421. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4422. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4423. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4424. builder.Write(rate.ToString("#0.0000"));//汇率
  4425. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4426. decimal rbmPrice = rate * dac.SubTotal;
  4427. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4428. foodandotherStartIndex++;
  4429. dac2totalPrice += rbmPrice;
  4430. }
  4431. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4432. //删除空行
  4433. if (dac2.Count < foodandotherRows)
  4434. {
  4435. //int nullRow = accommodationRows - dac2.Count;
  4436. //while (table2.Rows.Count > dac2.Count)
  4437. //{
  4438. // table2.Rows.RemoveAt(dac2.Count);
  4439. //}
  4440. }
  4441. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4442. string otherFeeStr = "";
  4443. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4444. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4445. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4446. if (otherFeeStr.Length > 0)
  4447. {
  4448. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4449. otherFeeStr = $"({otherFeeStr})";
  4450. dic.Add("OtherFeeStr", otherFeeStr);
  4451. }
  4452. foreach (var key in dic.Keys)
  4453. {
  4454. builder.MoveToBookmark(key);
  4455. builder.Write(dic[key]);
  4456. }
  4457. //模板文件名
  4458. string strFileName = $"省级单位出(境)经费报销单.docx";
  4459. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4460. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4461. return Ok(JsonView(true, "成功", new { Url = url }));
  4462. }
  4463. }
  4464. else if (dto.ExportType == 3)
  4465. {
  4466. if (dto.SubTypeId == 1) //团组成员名单
  4467. {
  4468. if (DeleClientList.Count < 1)
  4469. {
  4470. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  4471. }
  4472. //获取模板
  4473. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  4474. //载入模板
  4475. Document doc = new Document(tempPath);
  4476. DocumentBuilder builder = new DocumentBuilder(doc);
  4477. //获取word里所有表格
  4478. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4479. //获取所填表格的序数
  4480. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4481. var rowStart = tableOne.Rows[0]; //获取第1行
  4482. //循环赋值
  4483. for (int i = 0; i < DeleClientList.Count; i++)
  4484. {
  4485. builder.MoveToCell(0, i + 1, 0, 0);
  4486. builder.Write(DeleClientList[i].Name);
  4487. builder.MoveToCell(0, i + 1, 1, 0);
  4488. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4489. builder.Write(sex);
  4490. builder.MoveToCell(0, i + 1, 2, 0);
  4491. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  4492. builder.MoveToCell(0, i + 1, 3, 0);
  4493. builder.Write(DeleClientList[i].Company);
  4494. builder.MoveToCell(0, i + 1, 4, 0);
  4495. builder.Write(DeleClientList[i].Job);
  4496. }
  4497. //删除多余行
  4498. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  4499. {
  4500. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  4501. }
  4502. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  4503. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  4504. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  4505. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4506. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4507. return Ok(JsonView(true, "成功", new { Url = url }));
  4508. }
  4509. }
  4510. return Ok(JsonView(false, "操作失败!"));
  4511. }
  4512. catch (Exception ex)
  4513. {
  4514. return Ok(JsonView(false, ex.Message));
  4515. }
  4516. }
  4517. /// <summary>
  4518. /// 获取三公费用标准city
  4519. /// </summary>
  4520. /// <param name="placeData"></param>
  4521. /// <param name="nationalTravelFeeId"></param>
  4522. /// <returns></returns>
  4523. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  4524. {
  4525. string _city = string.Empty;
  4526. if (placeData.Count < 1) return _city;
  4527. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  4528. if (data == null) return _city;
  4529. string country = data.Country;
  4530. string city = data.City;
  4531. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  4532. else _city = city;
  4533. return _city;
  4534. }
  4535. /// <summary>
  4536. /// 团组模块 - 出入境费用 - 明细表导出
  4537. /// </summary>
  4538. /// <returns></returns>
  4539. [HttpPost]
  4540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4541. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  4542. {
  4543. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4544. if (data.Code != 0)
  4545. {
  4546. return Ok(JsonView(false, data.Msg));
  4547. }
  4548. return Ok(JsonView(true, data.Msg, data.Data));
  4549. }
  4550. /// <summary>
  4551. /// 团组模块 - 出入境费用 - 一键清空
  4552. /// </summary>
  4553. /// <returns></returns>
  4554. [HttpPost]
  4555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4556. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  4557. {
  4558. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4559. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  4560. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  4561. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  4562. if (_view.Code == 0)
  4563. {
  4564. return Ok(JsonView(true, "操作成功"));
  4565. }
  4566. return Ok(JsonView(false, "操作失败"));
  4567. }
  4568. /// <summary>
  4569. /// 团组模块 - 出入境费用 - 子项删除
  4570. /// </summary>
  4571. /// <returns></returns>
  4572. [HttpPost]
  4573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4574. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  4575. {
  4576. try
  4577. {
  4578. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  4579. if (data.Code != 0)
  4580. {
  4581. return Ok(JsonView(false, data.Msg));
  4582. }
  4583. return Ok(JsonView(true, "操作成功!", data.Data));
  4584. }
  4585. catch (Exception ex)
  4586. {
  4587. return Ok(JsonView(false, ex.Message));
  4588. }
  4589. }
  4590. /// <summary>
  4591. /// 团组模块 - 出入境国家费用标准 List
  4592. /// </summary>
  4593. /// <returns></returns>
  4594. [HttpPost]
  4595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4596. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  4597. {
  4598. try
  4599. {
  4600. Stopwatch sw = new Stopwatch();
  4601. sw.Start();
  4602. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  4603. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4604. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4605. Where gntf.Isdel = 0");
  4606. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  4607. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  4608. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  4609. //foreach (var item in nationalTravel)
  4610. //{
  4611. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  4612. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  4613. // if (otherData != null)
  4614. // {
  4615. // cityData.Remove(otherData);
  4616. // cityData.Add(otherData);
  4617. // }
  4618. // nationalTravelFeeData1.Add(new
  4619. // {
  4620. // Country = item.Country,
  4621. // CityData = cityData
  4622. // });
  4623. //}
  4624. sw.Stop();
  4625. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  4626. }
  4627. catch (Exception ex)
  4628. {
  4629. return Ok(JsonView(false, ex.Message));
  4630. throw;
  4631. }
  4632. }
  4633. /// <summary>
  4634. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  4635. /// </summary>
  4636. /// <returns></returns>
  4637. [HttpPost]
  4638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4639. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  4640. {
  4641. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  4642. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  4643. List<string> countryData = new List<string>();
  4644. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  4645. countryData = countryData.Distinct().ToList();
  4646. List<dynamic> dataSource = new List<dynamic>();
  4647. foreach (var item in countryData)
  4648. {
  4649. List<string> cityData1 = new List<string>();
  4650. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  4651. var countryData2 = new
  4652. {
  4653. CountryName = item,
  4654. CityData = cityData1
  4655. };
  4656. dataSource.Add(countryData2);
  4657. }
  4658. return Ok(JsonView(true, "查询成功!", dataSource));
  4659. }
  4660. /// <summary>
  4661. /// 团组模块 - 出入境国家费用标准 Page List
  4662. /// </summary>
  4663. /// <returns></returns>
  4664. [HttpPost]
  4665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4666. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  4667. {
  4668. int portId = dto.PortType;
  4669. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4670. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  4671. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  4672. string whereSql = string.Empty;
  4673. if (!string.IsNullOrEmpty(dto.Country))
  4674. {
  4675. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  4676. }
  4677. if (!string.IsNullOrEmpty(dto.City))
  4678. {
  4679. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  4680. }
  4681. string pageSql = string.Format(@"Select * From (
  4682. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  4683. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  4684. From Grp_NationalTravelFee gntf
  4685. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4686. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4687. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  4688. RefAsync<int> total = 0;
  4689. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  4690. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  4691. }
  4692. /// <summary>
  4693. /// 团组模块 - 出入境国家费用标准 根据城市查询
  4694. /// </summary>
  4695. /// <returns></returns>
  4696. [HttpPost]
  4697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4698. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  4699. {
  4700. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  4701. int portId = dto.PortType;
  4702. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4703. string whereSql = string.Empty;
  4704. if (!string.IsNullOrEmpty(dto.Country))
  4705. {
  4706. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  4707. }
  4708. if (!string.IsNullOrEmpty(dto.City))
  4709. {
  4710. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  4711. }
  4712. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  4713. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  4714. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  4715. From Grp_NationalTravelFee gntf
  4716. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4717. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4718. Where gntf.Isdel = 0 {0} ", whereSql);
  4719. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  4720. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  4721. }
  4722. /// <summary>
  4723. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  4724. /// </summary>
  4725. /// <returns></returns>
  4726. [HttpPost]
  4727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4728. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  4729. {
  4730. try
  4731. {
  4732. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  4733. if (data.Code != 0)
  4734. {
  4735. return Ok(JsonView(false, data.Msg));
  4736. }
  4737. return Ok(JsonView(true, "操作成功!", data.Data));
  4738. }
  4739. catch (Exception ex)
  4740. {
  4741. return Ok(JsonView(false, ex.Message));
  4742. }
  4743. }
  4744. /// <summary>
  4745. /// 团组模块 - 出入境国家费用标准 - Del
  4746. /// </summary>
  4747. /// <returns></returns>
  4748. [HttpPost]
  4749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4750. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  4751. {
  4752. try
  4753. {
  4754. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  4755. {
  4756. Id = dto.Id,
  4757. DeleteUserId = dto.DeleteUserId,
  4758. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  4759. IsDel = 1
  4760. };
  4761. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  4762. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  4763. .WhereColumns(it => new { it.Id })
  4764. .ExecuteCommandAsync();
  4765. if (delStatus <= 0)
  4766. {
  4767. return Ok(JsonView(false, "删除失败!"));
  4768. }
  4769. return Ok(JsonView(true, "操作成功!"));
  4770. }
  4771. catch (Exception ex)
  4772. {
  4773. return Ok(JsonView(false, ex.Message));
  4774. }
  4775. }
  4776. #endregion
  4777. #region 签证费用录入
  4778. /// <summary>
  4779. /// 根据diid查询签证费用列表
  4780. /// </summary>
  4781. /// <param name="dto"></param>
  4782. /// <returns></returns>
  4783. [HttpPost]
  4784. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4785. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  4786. {
  4787. try
  4788. {
  4789. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  4790. if (groupData.Code != 0)
  4791. {
  4792. return Ok(JsonView(false, groupData.Msg));
  4793. }
  4794. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4795. }
  4796. catch (Exception ex)
  4797. {
  4798. return Ok(JsonView(false, ex.Message));
  4799. }
  4800. }
  4801. /// <summary>
  4802. /// 根据签证费用Id查询单条数据及c表数据
  4803. /// </summary>
  4804. /// <param name="dto"></param>
  4805. /// <returns></returns>
  4806. [HttpPost]
  4807. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4808. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  4809. {
  4810. try
  4811. {
  4812. Result groupData = await _visaPriceRep.PostVisaById(dto);
  4813. if (groupData.Code != 0)
  4814. {
  4815. return Ok(JsonView(false, groupData.Msg));
  4816. }
  4817. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4818. }
  4819. catch (Exception ex)
  4820. {
  4821. return Ok(JsonView(false, ex.Message));
  4822. }
  4823. }
  4824. /// <summary>
  4825. /// 签证费用删除
  4826. /// </summary>
  4827. /// <param name="dto"></param>
  4828. /// <returns></returns>
  4829. [HttpPost]
  4830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4831. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  4832. {
  4833. _sqlSugar.BeginTran();
  4834. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  4835. if (!res)
  4836. {
  4837. _sqlSugar.RollbackTran();
  4838. return Ok(JsonView(false, "删除失败"));
  4839. }
  4840. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4841. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  4842. .SetColumns(a => new Grp_CreditCardPayment()
  4843. {
  4844. IsDel = 1,
  4845. DeleteUserId = dto.DeleteUserId,
  4846. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4847. }).ExecuteCommand();
  4848. if (resSub < 1)
  4849. {
  4850. _sqlSugar.RollbackTran();
  4851. return Ok(JsonView(false, "删除失败"));
  4852. }
  4853. _sqlSugar.CommitTran();
  4854. return Ok(JsonView(true, "删除成功!"));
  4855. }
  4856. /// <summary>
  4857. /// 签证费用录入下拉框初始化
  4858. /// </summary>
  4859. /// <returns></returns>
  4860. [HttpPost]
  4861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4862. public async Task<IActionResult> VisaPriceAddSelect()
  4863. {
  4864. try
  4865. {
  4866. //支付方式
  4867. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  4868. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  4869. //币种
  4870. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  4871. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  4872. //乘客类型
  4873. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  4874. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  4875. //卡类型
  4876. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  4877. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  4878. var data = new
  4879. {
  4880. Payment = _Payment,
  4881. CurrencyList = _CurrencyList,
  4882. PassengerType = _PassengerType,
  4883. BankCard = _BankCard
  4884. };
  4885. return Ok(JsonView(true, "查询成功!", data));
  4886. }
  4887. catch (Exception ex)
  4888. {
  4889. return Ok(JsonView(false, "程序错误!"));
  4890. throw;
  4891. }
  4892. }
  4893. /// <summary>
  4894. /// 签证费用录入操作(Status:1.新增,2.修改)
  4895. /// </summary>
  4896. /// <param name="dto"></param>
  4897. /// <returns></returns>
  4898. [HttpPost]
  4899. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4900. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  4901. {
  4902. try
  4903. {
  4904. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  4905. if (groupData.Code != 0)
  4906. {
  4907. return Ok(JsonView(false, groupData.Msg));
  4908. }
  4909. #region 应用推送
  4910. try
  4911. {
  4912. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4913. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4914. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4915. }
  4916. catch (Exception ex)
  4917. {
  4918. }
  4919. #endregion
  4920. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4921. }
  4922. catch (Exception ex)
  4923. {
  4924. return Ok(JsonView(false, ex.Message));
  4925. }
  4926. }
  4927. #endregion
  4928. #region op费用录入
  4929. /// <summary>
  4930. /// 根据diid查询op费用列表
  4931. /// </summary>
  4932. /// <param name="dto"></param>
  4933. /// <returns></returns>
  4934. [HttpPost]
  4935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4936. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  4937. {
  4938. try
  4939. {
  4940. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  4941. if (groupData.Code != 0)
  4942. {
  4943. return Ok(JsonView(false, groupData.Msg));
  4944. }
  4945. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4946. }
  4947. catch (Exception ex)
  4948. {
  4949. return Ok(JsonView(false, ex.Message));
  4950. }
  4951. }
  4952. /// <summary>
  4953. /// 根据op费用Id查询单条数据及c表数据
  4954. /// </summary>
  4955. /// <param name="dto"></param>
  4956. /// <returns></returns>
  4957. [HttpPost]
  4958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4959. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  4960. {
  4961. try
  4962. {
  4963. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  4964. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  4965. var data = new
  4966. {
  4967. CarTouristGuideGround = _groupData,
  4968. CreditCardPayment = _creditCardPayment
  4969. };
  4970. return Ok(JsonView(true, "查询成功!", data));
  4971. }
  4972. catch (Exception ex)
  4973. {
  4974. return Ok(JsonView(false, "程序错误!"));
  4975. }
  4976. }
  4977. /// <summary>
  4978. /// op费用删除
  4979. /// </summary>
  4980. /// <param name="dto"></param>
  4981. /// <returns></returns>
  4982. [HttpPost]
  4983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4984. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  4985. {
  4986. try
  4987. {
  4988. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4989. if (!res)
  4990. {
  4991. return Ok(JsonView(false, "删除失败"));
  4992. }
  4993. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  4994. {
  4995. IsDel = 1,
  4996. DeleteUserId = dto.DeleteUserId,
  4997. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4998. }).ExecuteCommandAsync();
  4999. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  5000. {
  5001. IsDel = 1,
  5002. DeleteUserId = dto.DeleteUserId,
  5003. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5004. }).ExecuteCommandAsync();
  5005. return Ok(JsonView(true, "删除成功!"));
  5006. }
  5007. catch (Exception ex)
  5008. {
  5009. return Ok(JsonView(false, "程序错误!"));
  5010. throw;
  5011. }
  5012. }
  5013. /// <summary>
  5014. /// op费用录入操作(Status:1.新增,2.修改)
  5015. /// </summary>
  5016. /// <param name="dto"></param>
  5017. /// <returns></returns>
  5018. [HttpPost]
  5019. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5020. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5021. {
  5022. try
  5023. {
  5024. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5025. if (groupData.Code != 0)
  5026. {
  5027. return Ok(JsonView(false, groupData.Msg));
  5028. }
  5029. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5030. }
  5031. catch (Exception ex)
  5032. {
  5033. return Ok(JsonView(false, ex.Message));
  5034. }
  5035. }
  5036. /// <summary>
  5037. /// 填写费用详细页面初始化绑定
  5038. /// </summary>
  5039. /// <param name="dto"></param>
  5040. /// <returns></returns>
  5041. [HttpPost]
  5042. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5043. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5044. {
  5045. try
  5046. {
  5047. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5048. if (groupData.Code != 0)
  5049. {
  5050. return Ok(JsonView(false, groupData.Msg));
  5051. }
  5052. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5053. }
  5054. catch (Exception ex)
  5055. {
  5056. return Ok(JsonView(false, ex.Message));
  5057. }
  5058. }
  5059. /// <summary>
  5060. /// 根据op费用Id查询详细数据
  5061. /// </summary>
  5062. /// <param name="dto"></param>
  5063. /// <returns></returns>
  5064. [HttpPost]
  5065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5066. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5067. {
  5068. try
  5069. {
  5070. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5071. if (groupData.Code != 0)
  5072. {
  5073. return Ok(JsonView(false, groupData.Msg));
  5074. }
  5075. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5076. }
  5077. catch (Exception ex)
  5078. {
  5079. return Ok(JsonView(false, ex.Message));
  5080. }
  5081. }
  5082. /// <summary>
  5083. /// OP费用录入填写详情
  5084. /// </summary>
  5085. /// <param name="dto"></param>
  5086. /// <returns></returns>
  5087. [HttpPost]
  5088. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5089. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5090. {
  5091. try
  5092. {
  5093. #region 参数校验
  5094. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  5095. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  5096. if (di == null) return Ok(JsonView(false, "团组错误!"));
  5097. #endregion
  5098. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5099. if (groupData.Code != 0)
  5100. {
  5101. return Ok(JsonView(false, groupData.Msg));
  5102. }
  5103. #region 应用推送
  5104. try
  5105. {
  5106. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5107. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5108. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5109. }
  5110. catch (Exception ex)
  5111. {
  5112. }
  5113. #endregion
  5114. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5115. }
  5116. catch (Exception ex)
  5117. {
  5118. return Ok(JsonView(false, ex.Message));
  5119. }
  5120. }
  5121. /// <summary>
  5122. /// 获取三公详细所有城市
  5123. /// </summary>
  5124. /// <returns></returns>
  5125. [HttpGet]
  5126. public IActionResult OpCarCityResult()
  5127. {
  5128. var jw = JsonView(false);
  5129. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5130. {
  5131. x.Id,
  5132. x.Country,
  5133. x.City,
  5134. }).ToList();
  5135. if (data.Count > 0)
  5136. {
  5137. jw = JsonView(true, "获取成功!", data);
  5138. }
  5139. else
  5140. {
  5141. jw.Msg = "城市数据为空!";
  5142. jw.Data = new string[0];
  5143. }
  5144. return Ok(jw);
  5145. }
  5146. /// <summary>
  5147. /// 导出地接费用明细
  5148. /// </summary>
  5149. /// <param name="dto"></param>
  5150. /// <returns></returns>
  5151. [HttpPost]
  5152. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5153. {
  5154. var jw = JsonView(false);
  5155. if (dto.Diid < 1)
  5156. {
  5157. jw.Msg = "请输入正确的diid!";
  5158. return Ok(jw);
  5159. }
  5160. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5161. if (group == null)
  5162. {
  5163. jw.Msg = "未找到团组信息!";
  5164. return Ok(jw);
  5165. }
  5166. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5167. if (localGuideArr.Count == 0)
  5168. {
  5169. jw.Msg = "该团组暂无地接信息!";
  5170. return Ok(jw);
  5171. }
  5172. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5173. var overspendSoure = new Dictionary<int, int>
  5174. {
  5175. { 91, 982 }, //车
  5176. { 92 , 1059} ,//导游
  5177. { 994 , 1073}, //翻译
  5178. { 988 , 1074 }, //早餐
  5179. { 93 , 1075 }, //午餐
  5180. { 989 , 1076 }, //晚餐
  5181. };
  5182. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5183. foreach (var groupArr in localGroup)
  5184. {
  5185. var keyValue = groupArr.Key;
  5186. if (int.TryParse(keyValue, out int cityid))
  5187. {
  5188. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5189. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5190. }
  5191. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5192. foreach (var item in groupArr)
  5193. {
  5194. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  5195. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  5196. new Grp_CarTouristGuideGroundReservationsContentExtend
  5197. {
  5198. Count = a.Count,
  5199. CreateTime = a.CreateTime,
  5200. CreateUserId = a.CreateUserId,
  5201. CTGGRId = a.CTGGRId,
  5202. Currency = a.Currency,
  5203. DatePrice = a.DatePrice,
  5204. DeleteTime = a.DeleteTime,
  5205. DeleteUserId = a.DeleteUserId,
  5206. DiId = a.DiId,
  5207. Id = a.Id,
  5208. IsDel = a.IsDel,
  5209. Price = a.Price,
  5210. PriceContent = a.PriceContent,
  5211. Remark = a.Remark,
  5212. SId = a.SId,
  5213. SidName = b.Name,
  5214. Units = a.Units,
  5215. }
  5216. ).ToList();
  5217. if (content.Count > 0)
  5218. {
  5219. contentArr.Add(content);
  5220. }
  5221. }
  5222. //open excel
  5223. //set excel
  5224. //save excel
  5225. try
  5226. {
  5227. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5228. IWorkbook workbook;
  5229. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5230. {
  5231. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5232. }
  5233. else
  5234. {
  5235. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5236. }
  5237. ISheet sheet = workbook.GetSheetAt(0);
  5238. var rowStartIndex = 2;
  5239. var clounmCount = 10;
  5240. var initStyleRow = sheet.GetRow(2);
  5241. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  5242. //var overspendArrDetail =
  5243. var existsId = new List<CarCompare>();
  5244. var lastElem = arr.Last();
  5245. var thisSid = -1;
  5246. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5247. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5248. {
  5249. Name = "未知币种!",
  5250. Remark = "未知币种!",
  5251. };
  5252. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5253. Action cloneRowFn = () =>
  5254. {
  5255. rowStartIndex++;
  5256. var cloneRow = sheet.CreateRow(rowStartIndex);
  5257. // 复制样式
  5258. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5259. {
  5260. ICell sourceCell = initStyleRow.GetCell(i);
  5261. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5262. // 确保单元格存在样式
  5263. if (sourceCell.CellStyle != null)
  5264. {
  5265. targetCell.CellStyle = sourceCell.CellStyle;
  5266. }
  5267. }
  5268. };
  5269. var mergeRow = () =>
  5270. {
  5271. for (int i = 2; i < sheet.LastRowNum; i++)
  5272. {
  5273. var row = sheet.GetRow(i);
  5274. var cellFirst = row.GetCell(0);
  5275. var thisIndex = i + 1;
  5276. while (thisIndex < sheet.LastRowNum)
  5277. {
  5278. var nextRow = sheet.GetRow(thisIndex);
  5279. var nextCellFirst = nextRow.GetCell(0);
  5280. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5281. {
  5282. thisIndex++;
  5283. }
  5284. else
  5285. {
  5286. break;
  5287. }
  5288. }
  5289. thisIndex--;
  5290. if (thisIndex != i)
  5291. {
  5292. //合并row
  5293. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5294. i, // 起始行索引(0-based)
  5295. thisIndex, // 结束行索引(0-based)
  5296. 0, // 起始列索引(0-based)
  5297. 0 // 结束列索引(0-based)
  5298. );
  5299. sheet.AddMergedRegion(cellRangeAddress);
  5300. i = thisIndex;
  5301. }
  5302. }
  5303. };
  5304. var chaoshiNumber = 0;
  5305. var totalNumber = 0.00M;
  5306. string lastStr = "";
  5307. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5308. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  5309. {
  5310. b.IsAuditGM,
  5311. x.Id,
  5312. x.Area,
  5313. b.PayPercentage,
  5314. b.PayMoney,
  5315. }).ToList();
  5316. string yesPayment = "", noPayment = "";
  5317. foreach (var item in queryCarArrByCityAndDiid)
  5318. {
  5319. if (item.IsAuditGM == 1)
  5320. {
  5321. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5322. }
  5323. else
  5324. {
  5325. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5326. }
  5327. }
  5328. lastStr = yesPayment + noPayment;
  5329. foreach (var item in arr)
  5330. {
  5331. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  5332. {
  5333. if (thisSid != item.SId)
  5334. {
  5335. if (thisSid == -1)
  5336. {
  5337. thisSid = item.SId;
  5338. }
  5339. else
  5340. {
  5341. //合并小计行
  5342. //创建合并区域的实例
  5343. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5344. rowStartIndex, // 起始行索引(0-based)
  5345. rowStartIndex, // 结束行索引(0-based)
  5346. 0, // 起始列索引(0-based)
  5347. 3 // 结束列索引(0-based)
  5348. );
  5349. sheet.AddMergedRegion(cellRangeAddress);
  5350. var CellStyle = workbook.CreateCellStyle();
  5351. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5352. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5353. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5354. for (int i = 0; i <= clounmCount; i++)
  5355. {
  5356. if (i > 6)
  5357. {
  5358. var CellStyle1 = workbook.CreateCellStyle();
  5359. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5360. IFont Font = workbook.CreateFont(); // 创建字体
  5361. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5362. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5363. CellStyle1.SetFont(Font);
  5364. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5365. }
  5366. else
  5367. {
  5368. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5369. }
  5370. }
  5371. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5372. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5373. //超时合计
  5374. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5375. //超时数
  5376. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5377. //超时合计费用
  5378. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5379. thisSid = item.SId;
  5380. cloneRowFn();
  5381. chaoshiNumber = 0;
  5382. totalNumber = 0;
  5383. }
  5384. }
  5385. IRow row = sheet.GetRow(rowStartIndex);
  5386. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5387. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  5388. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  5389. if (isOpenOverspendSoure)
  5390. {
  5391. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5392. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  5393. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  5394. }
  5395. for (int i = 0; i <= clounmCount; i++)
  5396. {
  5397. var cell = row.GetCell(i);
  5398. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  5399. if (cell == null)
  5400. {
  5401. cell = row.CreateCell(i);
  5402. }
  5403. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  5404. fontRed.CloneStyleFrom(cell.CellStyle);
  5405. IFont Font = workbook.CreateFont(); // 创建字体
  5406. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  5407. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5408. fontRed.SetFont(Font);
  5409. byte[] rgb = new byte[3] { 255, 242, 204 };
  5410. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  5411. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  5412. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  5413. if (workbook is XSSFWorkbook)
  5414. {
  5415. BackgroundColor255_242_204.FillForegroundColor = 0;
  5416. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  5417. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  5418. }
  5419. else
  5420. {
  5421. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  5422. }
  5423. if (i == 1 || i > 6)
  5424. {
  5425. if (i > 6)
  5426. {
  5427. fontRed.FillForegroundColor = 0;
  5428. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  5429. fontRed.FillPattern = FillPattern.SolidForeground;
  5430. }
  5431. cell.CellStyle = fontRed;
  5432. }
  5433. if (i > 2 && i < 7)
  5434. {
  5435. cell.CellStyle = BackgroundColor255_242_204;
  5436. }
  5437. cell.SetCellValue(setCellValue); //写入单元格
  5438. }
  5439. if (overspendSoure.ContainsKey(thisSid)) {
  5440. var overspendId = overspendSoure[thisSid];
  5441. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5442. }
  5443. cloneRowFn();
  5444. existsId.Add(new CarCompare
  5445. {
  5446. DataPrice = item.DatePrice.ObjToDate(),
  5447. Sid = item.SId
  5448. });
  5449. }
  5450. if (item.Equals(lastElem))
  5451. {
  5452. //合并小计行
  5453. //创建合并区域的实例
  5454. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5455. rowStartIndex, // 起始行索引(0-based)
  5456. rowStartIndex, // 结束行索引(0-based)
  5457. 0, // 起始列索引(0-based)
  5458. 3 // 结束列索引(0-based)
  5459. );
  5460. sheet.AddMergedRegion(cellRangeAddress);
  5461. var CellStyle = workbook.CreateCellStyle();
  5462. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5463. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5464. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5465. for (int i = 0; i <= clounmCount; i++)
  5466. {
  5467. if (i > 6)
  5468. {
  5469. var CellStyle1 = workbook.CreateCellStyle();
  5470. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5471. IFont Font = workbook.CreateFont(); // 创建字体
  5472. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5473. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5474. CellStyle1.SetFont(Font);
  5475. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5476. }
  5477. else
  5478. {
  5479. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5480. }
  5481. }
  5482. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5483. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5484. //超时合计
  5485. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5486. //超时数
  5487. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5488. //超时合计费用
  5489. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5490. cloneRowFn();
  5491. // 创建合并区域的实例
  5492. cellRangeAddress = new CellRangeAddress(
  5493. rowStartIndex, // 起始行索引(0-based)
  5494. rowStartIndex, // 结束行索引(0-based)
  5495. 0, // 起始列索引(0-based)
  5496. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  5497. );
  5498. // 添加合并区域
  5499. sheet.AddMergedRegion(cellRangeAddress);
  5500. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  5501. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  5502. }
  5503. }
  5504. mergeRow();
  5505. // 保存修改后的Excel文件到新文件
  5506. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  5507. // new FileStream(newFilePath, FileMode.CreateNew)
  5508. using (var stream = new MemoryStream())
  5509. {
  5510. workbook.Write(stream, true);
  5511. stream.Flush();
  5512. stream.Seek(0, SeekOrigin.Begin);
  5513. MemoryStream memoryStream = new MemoryStream();
  5514. stream.CopyTo(memoryStream);
  5515. memoryStream.Seek(0, SeekOrigin.Begin);
  5516. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  5517. }
  5518. workbook.Close();
  5519. workbook.Dispose();
  5520. }
  5521. catch (Exception ex)
  5522. {
  5523. jw.Msg = "出现异常!" + ex.Message;
  5524. return Ok(jw);
  5525. }
  5526. }
  5527. if (Zips.Count > 0)
  5528. {
  5529. IOOperatorHelper io = new IOOperatorHelper();
  5530. var byts = io.ConvertZipStream(Zips);
  5531. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  5532. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  5533. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  5534. }
  5535. else
  5536. {
  5537. jw.Msg = "暂无生成文件!";
  5538. }
  5539. return Ok(jw);
  5540. }
  5541. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  5542. {
  5543. string outStr = string.Empty;
  5544. switch (i)
  5545. {
  5546. case 0:
  5547. outStr = arr[0].SidName;
  5548. break;
  5549. case 1:
  5550. outStr = arr[0].DataPriceStr;
  5551. break;
  5552. case 2:
  5553. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  5554. break;
  5555. case 4:
  5556. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  5557. break;
  5558. case 7:
  5559. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5560. {
  5561. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  5562. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  5563. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  5564. }
  5565. break;
  5566. case 8:
  5567. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5568. {
  5569. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  5570. }
  5571. break;
  5572. case 9:
  5573. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5574. {
  5575. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  5576. }
  5577. break;
  5578. case 10:
  5579. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5580. {
  5581. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  5582. }
  5583. break;
  5584. }
  5585. return outStr;
  5586. }
  5587. #region OP行程单
  5588. /// <summary>
  5589. /// OP行程单初始化
  5590. /// </summary>
  5591. /// <param name="dto"></param>
  5592. /// <returns></returns>
  5593. [HttpPost]
  5594. public IActionResult InitOpTravel(InitOpTravelDto dto)
  5595. {
  5596. var jw = JsonView(false);
  5597. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  5598. var group = groupList.First();
  5599. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  5600. if (group == null)
  5601. {
  5602. jw.Msg = "暂无团组!";
  5603. return Ok(jw);
  5604. }
  5605. group = groupList.Find(x => x.Id == diid);
  5606. if (group == null)
  5607. {
  5608. jw.Msg = "请输入正确的团组ID!";
  5609. return Ok(jw);
  5610. }
  5611. string city = string.Empty;
  5612. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  5613. if (blackCode.Count > 0)
  5614. {
  5615. var black = blackCode.First();
  5616. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  5617. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  5618. if (blackSp.Length > 0)
  5619. {
  5620. try
  5621. {
  5622. var cityArrCode = new List<string>(20);
  5623. foreach (var item in blackSp)
  5624. {
  5625. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  5626. var IndexSelect = itemSp[2];
  5627. var cityArrCodeLength = cityArrCode.Count - 1;
  5628. var startCity = IndexSelect.Substring(0, 3);
  5629. if (cityArrCodeLength > 0)
  5630. {
  5631. var arrEndCity = cityArrCode[cityArrCodeLength];
  5632. if (arrEndCity != startCity)
  5633. {
  5634. cityArrCode.Add(startCity.ToUpper());
  5635. }
  5636. }
  5637. else
  5638. {
  5639. cityArrCode.Add(startCity.ToUpper());
  5640. }
  5641. var endCity = IndexSelect.Substring(3, 3);
  5642. cityArrCode.Add(endCity.ToUpper());
  5643. }
  5644. var cityThree = string.Empty;
  5645. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  5646. cityThree = cityThree.TrimEnd(',');
  5647. if (string.IsNullOrWhiteSpace(cityThree))
  5648. {
  5649. throw new
  5650. Exception("error");
  5651. }
  5652. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  5653. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  5654. foreach (var item in cityArrCode)
  5655. {
  5656. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  5657. if (find != null)
  5658. {
  5659. city += find.City + "/";
  5660. }
  5661. else
  5662. {
  5663. city += item + "三字码未收入/";
  5664. }
  5665. }
  5666. city = city.TrimEnd('/');
  5667. }
  5668. catch (Exception e)
  5669. {
  5670. city = "黑屏代码格式不正确!";
  5671. }
  5672. }
  5673. }
  5674. else
  5675. {
  5676. city = "未录入黑屏代码";
  5677. }
  5678. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  5679. {
  5680. Date = x.Date,
  5681. Days = x.Days,
  5682. Diffgroup = x.Diffgroup,
  5683. Diid = x.Diid,
  5684. Traffic_First = x.Traffic_First,
  5685. Traffic_Second = x.Traffic_Second,
  5686. Trip = x.Trip,
  5687. WeekDay = x.WeekDay,
  5688. Id = x.Id
  5689. }).ToList();
  5690. jw.Data = new
  5691. {
  5692. groupList = groupList.Select(x => new
  5693. {
  5694. x.Id,
  5695. x.TeamName,
  5696. x.TourCode
  5697. }).ToList(),
  5698. groupInfo = new
  5699. {
  5700. group.VisitDays,
  5701. group.TourCode,
  5702. group.VisitPNumber,
  5703. group.TeamName,
  5704. city
  5705. },
  5706. OpTravelList
  5707. };
  5708. jw.Code = 200;
  5709. jw.Msg = "操作成功!";
  5710. return Ok(jw);
  5711. }
  5712. /// <summary>
  5713. /// 删除团组行程单
  5714. /// </summary>
  5715. /// <returns></returns>
  5716. [HttpPost]
  5717. public IActionResult DelTravel(DelOpTravelDto dto)
  5718. {
  5719. var jw = JsonView(false);
  5720. if (dto.UserId <= 0 || dto.Diid <= 0)
  5721. {
  5722. jw.Msg = "请输入正确的参数!";
  5723. return Ok(jw);
  5724. }
  5725. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  5726. .SetColumns(x => new Grp_TravelList
  5727. {
  5728. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5729. DeleteUserId = dto.UserId,
  5730. IsDel = 1,
  5731. }).ExecuteCommand();
  5732. jw = JsonView(true);
  5733. return Ok(jw);
  5734. }
  5735. /// <summary>
  5736. /// 行程单保存
  5737. /// </summary>
  5738. /// <returns></returns>
  5739. [HttpPost]
  5740. public IActionResult TravelSave(TravelSaveDto dto)
  5741. {
  5742. var jw = JsonView(false);
  5743. if (dto.Arr.Count > 0)
  5744. {
  5745. try
  5746. {
  5747. _sqlSugar.BeginTran();
  5748. foreach (var item in dto.Arr)
  5749. {
  5750. if (item.Id == 0)
  5751. {
  5752. throw new Exception("请传入正确的Id");
  5753. }
  5754. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  5755. .SetColumns(x => new Grp_TravelList
  5756. {
  5757. Trip = item.Trip
  5758. }).ExecuteCommand();
  5759. }
  5760. _sqlSugar.CommitTran();
  5761. jw = JsonView(true);
  5762. }
  5763. catch (Exception ex)
  5764. {
  5765. _sqlSugar.RollbackTran();
  5766. jw.Msg = "程序异常!" + ex.Message;
  5767. }
  5768. }
  5769. else
  5770. {
  5771. jw.Msg = "请传入正确的参数!";
  5772. }
  5773. return Ok(jw);
  5774. }
  5775. /// <summary>
  5776. /// 导出行程单
  5777. /// </summary>
  5778. /// <param name="dto"></param>
  5779. /// <returns></returns>
  5780. [HttpPost]
  5781. public IActionResult ExportTravel(InitOpTravelDto dto)
  5782. {
  5783. var jw = JsonView(false);
  5784. //数据源
  5785. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  5786. int diid = 0;
  5787. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  5788. if (Find == null)
  5789. {
  5790. jw.Msg = "请选择正确的团组!";
  5791. return Ok(jw);
  5792. }
  5793. else
  5794. {
  5795. diid = Find.Id;
  5796. }
  5797. DataTable dtBlack = null;
  5798. try
  5799. {
  5800. dtBlack = GetTableByBlackCode(diid);
  5801. }
  5802. catch (Exception)
  5803. {
  5804. jw.Msg = "机票黑屏代码有误!";
  5805. return Ok(jw);
  5806. }
  5807. string CityStr1 = "";
  5808. List<string> countriesList = new List<string>();
  5809. List<string> cityList = new List<string>();
  5810. string countriesIntroduction = "";
  5811. string cityIntroduction = "";
  5812. string timeDifference = "";
  5813. string currExchangeRate = "";
  5814. string txt_itemPrepare = "";
  5815. string txt_specialReminder = "";
  5816. string txt_cGPrecautions = "";
  5817. string txt_yGCG = "";
  5818. string txt_conduct = "";
  5819. string txt_commonEnglish = "";
  5820. if (dtBlack == null && (dtBlack.Rows[0]["Day"] == null || dtBlack.Rows[0]["Day"].ToString() == ""))
  5821. {
  5822. //提示
  5823. //PublicCode.GetAlertMsg(this, GetType(), dt.Rows[dt.Rows.Count - 1]["Error"].ToString());
  5824. }
  5825. else
  5826. {
  5827. //创建三字码示例
  5828. Res_ThreeCode t = new Res_ThreeCode();
  5829. //城市缓存
  5830. string city = "";
  5831. //出访城市
  5832. for (int i = 0; i < dtBlack.Rows.Count; i++)
  5833. {
  5834. if ((i + 1) < dtBlack.Rows.Count && dtBlack.Rows[i]["Three"].ToString() == dtBlack.Rows[i + 1]["Three"].ToString())
  5835. {
  5836. continue;
  5837. }
  5838. if (dtBlack.Rows.Count > 0 && (dtBlack.Rows[i]["Three"].ToString() != null && dtBlack.Rows[i]["Three"].ToString() != ""))
  5839. {
  5840. //出发城市
  5841. string cityTemp = dtBlack.Rows[i]["Three"].ToString().Replace("/", string.Empty).Substring(0, 3);
  5842. t = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three == cityTemp && x.IsDel == 0);
  5843. if (t != null)
  5844. {
  5845. city = city + "/" + t.City;
  5846. }
  5847. else
  5848. {
  5849. city = city + "/【" + cityTemp + "未收录,请联系机票同事录入】";
  5850. }
  5851. if (i == dtBlack.Rows.Count - 1)
  5852. {
  5853. //抵达城市
  5854. cityTemp = dtBlack.Rows[i]["Three"].ToString().Replace("/", string.Empty).Substring(3, 3);
  5855. t = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three == cityTemp && x.IsDel == 0);
  5856. if (t != null)
  5857. {
  5858. city = city + "/" + t.City;
  5859. }
  5860. else
  5861. {
  5862. city = city + "/【" + cityTemp + "未收录,请联系机票同事录入】";
  5863. }
  5864. }
  5865. }
  5866. }
  5867. if (city != "" && city != null)
  5868. {
  5869. string[] cityStr2 = city.Split('/');
  5870. string[] strs = cityStr2.Distinct().ToArray(); ;
  5871. string str = "";
  5872. foreach (var s in strs)
  5873. {
  5874. str += s + "/";
  5875. }
  5876. str = str.TrimStart('/');
  5877. str = str.TrimEnd('/');
  5878. //lblTourCity.Text = "去重前:" + city.TrimStart('/') + "\n 去重后:" + str;
  5879. CityStr1 = city.TrimStart('/');
  5880. }
  5881. // 行程repeater
  5882. if (GetByDiid(diid).Count > 0)
  5883. {
  5884. _travelList = GetByDiid(diid).Where(x => x.Issel == 1 && x.IsDel == 0).ToList();
  5885. }
  5886. else
  5887. {
  5888. //生成该时间段日期
  5889. List<string> timeList = GetTimeListByDataTable(dtBlack);
  5890. if (timeList != null)
  5891. {
  5892. string[] str = new string[timeList.Count];
  5893. //rpData.DataSource = str;
  5894. //rpData.DataBind();
  5895. }
  5896. }
  5897. }
  5898. //创建数据源Table
  5899. DataTable dtSource = new DataTable();
  5900. dtSource.Columns.Add("Days", typeof(string));
  5901. dtSource.Columns.Add("Date", typeof(string));
  5902. dtSource.Columns.Add("Week", typeof(string));
  5903. dtSource.Columns.Add("Traffic", typeof(string));
  5904. dtSource.Columns.Add("Trip", typeof(string));
  5905. //获取数据,放到datatable
  5906. foreach (var item in _travelList)
  5907. {
  5908. DataRow dr = dtSource.NewRow();
  5909. dr["Days"] = item.Days;
  5910. dr["Date"] = item.Date;
  5911. dr["Week"] = item.WeekDay;
  5912. dr["Traffic"] = item.Traffic_First
  5913. + "\r\n"
  5914. + item.Traffic_Second;
  5915. if (item.Trip.Replace("(此地区为黄热病地区,请注意打疫苗)", "").Length < 15)
  5916. {
  5917. item.Trip += @"
  5918. 08:00 早餐于酒店;
  5919. 09:00 公务活动;
  5920. 10:30 公务活动;
  5921. 12:00 午餐于当地餐厅;
  5922. 14:00 公务活动;
  5923. 16:00 公务活动;
  5924. 18:00 晚餐于当地餐厅;
  5925. 19:00 入住酒店休息;";
  5926. }
  5927. dr["Trip"] = item.Trip;
  5928. dtSource.Rows.Add(dr);
  5929. }
  5930. //lblTeamName.Text = di.TourCode;
  5931. //lblVisitDays.Text = di.VisitDays.ToString();
  5932. //lblVisitDays2.Text = di.VisitDays.ToString();
  5933. //lblPNumber.Text = di.VisitPNumber.ToString();
  5934. //lblGroup.Text = di.TeamName.ToString();
  5935. Dictionary<string, string> dic = new Dictionary<string, string>();
  5936. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  5937. dic.Add("City", CityStr1);
  5938. dic.Add("Days", Find.VisitDays.ToString());
  5939. dic.Add("DeleCode", Find.TourCode);
  5940. dic.Add("Pnum", Find.VisitPNumber.ToString());
  5941. dic.Add("Pnum2", Find.VisitPNumber.ToString());
  5942. List<Crm_DeleClient> leader = GetByDiidClient(Find.Id);
  5943. if (leader != null && leader.Count > 0)
  5944. {
  5945. dic.Add("Leader", GetByDiidClient(Find.Id)[0].LastName + GetByDiidClient(Find.Id)[0].FirstName);
  5946. }
  5947. else
  5948. {
  5949. dic.Add("Leader", "");
  5950. }
  5951. dic.Add("Pnum3", Find.VisitPNumber.ToString());
  5952. int UserId = 253;
  5953. dic.Add("OP", "");
  5954. dic.Add("OPTel", "");
  5955. //dic.Add("OP", "OP姓名");
  5956. //dic.Add("OPTel", "OP手机号码");
  5957. string countriesStr = "";
  5958. countriesList.ForEach(s => countriesStr += s + "、");
  5959. countriesStr = countriesStr.TrimEnd('、');
  5960. string cityStr = "";
  5961. cityList.ForEach(s => cityStr += s + "、");
  5962. cityStr = cityStr.TrimEnd('、');
  5963. //下方数据
  5964. dic.Add("selCountries", countriesStr == null ? "" : countriesStr);
  5965. dic.Add("selCity", cityStr == null ? "" : cityStr);
  5966. dic.Add("countriesIntroduction", countriesIntroduction == null ? "" : countriesIntroduction);
  5967. dic.Add("CityIntroduction", cityIntroduction == null ? "" : cityIntroduction);
  5968. dic.Add("timeDifference", timeDifference == null ? "" : timeDifference);
  5969. dic.Add("currExchangeRate", currExchangeRate == null ? "" : currExchangeRate);
  5970. dic.Add("temperature", "");
  5971. dic.Add("txt_itemPrepare", txt_itemPrepare == null ? "" : txt_itemPrepare);
  5972. dic.Add("txt_specialReminder", txt_specialReminder == null ? "" : txt_specialReminder);
  5973. dic.Add("txt_cGPrecautions", txt_cGPrecautions == null ? "" : txt_cGPrecautions);
  5974. dic.Add("txt_yGCG", txt_yGCG == null ? "" : txt_yGCG);
  5975. dic.Add("txt_conduct", txt_conduct == null ? "" : txt_conduct);
  5976. dic.Add("txt_commonEnglish", txt_commonEnglish == null ? "" : txt_commonEnglish);
  5977. //模板路径
  5978. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  5979. //载入模板
  5980. Document doc = null;
  5981. DocumentBuilder builder = null;
  5982. try
  5983. {
  5984. //载入模板
  5985. doc = new Document(tempPath);
  5986. builder = new DocumentBuilder(doc);
  5987. }
  5988. catch (Exception)
  5989. {
  5990. jw.Msg = "模板位置不存在!";
  5991. return Ok(jw);
  5992. }
  5993. foreach (var key in dic.Keys)
  5994. {
  5995. Bookmark bookmark = doc.Range.Bookmarks[key];
  5996. if (bookmark != null)
  5997. {
  5998. builder.MoveToBookmark(key);
  5999. builder.Write(dic[key]);
  6000. }
  6001. }
  6002. //获取word里所有表格
  6003. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6004. //获取所填表格的序数
  6005. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6006. try
  6007. {
  6008. //循环赋值
  6009. for (int i = 0; i < dtSource.Rows.Count; i++)
  6010. {
  6011. builder.MoveToCell(0, i + 1, 0, 0);
  6012. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6013. builder.MoveToCell(0, i + 1, 1, 0);
  6014. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6015. builder.MoveToCell(0, i + 1, 2, 0);
  6016. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6017. var trip = dtSource.Rows[i]["Trip"].ToString();
  6018. builder.MoveToCell(0, i + 1, 3, 0);
  6019. builder.Write(trip);
  6020. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6021. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6022. // 获取特定索引的段落
  6023. Paragraph paragraph = (Paragraph)paragraphs[0];
  6024. Run run = paragraph.Runs[0];
  6025. Aspose.Words.Font font = run.Font;
  6026. font.Name = "黑体";
  6027. //设置双休红色
  6028. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6029. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6030. paragraph = (Paragraph)paragraphs[1];
  6031. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6032. {
  6033. run = paragraph.Runs[0];
  6034. font = run.Font;
  6035. font.Color = Color.Red;
  6036. }
  6037. }
  6038. }
  6039. catch (Exception ex)
  6040. {
  6041. }
  6042. //删除多余行
  6043. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6044. {
  6045. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6046. }
  6047. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6048. if (!Directory.Exists(savePath))
  6049. {
  6050. try
  6051. {
  6052. Directory.CreateDirectory(savePath);
  6053. }
  6054. catch
  6055. {
  6056. }
  6057. }
  6058. string path = savePath + Find.TeamName + "出访日程.docx";
  6059. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程.docx";
  6060. try
  6061. {
  6062. doc.Save(path, Aspose.Words.SaveFormat.Doc);
  6063. jw = JsonView(true, "导出成功", ftpPath);
  6064. }
  6065. catch (Exception)
  6066. {
  6067. jw = JsonView(false);
  6068. }
  6069. return Ok(jw);
  6070. }
  6071. /// <summary>
  6072. ///根据机票黑屏代码整理DataTable
  6073. /// </summary>
  6074. /// <param name="diid"></param>
  6075. /// <returns></returns>
  6076. DataTable GetTableByBlackCode(int diid)
  6077. {
  6078. //黑屏代码信息
  6079. List<Air_TicketBlackCode> listcode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.DiId == diid && x.IsDel == 0).ToList();
  6080. //测试数据为序号,航班号,起飞日期,三字码,起飞时刻,到达时刻,出发航站楼,到达航站楼,机型,飞行时间
  6081. //1.3U8391 TU17NOV CTUCAI 0220 0715 T1 T2 330 10H55M
  6082. DataTable dt = new DataTable();
  6083. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  6084. dt.Columns.Add("Date", typeof(string));//起飞日期
  6085. dt.Columns.Add("Three", typeof(string));//三字码
  6086. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  6087. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  6088. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  6089. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  6090. dt.Columns.Add("AirModel", typeof(string)); //机型
  6091. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  6092. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  6093. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  6094. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  6095. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  6096. //判断是否录入黑屏代码
  6097. if (listcode.Count() == 0 || listcode == null)
  6098. {
  6099. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null);
  6100. }
  6101. else
  6102. {
  6103. //读取单段黑屏代码
  6104. for (int i = 0; i < listcode.Count; i++)
  6105. {
  6106. //去除序号
  6107. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  6108. //去除多余空格,方法一Linq扩展方法
  6109. CodeList = CodeList.Where(str => str != "").ToArray();
  6110. CodeList = CodeList.Where(str => str != " ").ToArray();
  6111. //年
  6112. int year = Convert.ToInt32(DateTime.Now.Year.ToString());
  6113. //读取单条黑屏代码
  6114. for (int j = 0; j < CodeList.Count(); j++)
  6115. {
  6116. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  6117. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  6118. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6119. //string[] Info = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  6120. // .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6121. //去除多余空格
  6122. Info = Info.Where(str => str != "").ToArray();
  6123. Info = Info.Where(str => str != " ").ToArray();
  6124. //判断黑屏代码是否正确拆分; 理应拆成9段
  6125. if (Info.Count() < 9)
  6126. {
  6127. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null);
  6128. }
  6129. else
  6130. {
  6131. try
  6132. {
  6133. //月
  6134. int month = Convert.ToInt32(GetLonger(Info[1].Substring(4, 3)));
  6135. //日
  6136. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  6137. #region 逐一比较月份,判断是否翻年;逐一比较三字码顶真,判断是否跑错机场
  6138. if (j > 0)
  6139. {
  6140. string[] Temp = CodeList[j - 1].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  6141. .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6142. Temp = Temp.Where(str => str != "").ToArray();
  6143. Temp = Temp.Where(str => str != " ").ToArray();
  6144. int monthTemp = Convert.ToInt32(GetLonger(Temp[1].Substring(4, 3)));
  6145. // 如果相邻月份之差小于0,则证明次一条年份需+1
  6146. if (month - monthTemp < 0)
  6147. {
  6148. year = year + 1;
  6149. }
  6150. //如果相邻代码三字码不顶真,提醒
  6151. string FootThree = Temp[2].Substring(3, 3);
  6152. string HeadThree = Info[2].Substring(0, 3);
  6153. if (FootThree != HeadThree)
  6154. {
  6155. //DelegationInfoService s = new DelegationInfoService();
  6156. //UsersService us = new UsersService();
  6157. //GroupsTaskAssignmentService gts = new GroupsTaskAssignmentService();
  6158. //77 行程
  6159. List<Grp_GroupsTaskAssignment> list2 = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 77 && x.DIId == diid && x.IsDel == 0).ToList();
  6160. foreach (var temp in list2)
  6161. {
  6162. //if (temp.UId != 21)
  6163. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  6164. // "黑屏代码提醒",
  6165. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  6166. }
  6167. //85 机票预订
  6168. List<Grp_GroupsTaskAssignment> list6 = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 85 && x.DIId == diid && x.IsDel == 0).ToList();
  6169. foreach (var temp in list6)
  6170. {
  6171. //if (temp.UId != 21)
  6172. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  6173. // "黑屏代码提醒",
  6174. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  6175. }
  6176. }
  6177. }
  6178. #endregion
  6179. #region 判断到达日期是否需要加1
  6180. if (Info[4].Contains("+"))
  6181. {
  6182. //日期+1
  6183. day = day + 1;
  6184. //判断是否进入下一月
  6185. if (day > Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year)))
  6186. {
  6187. day = day - Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year));
  6188. month = month + 1;
  6189. //判断是否进入下一年
  6190. if (month > 12)
  6191. {
  6192. month = month - 12;
  6193. year = year + 1;
  6194. }
  6195. }
  6196. //月份整理格式
  6197. string monthTemp = month.ToString();
  6198. if (month < 10)
  6199. {
  6200. monthTemp = "0" + monthTemp;
  6201. }
  6202. //日期整理格式
  6203. string daytemp = day.ToString();
  6204. if (day < 10)
  6205. {
  6206. daytemp = "0" + daytemp;
  6207. }
  6208. string temp = Info[4].Split('+')[0];
  6209. //添加起飞数据
  6210. dt.Rows.Add(Info[0],
  6211. Info[1],
  6212. Info[2],
  6213. Info[3],
  6214. temp,
  6215. Info[5],
  6216. Info[6],
  6217. Info[7],
  6218. Info[8],
  6219. year + "-" + GetLonger(Info[1].Substring(4, 3)) + "-" + Info[1].Substring(2, 2),
  6220. year + "-" + monthTemp + "-" + daytemp,
  6221. "",
  6222. "0");
  6223. //加1天,添加到达数据
  6224. dt.Rows.Add(Info[0],
  6225. Info[1].Replace(Info[1].Substring(2, 2), daytemp),
  6226. Info[2],
  6227. Info[3],
  6228. temp,
  6229. Info[5],
  6230. Info[6],
  6231. Info[7],
  6232. Info[8],
  6233. year + "-" + monthTemp + "-" + daytemp,
  6234. year + "-" + monthTemp + "-" + daytemp,
  6235. "",
  6236. "1");
  6237. }
  6238. else
  6239. {
  6240. //月份整理格式
  6241. string monthTemp = month.ToString();
  6242. if (month < 10)
  6243. {
  6244. monthTemp = "0" + monthTemp;
  6245. }
  6246. //日期整理格式
  6247. string daytemp = day.ToString();
  6248. if (day < 10)
  6249. {
  6250. daytemp = "0" + daytemp;
  6251. }
  6252. dt.Rows.Add(Info[0],
  6253. Info[1],
  6254. Info[2],
  6255. Info[3],
  6256. Info[4],
  6257. Info[5],
  6258. Info[6],
  6259. Info[7],
  6260. Info[8],
  6261. year + "-" + monthTemp + "-" + daytemp,
  6262. year + "-" + monthTemp + "-" + daytemp,
  6263. "",
  6264. "0");
  6265. }
  6266. #endregion
  6267. }
  6268. catch (Exception ex)
  6269. {
  6270. string exstr = ex.Message.ToString();
  6271. }
  6272. }
  6273. }
  6274. //排序
  6275. dt.DefaultView.Sort = "Day asc";
  6276. dt = dt.DefaultView.ToTable();
  6277. }
  6278. }
  6279. return dt;
  6280. }
  6281. /// <summary>
  6282. /// 根据团组编号查询信息
  6283. /// </summary>
  6284. /// <returns>返回空或者对象信息</returns>
  6285. List<Grp_TravelList> GetByDiid(int Diid)
  6286. {
  6287. //调用获取单个对象的方法
  6288. return _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == Diid && x.IsDel == 0).ToList();
  6289. }
  6290. /// <summary>
  6291. /// 20210816
  6292. /// 根据datatable生成某一时间段的日期
  6293. /// </summary>
  6294. /// <param name="dt">黑屏代码生成的datatable</param>
  6295. /// <returns></returns>
  6296. List<string> GetTimeListByDataTable(DataTable dt)
  6297. {
  6298. if (dt.Rows[0]["Day"].ToString() != "")
  6299. {
  6300. DateTime datestart = Convert.ToDateTime(dt.Rows[0]["Day"].ToString());
  6301. DateTime dateend = Convert.ToDateTime(dt.Rows[dt.Rows.Count - 1]["ArrivedDate"].ToString());
  6302. List<string> timeList = new List<string>();
  6303. while (datestart <= dateend)
  6304. {
  6305. timeList.Add(datestart.ToString("yyyy-MM-dd"));
  6306. datestart = datestart.AddDays(1);
  6307. }
  6308. return timeList;
  6309. }
  6310. return null;
  6311. }
  6312. /// <summary>
  6313. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6314. /// </summary>
  6315. /// <param name="num"></param>
  6316. /// <returns></returns>
  6317. string GetNum(string num)
  6318. {
  6319. string str = "";
  6320. switch (num)
  6321. {
  6322. case "1":
  6323. str = "一";
  6324. break;
  6325. case "2":
  6326. str = "二";
  6327. break;
  6328. case "3":
  6329. str = "三";
  6330. break;
  6331. case "4":
  6332. str = "四";
  6333. break;
  6334. case "5":
  6335. str = "五";
  6336. break;
  6337. case "6":
  6338. str = "六";
  6339. break;
  6340. case "7":
  6341. str = "七";
  6342. break;
  6343. case "8":
  6344. str = "八";
  6345. break;
  6346. case "9":
  6347. str = "九";
  6348. break;
  6349. case "10":
  6350. str = "十";
  6351. break;
  6352. case "11":
  6353. str = "十一";
  6354. break;
  6355. case "12":
  6356. str = "十二";
  6357. break;
  6358. case "一":
  6359. str = "1";
  6360. break;
  6361. case "二":
  6362. str = "2";
  6363. break;
  6364. case "三":
  6365. str = "3";
  6366. break;
  6367. case "四":
  6368. str = "4";
  6369. break;
  6370. case "五":
  6371. str = "5";
  6372. break;
  6373. case "六":
  6374. str = "6";
  6375. break;
  6376. case "七":
  6377. str = "7";
  6378. break;
  6379. case "八":
  6380. str = "8";
  6381. break;
  6382. case "九":
  6383. str = "9";
  6384. break;
  6385. case "十":
  6386. str = "10";
  6387. break;
  6388. case "十一":
  6389. str = "11";
  6390. break;
  6391. case "十二":
  6392. str = "12";
  6393. break;
  6394. }
  6395. return str;
  6396. }
  6397. List<Crm_DeleClient> GetByDiidClient(int DIID)
  6398. {
  6399. return _sqlSugar.Queryable<Crm_DeleClient>().Where(x => x.DiId == DIID && x.IsDel == 0).ToList();
  6400. }
  6401. /// <summary>
  6402. /// 根据星期,月份的缩写,转换成数字或者全称
  6403. /// 根据币种中文名称返回币种代码
  6404. /// 根据数字返回机型型号【2、3开头的就是空客,比如空客320,7开头的就是波音,比如波音777】
  6405. /// 20210903贾文滔
  6406. /// </summary>
  6407. /// <param name="startDate"></param>
  6408. /// <param name="endDate"></param>
  6409. /// <returns></returns>
  6410. string GetLonger(string temp)
  6411. {
  6412. string str = "";
  6413. switch (temp.ToUpper())
  6414. {
  6415. case "美元":
  6416. str = "USD";
  6417. break;
  6418. case "日元":
  6419. str = "JPY";
  6420. break;
  6421. case "英镑":
  6422. str = "GBP";
  6423. break;
  6424. case "欧元":
  6425. str = "EUR";
  6426. break;
  6427. case "港币":
  6428. str = "HKD";
  6429. break;
  6430. case "MO":
  6431. str = "星期一";
  6432. break;
  6433. case "TU":
  6434. str = "星期二";
  6435. break;
  6436. case "WE":
  6437. str = "星期三";
  6438. break;
  6439. case "TH":
  6440. str = "星期四";
  6441. break;
  6442. case "FR":
  6443. str = "星期五";
  6444. break;
  6445. case "SA":
  6446. str = "星期六";
  6447. break;
  6448. case "SU":
  6449. str = "星期天";
  6450. break;
  6451. case "JAN":
  6452. str = "01";
  6453. break;
  6454. case "FEB":
  6455. str = "02";
  6456. break;
  6457. case "MAR":
  6458. str = "03";
  6459. break;
  6460. case "APR":
  6461. str = "04";
  6462. break;
  6463. case "MAY":
  6464. str = "05";
  6465. break;
  6466. case "JUN":
  6467. str = "06";
  6468. break;
  6469. case "JUL":
  6470. str = "07";
  6471. break;
  6472. case "AUG":
  6473. str = "08";
  6474. break;
  6475. case "SEP":
  6476. str = "09";
  6477. break;
  6478. case "OCT":
  6479. str = "10";
  6480. break;
  6481. case "NOV":
  6482. str = "11";
  6483. break;
  6484. case "DEC":
  6485. str = "12";
  6486. break;
  6487. case "MONDAY":
  6488. str = "星期一";
  6489. break;
  6490. case "TUESDAY":
  6491. str = "星期二";
  6492. break;
  6493. case "WEDNESDAY":
  6494. str = "星期三";
  6495. break;
  6496. case "THURSDAY":
  6497. str = "星期四";
  6498. break;
  6499. case "FRIDAY":
  6500. str = "星期五";
  6501. break;
  6502. case "SATURDAY":
  6503. str = "星期六";
  6504. break;
  6505. case "SUNDAY":
  6506. str = "星期日";
  6507. break;
  6508. case "01":
  6509. str = "JAN";
  6510. break;
  6511. case "02":
  6512. str = "FEB";
  6513. break;
  6514. case "03":
  6515. str = "MAR";
  6516. break;
  6517. case "04":
  6518. str = "APR";
  6519. break;
  6520. case "05":
  6521. str = "MAY";
  6522. break;
  6523. case "06":
  6524. str = "JUN";
  6525. break;
  6526. case "07":
  6527. str = "JUL";
  6528. break;
  6529. case "08":
  6530. str = "AUG";
  6531. break;
  6532. case "09":
  6533. str = "SEP";
  6534. break;
  6535. case "10":
  6536. str = "OCT";
  6537. break;
  6538. case "11":
  6539. str = "NOV";
  6540. break;
  6541. case "12":
  6542. str = "DEC";
  6543. break;
  6544. case "2":
  6545. str = "空客A";
  6546. break;
  6547. case "3":
  6548. str = "空客A";
  6549. break;
  6550. case "7":
  6551. str = "波音";
  6552. break;
  6553. }
  6554. return str;
  6555. }
  6556. /// <summary>
  6557. /// 根据月份返回天数
  6558. /// </summary>
  6559. /// <param name="temp"></param>
  6560. /// <returns></returns>
  6561. string GetDaysByMonth(string Month, int year)
  6562. {
  6563. string str = "";
  6564. //判断是否是闰年
  6565. if (DateTime.IsLeapYear(year) == false)
  6566. {
  6567. switch (Month.ToUpper())
  6568. {
  6569. case "JAN":
  6570. str = "31";
  6571. break;
  6572. case "FEB":
  6573. str = "28";
  6574. break;
  6575. case "MAR":
  6576. str = "31";
  6577. break;
  6578. case "APR":
  6579. str = "30";
  6580. break;
  6581. case "MAY":
  6582. str = "31";
  6583. break;
  6584. case "JUN":
  6585. str = "30";
  6586. break;
  6587. case "JUL":
  6588. str = "31";
  6589. break;
  6590. case "AUG":
  6591. str = "31";
  6592. break;
  6593. case "SEP":
  6594. str = "30";
  6595. break;
  6596. case "OCT":
  6597. str = "31";
  6598. break;
  6599. case "NOV":
  6600. str = "30";
  6601. break;
  6602. case "DEC":
  6603. str = "31";
  6604. break;
  6605. case "01":
  6606. str = "31";
  6607. break;
  6608. case "02":
  6609. str = "28";
  6610. break;
  6611. case "03":
  6612. str = "31";
  6613. break;
  6614. case "04":
  6615. str = "30";
  6616. break;
  6617. case "05":
  6618. str = "31";
  6619. break;
  6620. case "06":
  6621. str = "30";
  6622. break;
  6623. case "07":
  6624. str = "31";
  6625. break;
  6626. case "08":
  6627. str = "31";
  6628. break;
  6629. case "09":
  6630. str = "30";
  6631. break;
  6632. case "10":
  6633. str = "31";
  6634. break;
  6635. case "11":
  6636. str = "30";
  6637. break;
  6638. case "12":
  6639. str = "31";
  6640. break;
  6641. }
  6642. }
  6643. else
  6644. {
  6645. switch (Month.ToUpper())
  6646. {
  6647. case "JAN":
  6648. str = "31";
  6649. break;
  6650. case "FEB":
  6651. str = "29";
  6652. break;
  6653. case "MAR":
  6654. str = "31";
  6655. break;
  6656. case "APR":
  6657. str = "30";
  6658. break;
  6659. case "MAY":
  6660. str = "31";
  6661. break;
  6662. case "JUN":
  6663. str = "30";
  6664. break;
  6665. case "JUL":
  6666. str = "31";
  6667. break;
  6668. case "AUG":
  6669. str = "31";
  6670. break;
  6671. case "SEP":
  6672. str = "30";
  6673. break;
  6674. case "OCT":
  6675. str = "31";
  6676. break;
  6677. case "NOV":
  6678. str = "30";
  6679. break;
  6680. case "DEC":
  6681. str = "31";
  6682. break;
  6683. case "01":
  6684. str = "31";
  6685. break;
  6686. case "02":
  6687. str = "29";
  6688. break;
  6689. case "03":
  6690. str = "31";
  6691. break;
  6692. case "04":
  6693. str = "30";
  6694. break;
  6695. case "05":
  6696. str = "31";
  6697. break;
  6698. case "06":
  6699. str = "30";
  6700. break;
  6701. case "07":
  6702. str = "31";
  6703. break;
  6704. case "08":
  6705. str = "31";
  6706. break;
  6707. case "09":
  6708. str = "30";
  6709. break;
  6710. case "10":
  6711. str = "31";
  6712. break;
  6713. case "11":
  6714. str = "30";
  6715. break;
  6716. case "12":
  6717. str = "31";
  6718. break;
  6719. }
  6720. }
  6721. return str;
  6722. }
  6723. #endregion
  6724. #endregion
  6725. #region 团组成本
  6726. /// <summary>
  6727. /// 团组成本数据初始化
  6728. /// </summary>
  6729. /// <param name="dto"></param>
  6730. /// <returns></returns>
  6731. [HttpPost]
  6732. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6733. {
  6734. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6735. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6736. WHEN COUNT(*) >= 0 THEN 'True'
  6737. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6738. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6739. ").ToList(); //团组列表
  6740. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6741. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6742. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6743. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6744. if (groupinfoValue != null)
  6745. {
  6746. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6747. var spArr = new string[1] { countryArr };
  6748. if (countryArr.Contains("|"))
  6749. {
  6750. spArr = countryArr.Split("|");
  6751. }
  6752. else if (countryArr.Contains("、"))
  6753. {
  6754. spArr = countryArr.Split("、");
  6755. }
  6756. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6757. {
  6758. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6759. if (dbQueryCountry != null)
  6760. {
  6761. visaCountryInfoArr.Add(dbQueryCountry);
  6762. }
  6763. }
  6764. }
  6765. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6766. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6767. var create = _GroupCostRepository.
  6768. CreateGroupCostByBlackCode(dto.Diid);
  6769. if (groupCost.Count == 0 && create.Code == 0)
  6770. {
  6771. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6772. }
  6773. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6774. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6775. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6776. groupCostMap = groupCostMap.Select(x =>
  6777. {
  6778. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6779. {
  6780. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6781. }
  6782. return x;
  6783. }).ToList();
  6784. //GroupCostParameter.Add(new
  6785. // Grp_GroupCostParameter());
  6786. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6787. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  6788. return Ok(JsonView(new
  6789. {
  6790. groupList,
  6791. groupInfo,
  6792. groupChecks,
  6793. groupCost = groupCostMap,
  6794. hotelNumber,
  6795. GroupCostParameter = GroupCostParameterMap,
  6796. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6797. {
  6798. x.VisaCountry,
  6799. x.VisaPrice,
  6800. x.Id,
  6801. }).ToList(),
  6802. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6803. blackCodeIsTrue = create.Code == 0 ? true : false,
  6804. hotelIsTrue = hotelIsTrue,
  6805. }));
  6806. }
  6807. /// <summary>
  6808. /// 团组成本信息保存
  6809. /// </summary>
  6810. /// <param name="dto"></param>
  6811. /// <returns></returns>
  6812. [HttpPost]
  6813. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6814. {
  6815. if (dto.Diid <= 0 || dto.Userid <= 0)
  6816. {
  6817. return Ok(JsonView(false));
  6818. }
  6819. JsonView jw = null;
  6820. bool isTrue = false;
  6821. #region 复制团组成本
  6822. //if (dto.Diid == 2581)
  6823. //{
  6824. // dto.Diid = 2599;
  6825. // dto.CheckBoxs.ForEach(x =>
  6826. // {
  6827. // x.Diid = 2599;
  6828. // });
  6829. // dto.GroupCosts.ForEach(x =>
  6830. // {
  6831. // x.Diid = 2599;
  6832. // });
  6833. // dto.CostTypeHotelNumbers.ForEach(x =>
  6834. // {
  6835. // x.Diid = 2599;
  6836. // });
  6837. // dto.GroupCostParameters.ForEach(x =>
  6838. // {
  6839. // x.DiId = 2599;
  6840. // });
  6841. //}
  6842. #endregion
  6843. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6844. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6845. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6846. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6847. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6848. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6849. try
  6850. {
  6851. _sqlSugar.BeginTran();
  6852. isTrue = await _GroupCostRepository.
  6853. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  6854. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6855. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6856. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6857. _sqlSugar.CommitTran();
  6858. jw = JsonView(true, "保存成功!", isTrue);
  6859. }
  6860. catch (Exception)
  6861. {
  6862. _sqlSugar.RollbackTran();
  6863. jw = JsonView(false);
  6864. }
  6865. return Ok(jw);
  6866. }
  6867. /// <summary>
  6868. /// 司兼导数据
  6869. /// </summary>
  6870. /// <param name="dto"></param>
  6871. /// <returns></returns>
  6872. [HttpPost]
  6873. public IActionResult GetCarGuides(CarGuidesDto dto)
  6874. {
  6875. JsonView jw = null;
  6876. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6877. jw = JsonView(true, "获取成功!", Data);
  6878. return Ok(jw);
  6879. }
  6880. /// <summary>
  6881. /// 导游数据
  6882. /// </summary>
  6883. /// <param name="dto"></param>
  6884. /// <returns></returns>
  6885. [HttpPost]
  6886. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6887. {
  6888. JsonView jw = null;
  6889. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6890. // 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
  6891. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6892. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6893. jw = JsonView(true, "获取成功!", Data);
  6894. return Ok(jw);
  6895. }
  6896. /// <summary>
  6897. /// 成本车数据
  6898. /// </summary>
  6899. /// <param name="dto"></param>
  6900. /// <returns></returns>
  6901. [HttpPost]
  6902. public IActionResult GetCarInfo(CarGuidesDto dto)
  6903. {
  6904. JsonView jw = null;
  6905. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6906. jw = JsonView(true, "获取成功!", Data);
  6907. return Ok(jw);
  6908. }
  6909. /// <summary>
  6910. /// 景点数据
  6911. /// </summary>
  6912. /// <param name="dto"></param>
  6913. /// <returns></returns>
  6914. [HttpPost]
  6915. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6916. {
  6917. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6918. return Ok(JsonView(true, "获取成功!", Data));
  6919. }
  6920. /// <summary>
  6921. /// 成本通知
  6922. /// </summary>
  6923. /// <param name="dto"></param>
  6924. /// <returns></returns>
  6925. [HttpPost]
  6926. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6927. {
  6928. if (dto.Diid < 0)
  6929. {
  6930. return Ok(JsonView(false));
  6931. }
  6932. JsonView jw = null;
  6933. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6934. if (GroupCostParameter != null)
  6935. {
  6936. int IsShare = 0;
  6937. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6938. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6939. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6940. string msg = string.Empty;
  6941. if (isTrue)
  6942. {
  6943. if (IsShare == 0)
  6944. {
  6945. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6946. }
  6947. else
  6948. {
  6949. #region 企微通知对应岗位用户
  6950. try
  6951. {
  6952. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6953. }
  6954. catch (Exception ex)
  6955. {
  6956. }
  6957. #endregion
  6958. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6959. }
  6960. jw = JsonView(isTrue, msg, new { IsShare });
  6961. }
  6962. else
  6963. {
  6964. msg = "修改失败!";
  6965. jw = JsonView(isTrue, msg);
  6966. }
  6967. }
  6968. else
  6969. {
  6970. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6971. }
  6972. return Ok(jw);
  6973. }
  6974. /// <summary>
  6975. /// 导出收款账单
  6976. /// </summary>
  6977. /// <param name="dto"></param>
  6978. /// <returns></returns>
  6979. [HttpPost]
  6980. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6981. {
  6982. if (dto.Diid == 0)
  6983. {
  6984. return Ok(JsonView(false, "请传递团组id"));
  6985. }
  6986. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6987. if (deleInfo.Code != 0)
  6988. {
  6989. return Ok(JsonView(false, "团组信息查询失败!"));
  6990. }
  6991. var di = deleInfo.Data as DelegationInfoWebView;
  6992. if (di != null)
  6993. {
  6994. //文件名
  6995. string strFileName = di.TeamName + "-收款账单.doc";
  6996. //获取模板
  6997. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6998. //载入模板
  6999. Document doc = new Document(tmppath);
  7000. decimal TotalPrice = 0.00M;
  7001. string itemStr = string.Empty;
  7002. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  7003. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7004. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7005. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7006. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7007. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7008. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7009. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7010. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7011. foreach (var cost in groupCostType)
  7012. {
  7013. var List = cost.ToList();
  7014. if (cost.Key == "A")
  7015. {
  7016. foreach (var ListItem in List)
  7017. {
  7018. if (ListItem.number > 0)
  7019. {
  7020. if (ListItem.code.Contains("TBR"))
  7021. {
  7022. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7023. }
  7024. else
  7025. {
  7026. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7027. }
  7028. TotalPrice += (ListItem.number * ListItem.price);
  7029. }
  7030. }
  7031. }
  7032. else
  7033. {
  7034. itemStr = itemStr.Insert(0, "A段\r\n");
  7035. itemStr += "B段\r\n";
  7036. foreach (var ListItem in List)
  7037. {
  7038. if (ListItem.number > 0)
  7039. {
  7040. if (ListItem.code.Contains("TBR"))
  7041. {
  7042. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7043. }
  7044. else
  7045. {
  7046. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7047. }
  7048. TotalPrice += (ListItem.number * ListItem.price);
  7049. }
  7050. }
  7051. }
  7052. }
  7053. #region 替换Word模板书签内容
  7054. Dictionary<string, string> marks = new Dictionary<string, string>();
  7055. marks.Add("To", di.ClientUnit);//付款方
  7056. marks.Add("ToTel", di.TellPhone);//付款方电话
  7057. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7058. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7059. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7060. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7061. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7062. marks.Add("WeChat", "WeChat");//微信号 di.WeChat;
  7063. marks.Add("PayItemContent", itemStr);//详细信息
  7064. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7065. #endregion
  7066. ////注
  7067. //if (doc.Range.Bookmarks["Attention"] != null)
  7068. //{
  7069. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7070. // mark.Text = frList[0].Attention;
  7071. //}
  7072. foreach (var item in marks.Keys)
  7073. {
  7074. if (doc.Range.Bookmarks[item] != null)
  7075. {
  7076. Bookmark mark = doc.Range.Bookmarks[item];
  7077. mark.Text = marks[item];
  7078. }
  7079. }
  7080. byte[] bytes = null;
  7081. using (MemoryStream stream = new MemoryStream())
  7082. {
  7083. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7084. bytes = stream.ToArray();
  7085. }
  7086. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7087. return Ok(JsonView(true, "", new
  7088. {
  7089. Data = bytes,
  7090. strFileName,
  7091. }));
  7092. }
  7093. else
  7094. {
  7095. return Ok(JsonView(false, "团组信息不存在!"));
  7096. }
  7097. }
  7098. /// <summary>
  7099. /// 导出团组成本
  7100. /// </summary>
  7101. /// <param name="dto"></param>
  7102. /// <returns></returns>
  7103. [HttpPost]
  7104. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7105. {
  7106. var jw = JsonView(false);
  7107. if (dto.Diid == 0)
  7108. {
  7109. return Ok(JsonView(false, "请传递团组id"));
  7110. }
  7111. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7112. if (deleInfo.Code != 0)
  7113. {
  7114. return Ok(JsonView(false, "团组信息查询失败!"));
  7115. }
  7116. var di = deleInfo.Data as DelegationInfoWebView;
  7117. if (di == null)
  7118. {
  7119. return Ok(JsonView(false, "团组信息查询失败!"));
  7120. }
  7121. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7122. WorkbookDesigner designer = new WorkbookDesigner();
  7123. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7124. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7125. for (int i = 0; i < List_GC.Count; i++)
  7126. {
  7127. GroupCost_Excel gc = new GroupCost_Excel();
  7128. gc.Id = List_GC[i].Id;
  7129. gc.Diid = List_GC[i].Diid.ToString();
  7130. gc.DAY = List_GC[i].DAY;
  7131. string week = "";
  7132. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7133. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7134. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7135. gc.ITIN = List_GC[i].ITIN;
  7136. gc.CarType = List_GC[i].CarType;
  7137. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7138. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7139. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7140. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7141. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7142. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7143. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7144. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7145. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7146. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7147. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7148. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7149. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7150. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7151. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7152. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7153. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7154. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7155. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7156. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7157. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7158. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7159. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7160. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7161. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7162. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7163. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7164. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7165. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7166. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7167. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7168. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7169. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7170. List_GC1.Add(gc);
  7171. }
  7172. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7173. dt.TableName = "TB";
  7174. //报表标题等不用dt的值
  7175. designer.SetDataSource("TeamName", dto.title.TeamName);
  7176. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7177. designer.SetDataSource("Tax", dto.title.Tax);
  7178. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7179. designer.SetDataSource("Currency", dto.title.Currency);
  7180. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7181. designer.SetDataSource("Rate", dto.title.Rate);
  7182. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7183. var Aparams = hotels.Find(x => x.Type == "Default");
  7184. if (Aparams == null)
  7185. {
  7186. return Ok(jw);
  7187. }
  7188. //酒店数量
  7189. var txtSGRNumber = Aparams.SGR.ToString();
  7190. var txtTBRNumber = Aparams.TBR.ToString();
  7191. var txtJSESNumber = Aparams.JSES.ToString();
  7192. var txtSUITENumbe = Aparams.SUITE.ToString();
  7193. if (dto.costType == "B")
  7194. {
  7195. Aparams = hotels.Find(x => x.Type == "A");
  7196. var Bparams = hotels.Find(x => x.Type == "B");
  7197. if (Aparams == null || Bparams == null)
  7198. {
  7199. return Ok(jw);
  7200. }
  7201. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7202. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7203. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7204. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7205. }
  7206. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7207. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7208. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7209. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7210. var ws = designer.Workbook.Worksheets[0];
  7211. int Row = List_GC.Count;
  7212. int startIndex = 11;
  7213. int HideRows = 0;
  7214. List<int> hideRowsList = new List<int>();
  7215. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7216. #region A段left数据
  7217. var left = dto.leftInfo.Find(x => x.Type == "A");
  7218. if (left == null)
  7219. {
  7220. return Ok(jw);
  7221. }
  7222. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7223. if (leftBindData != null)
  7224. {
  7225. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7226. designer.SetDataSource("VisaRS", leftBindData.rs);
  7227. designer.SetDataSource("VisaXS", leftBindData.xs);
  7228. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7229. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7230. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7231. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7232. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7233. }
  7234. else
  7235. {
  7236. hideRowsList.Add(Row + startIndex + HideRows);
  7237. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7238. }
  7239. HideRows += 2;
  7240. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7241. if (leftBindData != null)
  7242. {
  7243. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7244. designer.SetDataSource("BXRS", leftBindData.rs);
  7245. designer.SetDataSource("BXXS", leftBindData.xs);
  7246. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7247. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7248. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7249. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7250. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7251. }
  7252. else
  7253. {
  7254. hideRowsList.Add(Row + startIndex + HideRows);
  7255. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7256. }
  7257. HideRows += 2;
  7258. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7259. if (leftBindData != null)
  7260. {
  7261. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7262. designer.SetDataSource("HSRS", leftBindData.rs);
  7263. designer.SetDataSource("HSXS", leftBindData.xs);
  7264. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7265. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7266. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7267. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7268. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7269. }
  7270. else
  7271. {
  7272. hideRowsList.Add(Row + startIndex + HideRows);
  7273. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7274. }
  7275. HideRows += 2;
  7276. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7277. if (leftBindData != null)
  7278. {
  7279. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7280. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7281. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7282. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7283. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7284. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7285. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7286. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7287. }
  7288. else
  7289. {
  7290. hideRowsList.Add(Row + startIndex + HideRows);
  7291. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7292. }
  7293. HideRows += 2;
  7294. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7295. if (leftBindData != null)
  7296. {
  7297. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7298. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7299. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7300. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7301. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7302. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7303. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7304. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7305. }
  7306. else
  7307. {
  7308. hideRowsList.Add(Row + startIndex + HideRows);
  7309. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7310. }
  7311. HideRows += 2;
  7312. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7313. if (leftBindData != null)
  7314. {
  7315. ////TBR
  7316. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7317. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7318. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7319. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7320. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7321. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7322. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7323. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7324. }
  7325. else
  7326. {
  7327. hideRowsList.Add(Row + startIndex + HideRows);
  7328. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7329. }
  7330. HideRows += 2;
  7331. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7332. if (leftBindData != null)
  7333. {
  7334. ////SGR
  7335. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7336. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7337. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7338. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7339. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7340. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7341. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7342. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7343. }
  7344. else
  7345. {
  7346. hideRowsList.Add(Row + startIndex + HideRows);
  7347. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7348. }
  7349. HideRows += 2;
  7350. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7351. if (leftBindData != null)
  7352. {
  7353. ////JS/ES
  7354. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7355. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7356. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7357. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7358. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7359. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7360. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7361. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7362. }
  7363. else
  7364. {
  7365. hideRowsList.Add(Row + startIndex + HideRows);
  7366. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7367. }
  7368. HideRows += 2;
  7369. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7370. if (leftBindData != null)
  7371. {
  7372. ////SUITE
  7373. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7374. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7375. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7376. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7377. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7378. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7379. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7380. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7381. }
  7382. else
  7383. {
  7384. hideRowsList.Add(Row + startIndex + HideRows);
  7385. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7386. }
  7387. HideRows += 2;
  7388. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7389. if (leftBindData != null)
  7390. {
  7391. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7392. designer.SetDataSource("DJRS", leftBindData.rs);
  7393. designer.SetDataSource("DJXS", leftBindData.xs);
  7394. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7395. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7396. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7397. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7398. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7399. }
  7400. else
  7401. {
  7402. hideRowsList.Add(Row + startIndex + HideRows);
  7403. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7404. }
  7405. HideRows += 2;
  7406. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7407. if (leftBindData != null)
  7408. {
  7409. designer.SetDataSource("HCPCB", leftBindData.cb);
  7410. designer.SetDataSource("HCPRS", leftBindData.rs);
  7411. designer.SetDataSource("HCPXS", leftBindData.xs);
  7412. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7413. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7414. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7415. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7416. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7417. }
  7418. else
  7419. {
  7420. hideRowsList.Add(Row + startIndex + HideRows);
  7421. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7422. }
  7423. HideRows += 2;
  7424. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7425. if (leftBindData != null)
  7426. {
  7427. designer.SetDataSource("CPCB", leftBindData.cb);
  7428. designer.SetDataSource("CPRS", leftBindData.rs);
  7429. designer.SetDataSource("CPXS", leftBindData.xs);
  7430. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7431. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7432. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7433. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7434. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7435. }
  7436. else
  7437. {
  7438. hideRowsList.Add(Row + startIndex + HideRows);
  7439. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7440. }
  7441. HideRows += 2;
  7442. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7443. if (leftBindData != null)
  7444. {
  7445. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7446. designer.SetDataSource("GWRS", leftBindData.rs);
  7447. designer.SetDataSource("GWXS", leftBindData.xs);
  7448. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7449. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7450. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7451. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7452. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7453. }
  7454. else
  7455. {
  7456. hideRowsList.Add(Row + startIndex + HideRows);
  7457. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7458. }
  7459. HideRows += 2;
  7460. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7461. if (leftBindData != null)
  7462. {
  7463. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7464. designer.SetDataSource("LYJRS", leftBindData.rs);
  7465. designer.SetDataSource("LYJXS", leftBindData.xs);
  7466. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7467. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7468. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7469. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7470. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7471. }
  7472. else
  7473. {
  7474. hideRowsList.Add(Row + startIndex + HideRows);
  7475. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7476. }
  7477. #endregion
  7478. #region A段Right信息
  7479. var right = dto.rightInfo.Find(x => x.Type == "A");
  7480. if (right == null)
  7481. {
  7482. return Ok(jw);
  7483. }
  7484. HideRows += 4;
  7485. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7486. if (rightBindData != null)
  7487. {
  7488. //经济舱 + 双人间 TBR
  7489. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7490. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7491. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7492. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7493. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7494. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7495. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7496. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7497. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7498. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7499. }
  7500. else
  7501. {
  7502. hideRowsList.Add(Row + startIndex + HideRows);
  7503. }
  7504. HideRows += 2;
  7505. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7506. if (rightBindData != null)
  7507. {
  7508. //经济舱 + 单人间 SGR
  7509. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7510. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7511. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7512. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7513. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7514. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7515. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7516. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7517. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7518. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7519. }
  7520. else
  7521. {
  7522. hideRowsList.Add(Row + startIndex + HideRows);
  7523. }
  7524. HideRows += 2;
  7525. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7526. if (rightBindData != null)
  7527. {
  7528. //公务舱 + 单人间 SGR
  7529. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7530. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7531. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7532. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7533. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7534. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7535. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7536. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7537. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7538. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7539. }
  7540. else
  7541. {
  7542. hideRowsList.Add(Row + startIndex + HideRows);
  7543. }
  7544. HideRows += 2;
  7545. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7546. if (rightBindData != null)
  7547. {
  7548. //公务舱 + 小套房 JSES
  7549. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7550. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7551. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7552. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7553. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7554. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7555. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7556. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7557. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7558. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7559. }
  7560. else
  7561. {
  7562. hideRowsList.Add(Row + startIndex + HideRows);
  7563. }
  7564. HideRows += 2;
  7565. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7566. if (rightBindData != null)
  7567. {
  7568. //公务舱 + 小套房 JSES
  7569. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7570. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7571. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7572. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7573. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7574. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7575. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7576. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7577. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7578. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7579. }
  7580. else
  7581. {
  7582. hideRowsList.Add(Row + startIndex + HideRows);
  7583. }
  7584. HideRows += 2;
  7585. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7586. if (rightBindData != null)
  7587. {
  7588. //经济舱 + 大套房
  7589. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7590. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7591. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7592. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7593. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7594. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7595. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7596. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7597. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7598. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7599. }
  7600. else
  7601. {
  7602. hideRowsList.Add(Row + startIndex + HideRows);
  7603. }
  7604. #endregion
  7605. #region B段标题清空
  7606. designer.SetDataSource("CostBDRCB", "");
  7607. designer.SetDataSource("CostBRS", "");
  7608. designer.SetDataSource("CostBXS", "");
  7609. designer.SetDataSource("CostBZCB", "");
  7610. designer.SetDataSource("CostBDRBJ", "");
  7611. designer.SetDataSource("CostBZBJ", "");
  7612. designer.SetDataSource("CostBDRLR", "");
  7613. designer.SetDataSource("CostBZLR", "");
  7614. designer.SetDataSource("CostBDRCBOM", "");
  7615. designer.SetDataSource("CostBRSOM", "");
  7616. designer.SetDataSource("CostBZCBOM", "");
  7617. designer.SetDataSource("CostBDRBJOM", "");
  7618. designer.SetDataSource("CostBZBJOM", "");
  7619. designer.SetDataSource("CostBDRLROM", "");
  7620. designer.SetDataSource("CostBZLROM", "");
  7621. #endregion
  7622. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7623. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7624. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7625. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7626. designer.SetDataSource("DJName", "地接(CNY)");
  7627. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7628. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7629. designer.SetDataSource("GWName", "公务(CNY)");
  7630. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7631. designer.SetDataSource("LYJName", "零用金(CNY)");
  7632. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7633. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7634. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7635. designer.SetDataSource("BXName", "保险(CNY)");
  7636. designer.SetDataSource("VisaName", "签证(CNY)");
  7637. #region B段基本数据
  7638. if (dto.costType == "B")
  7639. {
  7640. left = dto.leftInfo.Find(x => x.Type == "B");
  7641. if (left == null)
  7642. {
  7643. return Ok(jw);
  7644. }
  7645. #region B段left数据
  7646. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7647. if (leftBindData != null)
  7648. {
  7649. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7650. designer.SetDataSource("BHSRS", leftBindData.rs);
  7651. designer.SetDataSource("BHSXS", leftBindData.xs);
  7652. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7653. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7654. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7655. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7656. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7657. }
  7658. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7659. if (leftBindData != null)
  7660. {
  7661. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7662. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7663. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7664. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7665. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7666. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7667. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7668. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7669. }
  7670. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7671. if (leftBindData != null)
  7672. {
  7673. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7674. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7675. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7676. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7677. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7678. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7679. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7680. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7681. }
  7682. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7683. if (leftBindData != null)
  7684. {
  7685. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7686. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7687. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7688. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7689. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7690. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7691. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7692. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7693. }
  7694. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7695. if (leftBindData != null)
  7696. {
  7697. designer.SetDataSource("BCPCB", leftBindData.cb);
  7698. designer.SetDataSource("BCPRS", leftBindData.rs);
  7699. designer.SetDataSource("BCPXS", leftBindData.xs);
  7700. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7701. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7702. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7703. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7704. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7705. }
  7706. //TBR
  7707. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7708. if (leftBindData != null)
  7709. {
  7710. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7711. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7712. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7713. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7714. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7715. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7716. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7717. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7718. }
  7719. //SGR
  7720. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7721. if (leftBindData != null)
  7722. {
  7723. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7724. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7725. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7726. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7727. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7728. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7729. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7730. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7731. }
  7732. //JS/ES
  7733. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7734. if (leftBindData != null)
  7735. {
  7736. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7737. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7738. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7739. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7740. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7741. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7742. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7743. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7744. }
  7745. //SUITE
  7746. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7747. if (leftBindData != null)
  7748. {
  7749. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7750. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7751. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7752. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7753. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7754. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7755. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7756. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7757. }
  7758. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7759. if (leftBindData != null)
  7760. {
  7761. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7762. designer.SetDataSource("BDJRS", leftBindData.rs);
  7763. designer.SetDataSource("BDJXS", leftBindData.xs);
  7764. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7765. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7766. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7767. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7768. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7769. }
  7770. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7771. if (leftBindData != null)
  7772. {
  7773. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7774. designer.SetDataSource("BGWRS", leftBindData.rs);
  7775. designer.SetDataSource("BGWXS", leftBindData.xs);
  7776. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7777. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7778. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7779. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7780. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7781. }
  7782. #region 优化方案
  7783. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7784. //excelBind.Add("零用金", new {
  7785. //cb="",
  7786. //rs="",
  7787. //xs ="",
  7788. //zcb = "",
  7789. //});
  7790. #endregion
  7791. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7792. if (leftBindData != null)
  7793. {
  7794. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7795. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7796. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7797. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7798. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7799. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7800. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7801. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7802. }
  7803. #endregion
  7804. #region B段Right信息
  7805. right = dto.rightInfo.Find(x => x.Type == "B");
  7806. if (right == null)
  7807. {
  7808. return Ok(jw);
  7809. }
  7810. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7811. if (rightBindData != null)
  7812. {
  7813. //经济舱 + 双人间 TBR
  7814. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7815. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7816. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7817. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7818. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7819. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7820. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7821. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7822. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7823. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7824. }
  7825. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7826. if (rightBindData != null)
  7827. {
  7828. //经济舱 + 单人间 SGR
  7829. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7830. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7831. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7832. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7833. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7834. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7835. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7836. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7837. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7838. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7839. }
  7840. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7841. if (rightBindData != null)
  7842. {
  7843. //公务舱 + 单人间 SGR
  7844. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7845. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7846. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7847. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7848. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7849. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7850. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7851. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7852. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7853. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7854. }
  7855. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7856. if (rightBindData != null)
  7857. {
  7858. //公务舱 + 小套房 JSES
  7859. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7860. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7861. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7862. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7863. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7864. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7865. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7866. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7867. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7868. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7869. }
  7870. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7871. if (rightBindData != null)
  7872. {
  7873. //公务舱 + 小套房 JSES
  7874. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7875. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7876. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7877. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7878. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7879. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7880. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7881. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7882. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7883. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7884. }
  7885. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7886. if (rightBindData != null)
  7887. {
  7888. //经济舱 + 大套房
  7889. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7890. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7891. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7892. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7893. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7894. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7895. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7896. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7897. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7898. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7899. }
  7900. #endregion
  7901. #region 标题
  7902. designer.SetDataSource("CostBDRCB", "单人成本");
  7903. designer.SetDataSource("CostBRS", "人数");
  7904. designer.SetDataSource("CostBXS", "系数");
  7905. designer.SetDataSource("CostBZCB", "总成本");
  7906. designer.SetDataSource("CostBDRBJ", "单人报价");
  7907. designer.SetDataSource("CostBZBJ", "总报价");
  7908. designer.SetDataSource("CostBDRLR", "单人利润");
  7909. designer.SetDataSource("CostBZLR", "总利润");
  7910. designer.SetDataSource("CostBDRCBOM", "单人成本");
  7911. designer.SetDataSource("CostBRSOM", "人数");
  7912. designer.SetDataSource("CostBZCBOM", "总成本");
  7913. designer.SetDataSource("CostBDRBJOM", "单人报价");
  7914. designer.SetDataSource("CostBZBJOM", "总报价");
  7915. designer.SetDataSource("CostBDRLROM", "单人利润");
  7916. designer.SetDataSource("CostBZLROM", "总利润");
  7917. #endregion
  7918. }
  7919. #endregion
  7920. designer.SetDataSource("TzZCB2", TzZCB2);
  7921. designer.SetDataSource("TzZBJ2", TzZBJ2);
  7922. designer.SetDataSource("TzZLR2", TzZLR2);
  7923. string[] dataSourceKeys = new string[]
  7924. {
  7925. "VF",
  7926. "TGS",
  7927. "TGOF",
  7928. "TGM",
  7929. "TGA",
  7930. "TGTF",
  7931. "TGEF",
  7932. "CFM",
  7933. "CFOF",
  7934. "B",
  7935. "L",
  7936. "D",
  7937. "TBR",
  7938. "SGR",
  7939. "JSES",
  7940. "Suite",
  7941. "TV",
  7942. "1L",
  7943. "IF",
  7944. "EF",
  7945. "BRF",
  7946. "TE",
  7947. "TGT",
  7948. "DRVT",
  7949. "PC",
  7950. "TLF",
  7951. "ECT"
  7952. };
  7953. foreach (var item in dataSourceKeys)
  7954. {
  7955. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  7956. if (find != null)
  7957. {
  7958. designer.SetDataSource(item, find.text);
  7959. }
  7960. else
  7961. {
  7962. designer.SetDataSource(item, 0);
  7963. }
  7964. }
  7965. designer.SetDataSource(dt);
  7966. //根据数据源处理生成报表内容
  7967. designer.Process();
  7968. designer.Workbook.Worksheets[0].Name = "清单";
  7969. Worksheet sheet = designer.Workbook.Worksheets[0];
  7970. foreach (var Rowindex in hideRowsList)
  7971. {
  7972. ws.Cells.HideRows(Rowindex, 2);
  7973. }
  7974. byte[] bytes = null;
  7975. string strFileName = di.TeamName + "-团组-成本.xls";
  7976. using (MemoryStream stream = new MemoryStream())
  7977. {
  7978. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  7979. bytes = stream.ToArray();
  7980. }
  7981. return Ok(JsonView(true, "", new
  7982. {
  7983. Data = bytes,
  7984. strFileName,
  7985. }));
  7986. }
  7987. /// <summary>
  7988. /// 导出客户报表
  7989. /// </summary>
  7990. /// <returns></returns>
  7991. [HttpPost]
  7992. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  7993. {
  7994. var jw = JsonView(false);
  7995. if (dto.Diid == 0)
  7996. {
  7997. return Ok(JsonView(false, "请传递团组id"));
  7998. }
  7999. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8000. if (deleInfo.Code != 0)
  8001. {
  8002. return Ok(JsonView(false, "团组信息查询失败!"));
  8003. }
  8004. var di = deleInfo.Data as DelegationInfoWebView;
  8005. if (di == null)
  8006. {
  8007. return Ok(JsonView(false, "团组信息查询失败!"));
  8008. }
  8009. //文件名
  8010. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8011. //获取模板
  8012. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8013. //载入模板
  8014. Document doc = new Document(tmppath);
  8015. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8016. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8017. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8018. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8019. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8020. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8021. if (AParameter == null)
  8022. {
  8023. return Ok(JsonView(false, "系数不存在!"));
  8024. }
  8025. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8026. , TzAirDesc, TzZCost;
  8027. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8028. = TzAirDesc = TzZCost = string.Empty;
  8029. TzNumber = AParameter.CostTypenumber.ToString();
  8030. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8031. CarGuides1 = dto.CarGuides1;
  8032. Meal = dto.Meal;
  8033. SubsidizedMeals = dto.SubsidizedMeals;
  8034. NightRepair = dto.NightRepair;
  8035. AttractionsTickets = dto.AttractionsTickets;
  8036. MiscellaneousFees = dto.MiscellaneousFees;
  8037. ATip = dto.ATip;
  8038. TzHotelDesc = "";
  8039. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8040. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8041. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8042. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8043. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8044. TzAirDesc = "";
  8045. TzZCost = dto.TzZCost;
  8046. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8047. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8048. var index = 1;
  8049. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8050. foreach (var item in TzHotelDescArr)
  8051. {
  8052. if (AinfoArr != null)
  8053. {
  8054. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8055. if (Ainfo != null)
  8056. {
  8057. if (int.Parse(Ainfo.rs) <= 0)
  8058. {
  8059. continue;
  8060. }
  8061. var hotelText = string.Empty;
  8062. switch (item)
  8063. {
  8064. case "SGR":
  8065. hotelText = "单人间";
  8066. break;
  8067. case "JSES":
  8068. hotelText = "小套房";
  8069. break;
  8070. case "SUITE":
  8071. hotelText = "套房";
  8072. break;
  8073. case "TBR":
  8074. hotelText = "双人间";
  8075. break;
  8076. }
  8077. if (item != "TBR")
  8078. {
  8079. 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";
  8080. }
  8081. else
  8082. {
  8083. 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";
  8084. }
  8085. index++;
  8086. }
  8087. }
  8088. }
  8089. index = 1;
  8090. foreach (var item in TzAirDescArr)
  8091. {
  8092. if (AinfoArr != null)
  8093. {
  8094. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8095. if (Ainfo != null)
  8096. {
  8097. if (int.Parse(Ainfo.rs) <= 0)
  8098. {
  8099. continue;
  8100. }
  8101. 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";
  8102. index++;
  8103. }
  8104. }
  8105. }
  8106. if (dto.costType == "B")
  8107. {
  8108. if (BParameter == null)
  8109. {
  8110. return Ok(JsonView(false, "B段系数不存在!"));
  8111. }
  8112. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8113. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8114. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8115. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8116. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8117. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8118. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8119. foreach (var item in TzHotelDescArr)
  8120. {
  8121. if (AinfoArr != null)
  8122. {
  8123. TzHotelDesc += "B段信息 \r\n";
  8124. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8125. if (Ainfo != null)
  8126. {
  8127. if (int.Parse(Ainfo.rs) <= 0)
  8128. {
  8129. continue;
  8130. }
  8131. var hotelText = string.Empty;
  8132. switch (item)
  8133. {
  8134. case "SGR":
  8135. hotelText = "单人间";
  8136. break;
  8137. case "JSES":
  8138. hotelText = "小套房";
  8139. break;
  8140. case "SUITE":
  8141. hotelText = "套房";
  8142. break;
  8143. case "TBR":
  8144. hotelText = "双人间";
  8145. break;
  8146. }
  8147. if (item != "TBR")
  8148. {
  8149. 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";
  8150. }
  8151. else
  8152. {
  8153. 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";
  8154. }
  8155. index++;
  8156. }
  8157. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8158. }
  8159. }
  8160. index = 1;
  8161. foreach (var item in TzAirDescArr)
  8162. {
  8163. if (AinfoArr != null)
  8164. {
  8165. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8166. if (Ainfo != null)
  8167. {
  8168. if (int.Parse(Ainfo.rs) <= 0)
  8169. {
  8170. continue;
  8171. }
  8172. 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";
  8173. index++;
  8174. }
  8175. }
  8176. }
  8177. }
  8178. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8179. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8180. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8181. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8182. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8183. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8184. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8185. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8186. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8187. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8188. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8189. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8190. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8191. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8192. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8193. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8194. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8195. DickeyValue.Add("TzZCost", TzZCost);
  8196. foreach (var key in DickeyValue.Keys)
  8197. {
  8198. if (doc.Range.Bookmarks[key] != null)
  8199. {
  8200. Bookmark mark = doc.Range.Bookmarks[key];
  8201. mark.Text = DickeyValue[key];
  8202. }
  8203. }
  8204. byte[] bytes = null;
  8205. string strFileName = di.TeamName + "-客户报价.doc";
  8206. using (MemoryStream stream = new MemoryStream())
  8207. {
  8208. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8209. bytes = stream.ToArray();
  8210. }
  8211. return Ok(JsonView(true, "", new
  8212. {
  8213. Data = bytes,
  8214. strFileName,
  8215. }));
  8216. }
  8217. /// <summary>
  8218. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8219. /// </summary>
  8220. /// <param name="dto"></param>
  8221. /// <returns></returns>
  8222. [HttpPost]
  8223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8224. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8225. {
  8226. try
  8227. {
  8228. #region 参数验证
  8229. if (dto.DiId < 0)
  8230. {
  8231. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8232. }
  8233. List<int> cTableIds = new List<int>() {
  8234. 76 ,//酒店预订
  8235. 77 ,//行程
  8236. 79 ,//车/导游地接
  8237. 80 ,//签证
  8238. 81 ,//邀请/公务活
  8239. 82 ,//团组客户保险
  8240. 85 ,//机票预订
  8241. 98 ,//其他款项
  8242. 285 ,//收款退还
  8243. 751 ,//酒店早餐
  8244. 1015 // 超支费用
  8245. };
  8246. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8247. {
  8248. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8249. }
  8250. #endregion
  8251. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8252. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8253. if (_GroupCostParameters.Count <= 0)
  8254. {
  8255. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8256. }
  8257. if (_GroupCostParameters[0].IsShare == 0)
  8258. {
  8259. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8260. }
  8261. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8262. //处理date为空问题
  8263. if (_GroupCosts.Count > 0)
  8264. {
  8265. for (int i = 0; i < _GroupCosts.Count; i++)
  8266. {
  8267. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8268. {
  8269. if (i > 0)
  8270. {
  8271. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8272. }
  8273. }
  8274. }
  8275. }
  8276. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8277. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8278. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8279. string currCode = "";
  8280. #region currCode 验证
  8281. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8282. if (isInt)
  8283. {
  8284. var currData = currDatas.Find(it => it.Id == intCurrency);
  8285. if (currData != null)
  8286. {
  8287. currCode = currData.Name;
  8288. }
  8289. }
  8290. else
  8291. {
  8292. currCode = _GroupCostParameters[0].Currency.Trim();
  8293. }
  8294. #endregion
  8295. //op,酒店单段模式存储
  8296. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8297. {
  8298. CurrencyCode = currCode,
  8299. Rate = _GroupCostParameters[0].Rate,
  8300. CostType = _GroupCostParameters[0].CostType,
  8301. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8302. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8303. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8304. };
  8305. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8306. if (_GroupCostParameters.Count == 2)
  8307. {
  8308. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8309. }
  8310. foreach (var item in _GroupCostParameters)
  8311. {
  8312. decimal _rate = 1;
  8313. decimal _rate1 = item.Rate;
  8314. decimal _scale = 1;
  8315. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8316. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8317. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8318. //if (userInfo != null)
  8319. //{
  8320. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8321. // {
  8322. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8323. // {
  8324. // _scale = 1.00M;
  8325. // }
  8326. // }
  8327. //}
  8328. #endregion
  8329. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8330. {
  8331. CurrencyCode = currCode,
  8332. Rate = _rate1,
  8333. CostType = item.CostType,
  8334. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8335. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8336. CostTypeNumber = item.CostTypenumber
  8337. };
  8338. if (_GroupCostParameters.Count > 1)
  8339. {
  8340. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8341. }
  8342. else
  8343. {
  8344. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8345. }
  8346. if (dto.CTable == 79)//
  8347. {
  8348. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8349. modulePromptInfo.TotalCost = item.DJCB;
  8350. }
  8351. List<string> costTypes = new List<string>() { "A", "B" };
  8352. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8353. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8354. if (_GroupCostsDuplicates.Count() == 1)
  8355. {
  8356. _GroupCostsTypeData = _GroupCosts;
  8357. }
  8358. else
  8359. {
  8360. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8361. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8362. }
  8363. /*
  8364. * 76 酒店预订
  8365. * 77 行程
  8366. * 79 车/导游地接
  8367. * 80 签证
  8368. * 81 邀请/公务活动
  8369. * 82 团组客户保险
  8370. * 85 机票预订
  8371. * 98 其他款项
  8372. * 285 收款退还
  8373. * 751 酒店早餐
  8374. * 1015 超支费用
  8375. */
  8376. switch (dto.CTable)
  8377. {
  8378. case 76: // 酒店预订
  8379. _ModuleSubPromptInfo.AddRange(
  8380. _GroupCostsTypeData.Select(it => new
  8381. {
  8382. it.DAY,
  8383. it.Date,
  8384. it.ACCON,
  8385. it.ITIN,
  8386. it.SGR,
  8387. it.TBR,
  8388. it.JS_ES,
  8389. it.Suite
  8390. })
  8391. );
  8392. break;
  8393. case 79: // 车/导游地接
  8394. _ModuleSubPromptInfo.AddRange(
  8395. _GroupCostsTypeData.Select(it => new
  8396. {
  8397. Date = it.Date, //日期
  8398. CarFee = (it.CarCost + it.CFM + it.CFOF) * _rate * _scale, //车费用
  8399. GuideFee = (it.TGS + it.TGOF + it.TGM + it.TGA + it.TGTF + it.TGEF) * _rate * _scale, //导游费用
  8400. MealFee = (it.B + it.L + it.D) * _rate * _scale, //餐食费
  8401. TicketFee = it.EF * _rate * _scale, //门票费
  8402. TipFee = (it.TGTips + it.DRVTips) * _rate * _scale, //小费
  8403. AirportTransferFee = 0.00M,
  8404. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8405. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8406. LeadersFee = it.TLF * _rate * _scale, //领队费
  8407. CarFee1 = it.CarCost * _rate * _scale,
  8408. CarType = it.CarType, //车型
  8409. SpentCash = it.PC * _rate * _scale, //零用金
  8410. })
  8411. );
  8412. break;
  8413. case 85: // 机票
  8414. List<dynamic> datas = new List<dynamic>();
  8415. datas.Add(
  8416. new
  8417. {
  8418. AirType = "经济舱",
  8419. AirNum = item.JJCRS,
  8420. AirDRCB = item.JJCCB,
  8421. AirZCB = (item.JJCRS * item.JJCCB)
  8422. }
  8423. );
  8424. datas.Add(
  8425. new
  8426. {
  8427. AirType = "公务舱",
  8428. AirNum = item.GWCRS,
  8429. AirDRCB = item.GWCCB,
  8430. AirZCB = (item.GWCRS * item.GWCCB)
  8431. }
  8432. );
  8433. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8434. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8435. modulePromptInfo.Data = new {
  8436. airFeeData = datas,
  8437. airInitData = initDatas
  8438. };
  8439. _ModulePromptInfos.Add(modulePromptInfo);
  8440. break;
  8441. default:
  8442. break;
  8443. }
  8444. }
  8445. if (dto.CTable != 85)
  8446. {
  8447. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8448. _ModulePromptInfos.Add(_ModulePromptInfo);
  8449. }
  8450. _view.ModulePromptInfos = _ModulePromptInfos;
  8451. return Ok(JsonView(true, "操作成功!", _view));
  8452. }
  8453. catch (Exception ex)
  8454. {
  8455. return Ok(JsonView(false, ex.Message));
  8456. }
  8457. }
  8458. /// <summary>
  8459. /// 根据黑屏代码重新生成行程
  8460. /// </summary>
  8461. /// <param name="dto"></param>
  8462. /// <returns></returns>
  8463. [HttpPost]
  8464. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8465. {
  8466. var jw = JsonView(false);
  8467. var Create = _GroupCostRepository.
  8468. CreateGroupCostByBlackCode(dto.Diid);
  8469. jw.Msg = Create.Msg;
  8470. if (Create.Code == 0)
  8471. {
  8472. jw.Code = 200;
  8473. jw.Data = new
  8474. {
  8475. groupCost = Create.Data,
  8476. blackCodeIsTrue = true
  8477. };
  8478. }
  8479. else
  8480. {
  8481. jw.Code = 400;
  8482. jw.Data = new
  8483. {
  8484. groupCost = Create.Data,
  8485. blackCodeIsTrue = false,
  8486. };
  8487. }
  8488. return Ok(jw);
  8489. }
  8490. /// <summary>
  8491. /// 成本获取OP历史车费用
  8492. /// </summary>
  8493. /// <param name="dto"></param>
  8494. /// <returns></returns>
  8495. [HttpPost]
  8496. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8497. {
  8498. var jw = JsonView(false);
  8499. try
  8500. {
  8501. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8502. //获取现有所有车的数据
  8503. if (!dto.Param.IsNullOrWhiteSpace())
  8504. {
  8505. string sql = $@"
  8506. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8507. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8508. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8509. 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
  8510. AND gctggr.ServiceEndTime is not NULL
  8511. ORDER by gctggrc.id DESC
  8512. ";
  8513. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8514. var numeberResult = await Task.Run(() =>
  8515. {
  8516. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8517. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8518. return numberArr;
  8519. });
  8520. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8521. foreach (var item in numeberResult)
  8522. {
  8523. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8524. {
  8525. Country = "数据异常!",
  8526. City = string.Empty,
  8527. };
  8528. item.Area = find.Country + " " + find.City;
  8529. }
  8530. dbResult.AddRange(numeberResult);
  8531. if (dto.Param.Contains("、"))
  8532. {
  8533. var sp = dto.Param.Split("、");
  8534. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8535. .Where(x =>
  8536. {
  8537. return System.Array.Exists(sp, e =>
  8538. {
  8539. bool where = false;
  8540. if (x.Area != null)
  8541. {
  8542. where = x.Area.Contains(e);
  8543. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8544. {
  8545. return false;
  8546. }
  8547. }
  8548. if (x.PriceName != null && !where)
  8549. {
  8550. where = x.PriceName.Contains(e);
  8551. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8552. {
  8553. return false;
  8554. }
  8555. }
  8556. return where;
  8557. });
  8558. }).ToList();
  8559. }
  8560. else
  8561. {
  8562. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8563. .Where(x =>
  8564. {
  8565. bool where = false;
  8566. if (x.Area != null)
  8567. {
  8568. where = x.Area.Contains(dto.Param);
  8569. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8570. {
  8571. return false;
  8572. }
  8573. }
  8574. if (x.PriceName != null && !where)
  8575. {
  8576. where = x.PriceName.Contains(dto.Param);
  8577. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8578. {
  8579. return false;
  8580. }
  8581. }
  8582. return where;
  8583. }
  8584. )
  8585. .ToList();
  8586. }
  8587. }
  8588. var view = dbResult.Select(x => {
  8589. decimal dp = 0.00M;
  8590. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8591. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8592. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8593. {
  8594. if (startB && endB)
  8595. {
  8596. var timesp = endD.Subtract(startD);
  8597. if ((timesp.Days + 1) != 0)
  8598. {
  8599. dp = x.Price / (timesp.Days + 1);
  8600. }
  8601. }
  8602. }
  8603. else
  8604. {
  8605. dp = x.Price;
  8606. }
  8607. return new
  8608. {
  8609. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8610. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8611. x.Area,
  8612. x.id,
  8613. price = x.Price.ToString("F2"),
  8614. x.PriceName,
  8615. x.PriceContent,
  8616. x.TeamName,
  8617. x.DatePrice,
  8618. dayPrice = dp.ToString("F2"),
  8619. };
  8620. }).OrderByDescending(x => x.id).ToList();
  8621. jw = JsonView(true, "获取成功!", view);
  8622. }
  8623. catch (Exception e)
  8624. {
  8625. jw = JsonView(false, e.Message);
  8626. }
  8627. return Ok(jw);
  8628. }
  8629. #endregion
  8630. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8631. /// <summary>
  8632. /// 酒店预订
  8633. /// 酒店费用列表 根据团组Id查询
  8634. /// </summary>
  8635. /// <param name="_dto"></param>
  8636. /// <returns></returns>
  8637. [HttpPost]
  8638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8639. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8640. {
  8641. #region 参数验证
  8642. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8643. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8644. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8645. #region 团组操作权限验证 76 酒店预定模块
  8646. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8647. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8648. #endregion
  8649. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8650. #region 页面操作权限验证
  8651. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8652. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8653. #endregion
  8654. #endregion
  8655. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8656. }
  8657. /// <summary>
  8658. /// 酒店预订
  8659. /// 基础数据
  8660. /// </summary>
  8661. /// <param name="_dto"></param>
  8662. /// <returns></returns>
  8663. [HttpPost]
  8664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8665. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8666. {
  8667. #region 参数验证
  8668. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8669. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8670. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8671. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8672. #region 页面操作权限验证
  8673. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8674. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8675. #endregion
  8676. #region 团组操作权限验证 76 酒店预定模块
  8677. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8678. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8679. #endregion
  8680. #endregion
  8681. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  8682. }
  8683. /// <summary>
  8684. /// 酒店预订
  8685. /// 创建 入住卷号码
  8686. /// </summary>
  8687. /// <param name="_dto"></param>
  8688. /// <returns></returns>
  8689. [HttpPost]
  8690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8691. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8692. {
  8693. try
  8694. {
  8695. #region 参数验证
  8696. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8697. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8698. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8699. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8700. #region 页面操作权限验证
  8701. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8702. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8703. #endregion
  8704. #region 团组操作权限验证 76 酒店预定模块
  8705. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8706. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8707. #endregion
  8708. #endregion
  8709. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8710. if (data.Code != 0)
  8711. {
  8712. return Ok(JsonView(false, data.Msg));
  8713. }
  8714. return Ok(JsonView(true, data.Msg, data.Data));
  8715. }
  8716. catch (Exception ex)
  8717. {
  8718. return Ok(JsonView(false, ex.Message));
  8719. }
  8720. }
  8721. /// <summary>
  8722. /// 酒店预订
  8723. /// 详情
  8724. /// </summary>
  8725. /// <param name="_dto"></param>
  8726. /// <returns></returns>
  8727. [HttpPost]
  8728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8729. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8730. {
  8731. #region 参数验证
  8732. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8733. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8734. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8735. #region 团组操作权限验证 76 酒店预定模块
  8736. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8737. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8738. #endregion
  8739. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8740. #region 页面操作权限验证
  8741. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8742. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8743. #endregion
  8744. #endregion
  8745. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8746. }
  8747. /// <summary>
  8748. /// 酒店预订
  8749. /// Add Or Edit
  8750. /// </summary>
  8751. /// <param name="_dto"></param>
  8752. /// <returns></returns>
  8753. [HttpPost]
  8754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8755. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8756. {
  8757. #region 参数验证
  8758. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8759. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8760. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8761. #region 团组操作权限验证 76 酒店预定模块
  8762. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8763. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8764. #endregion
  8765. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8766. #region 页面操作权限验证
  8767. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8768. if (_dto.Id == 0) // Add
  8769. {
  8770. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8771. }
  8772. else if (_dto.Id > 1) // Edit
  8773. {
  8774. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8775. } else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8776. #endregion
  8777. #endregion
  8778. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8779. if (_view.Code != 200)
  8780. {
  8781. return Ok(_view);
  8782. }
  8783. #region 应用推送
  8784. //TODO:酒店预订费用消息推送 移动端完成后取消注释
  8785. //try
  8786. //{
  8787. // int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8788. // int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8789. // await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8790. //}
  8791. //catch (Exception ex)
  8792. //{
  8793. //}
  8794. #endregion
  8795. return Ok(_view);
  8796. }
  8797. /// <summary>
  8798. /// 酒店预订
  8799. /// Del
  8800. /// </summary>
  8801. /// <param name="_dto"></param>
  8802. /// <returns></returns>
  8803. [HttpPost]
  8804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8805. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  8806. {
  8807. #region 参数验证
  8808. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8809. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8810. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8811. #region 团组操作权限验证 76 酒店预定模块
  8812. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8813. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8814. #endregion
  8815. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8816. #region 页面操作权限验证
  8817. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8818. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  8819. #endregion
  8820. #endregion
  8821. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  8822. }
  8823. /// <summary>
  8824. /// 酒店预订
  8825. /// 生成VOUCHER
  8826. /// 2024.05.06 之前版本
  8827. /// </summary>
  8828. /// <param name="_dto"></param>
  8829. /// <returns></returns>
  8830. [HttpPost]
  8831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8832. public async Task<IActionResult> PostHotelReservationsCreateVoucher1(HotelReservationsCreateVoucherDto _dto)
  8833. {
  8834. try
  8835. {
  8836. #region 参数验证
  8837. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8838. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8839. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8840. #region 团组操作权限验证 76 酒店预定模块
  8841. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8842. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8843. #endregion
  8844. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8845. #region 页面操作权限验证
  8846. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8847. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8848. #endregion
  8849. #endregion
  8850. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  8851. //判断数据是否完整
  8852. if (hr != null)
  8853. {
  8854. if (!string.IsNullOrEmpty(hr.DetermineNo))
  8855. {
  8856. string strFileName = "HotelStatement/";
  8857. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  8858. if (dele != null)
  8859. strFileName += dele.TourCode;
  8860. //载入模板
  8861. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  8862. Document doc = new Document(sss);
  8863. DocumentBuilder builder = new DocumentBuilder(doc);
  8864. #region 替换Word模板书签内容
  8865. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  8866. //入住卷预定号码
  8867. if (doc.Range.Bookmarks["VNO"] != null)
  8868. {
  8869. Bookmark mark = doc.Range.Bookmarks["VNO"];
  8870. mark.Text = hr.CheckNumber;
  8871. }
  8872. //酒店时间
  8873. if (doc.Range.Bookmarks["Date"] != null)
  8874. {
  8875. Bookmark mark = doc.Range.Bookmarks["Date"];
  8876. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8877. }
  8878. //团号
  8879. if (doc.Range.Bookmarks["TNo"] != null)
  8880. {
  8881. Bookmark mark = doc.Range.Bookmarks["TNo"];
  8882. mark.Text = dele.TourCode;
  8883. }
  8884. //预定号码
  8885. if (doc.Range.Bookmarks["BookingId"] != null)
  8886. {
  8887. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  8888. mark.Text = hr.ReservationsNo;
  8889. }
  8890. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  8891. {
  8892. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  8893. mark.Text = hr.DetermineNo;
  8894. }
  8895. //酒店城市
  8896. if (doc.Range.Bookmarks["City"] != null)
  8897. {
  8898. Bookmark mark = doc.Range.Bookmarks["City"];
  8899. mark.Text = hr.City;
  8900. }
  8901. //酒店名称
  8902. if (doc.Range.Bookmarks["HName"] != null)
  8903. {
  8904. Bookmark mark = doc.Range.Bookmarks["HName"];
  8905. mark.Text = hr.HotelName;
  8906. }
  8907. //酒店地址
  8908. if (doc.Range.Bookmarks["Address"] != null)
  8909. {
  8910. Bookmark mark = doc.Range.Bookmarks["Address"];
  8911. mark.Text = hr.HotelAddress;
  8912. }
  8913. //酒店电话
  8914. if (doc.Range.Bookmarks["Tel"] != null)
  8915. {
  8916. Bookmark mark = doc.Range.Bookmarks["Tel"];
  8917. mark.Text = hr.HotelTel;
  8918. }
  8919. //酒店传真
  8920. if (doc.Range.Bookmarks["Fax"] != null)
  8921. {
  8922. Bookmark mark = doc.Range.Bookmarks["Fax"];
  8923. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  8924. {
  8925. mark.Text = hr.HotelFax;
  8926. }
  8927. }
  8928. //入住时间
  8929. if (doc.Range.Bookmarks["CIn"] != null)
  8930. {
  8931. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8932. Bookmark mark = doc.Range.Bookmarks["CIn"];
  8933. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  8934. }
  8935. //退房时间
  8936. if (doc.Range.Bookmarks["COut"] != null)
  8937. {
  8938. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8939. Bookmark mark = doc.Range.Bookmarks["COut"];
  8940. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8941. }
  8942. //客户名称
  8943. if (doc.Range.Bookmarks["GName"] != null)
  8944. {
  8945. string guestName = "";
  8946. string[] clients = new string[] { };
  8947. if (hr.GuestName.Contains(","))
  8948. {
  8949. clients = hr.GuestName.Split(",");
  8950. }
  8951. else
  8952. {
  8953. clients = new string[] { hr.GuestName };
  8954. }
  8955. List<int> clientIds_int = new List<int>();
  8956. if (clients.Length > 0)
  8957. {
  8958. foreach (var item in clients)
  8959. {
  8960. if (item.IsNumeric())
  8961. {
  8962. clientIds_int.Add(int.Parse(item));
  8963. }
  8964. }
  8965. }
  8966. if (clientIds_int.Count > 0)
  8967. {
  8968. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  8969. foreach (var client in _clientDatas)
  8970. {
  8971. //男
  8972. if (client.Sex == 0) guestName += $"Mr.";
  8973. //女
  8974. else if (client.Sex == 1) guestName += $"Ms.";
  8975. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  8976. {
  8977. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  8978. }
  8979. //guestName += $"{client.Pinyin},";
  8980. }
  8981. if (guestName.Length > 0)
  8982. {
  8983. guestName = guestName.Substring(0, guestName.Length - 1);
  8984. }
  8985. }
  8986. else
  8987. {
  8988. guestName = hr.GuestName;
  8989. }
  8990. Bookmark mark = doc.Range.Bookmarks["GName"];
  8991. mark.Text = guestName;
  8992. }
  8993. //房间介绍
  8994. if (doc.Range.Bookmarks["ROOM"] != null)
  8995. {
  8996. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  8997. mark.Text = hr.RoomExplanation;
  8998. }
  8999. //报价描述
  9000. if (doc.Range.Bookmarks["NOTE"] != null)
  9001. {
  9002. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9003. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9004. if (ss != null)
  9005. mark.Text = ss.Name;
  9006. }
  9007. //入住时间
  9008. if (doc.Range.Bookmarks["CheckIn"] != null)
  9009. {
  9010. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9011. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9012. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9013. }
  9014. //退房时间
  9015. if (doc.Range.Bookmarks["CheckOut"] != null)
  9016. {
  9017. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9018. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9019. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9020. }
  9021. //日期
  9022. if (doc.Range.Bookmarks["DT"] != null)
  9023. {
  9024. Bookmark mark = doc.Range.Bookmarks["DT"];
  9025. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9026. }
  9027. //名称
  9028. if (doc.Range.Bookmarks["VName"] != null)
  9029. {
  9030. Bookmark mark = doc.Range.Bookmarks["VName"];
  9031. mark.Text = hr.HotelName;
  9032. }
  9033. //号码
  9034. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9035. {
  9036. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9037. mark.Text = hr.CheckNumber;
  9038. }
  9039. #endregion
  9040. strFileName += "VOUCHER.doc";
  9041. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9042. doc.Save(fileDir);
  9043. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9044. return Ok(JsonView(true, "操作成功!", Url));
  9045. }
  9046. else
  9047. {
  9048. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9049. }
  9050. }
  9051. else
  9052. {
  9053. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9054. }
  9055. }
  9056. catch (Exception ex)
  9057. {
  9058. return Ok(JsonView(false, ex.Message));
  9059. }
  9060. }
  9061. /// <summary>
  9062. /// 酒店预订
  9063. /// 生成VOUCHER
  9064. /// 2024.05.06 之后版本
  9065. /// </summary>
  9066. /// <param name="_dto"></param>
  9067. /// <returns></returns>
  9068. [HttpPost]
  9069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9070. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9071. {
  9072. #region 参数验证
  9073. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9074. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9075. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9076. #region 团组操作权限验证 76 酒店预定模块
  9077. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9078. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9079. #endregion
  9080. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9081. #region 页面操作权限验证
  9082. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9083. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9084. #endregion
  9085. #endregion
  9086. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9087. //判断数据是否完整
  9088. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9089. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9090. string strFileName = "HotelStatement/";
  9091. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9092. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9093. #region 数据处理
  9094. List<int> guestIds = new List<int>();
  9095. int index = 0;
  9096. foreach (var item in hrDtas)
  9097. {
  9098. if (item.GuestName.Contains(","))
  9099. {
  9100. string[] guestIdArr = item.GuestName.Split(',');
  9101. foreach (var guestIdStr in guestIdArr)
  9102. {
  9103. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9104. if (guestBool)
  9105. {
  9106. guestIds.Add(guestId);
  9107. }
  9108. }
  9109. }
  9110. else guestNames += item.GuestName;
  9111. var voucherInfo = new HotelVoucherInfoView()
  9112. {
  9113. HotelName = item.HotelName,
  9114. CheckInDate = item.CheckInDate,
  9115. CheckOutDate = item.CheckOutDate,
  9116. ConfirmationNumber = item.DetermineNo.Trim(),
  9117. RoomType = item.RoomExplanation
  9118. };
  9119. vouchers.Add(voucherInfo);
  9120. }
  9121. if (guestIds.Count > 0)
  9122. {
  9123. guestIds = guestIds.Distinct().ToList();
  9124. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9125. if (guestDatas.Count > 0)
  9126. {
  9127. guestNames = "";
  9128. foreach (var guest in guestDatas)
  9129. {
  9130. string guestName = "";
  9131. if (guest.Sex == 0) guestName += @"MR.";
  9132. else if (guest.Sex == 1) guestName += @"MS.";
  9133. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9134. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9135. guestNames += @$"{guestName.Trim()}、";
  9136. }
  9137. if (guestNames.Length > 0)
  9138. {
  9139. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9140. }
  9141. }
  9142. }
  9143. #endregion
  9144. //载入模板
  9145. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9146. Document doc = new Document(sss);
  9147. DocumentBuilder builder = new DocumentBuilder(doc);
  9148. if (doc.Range.Bookmarks["GuestName"] != null)
  9149. {
  9150. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9151. mark.Text = guestNames;
  9152. }
  9153. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9154. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9155. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9156. for (int i = 1; i <= vouchers.Count; i++)
  9157. {
  9158. HotelVoucherInfoView hviv = vouchers[i - 1];
  9159. builder.MoveToCell(0, i, 0, 0);
  9160. builder.Write(hviv.HotelName);
  9161. builder.MoveToCell(0, i, 1, 0);
  9162. builder.Write(hviv.CheckInDate);
  9163. builder.MoveToCell(0, i, 2, 0);
  9164. builder.Write(hviv.CheckOutDate);
  9165. builder.MoveToCell(0, i, 3, 0);
  9166. builder.Write(hviv.RoomType);
  9167. builder.MoveToCell(0, i, 4, 0);
  9168. builder.Write(hviv.ConfirmationNumber);
  9169. }
  9170. //删除多余行
  9171. int currRowIndex = vouchers.Count + 1;
  9172. int delRows = 21 - currRowIndex;
  9173. if (delRows > 0)
  9174. {
  9175. for (int i = 0; i < delRows; i++)
  9176. {
  9177. table.Rows.RemoveAt(currRowIndex);
  9178. //cultivateRowIndex++;
  9179. }
  9180. }
  9181. strFileName += "VOUCHER.docx";
  9182. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9183. doc.Save(fileDir);
  9184. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9185. return Ok(JsonView(true, "操作成功!", Url));
  9186. }
  9187. /// <summary>
  9188. /// 酒店预订
  9189. /// 生成 预定成本 Excel
  9190. /// </summary>
  9191. /// <param name="_dto"></param>
  9192. /// <returns></returns>
  9193. [HttpPost]
  9194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9195. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  9196. {
  9197. #region 参数验证
  9198. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  9199. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  9200. if (!vadalitorRes.IsValid)
  9201. {
  9202. var errors = new StringBuilder();
  9203. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  9204. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  9205. }
  9206. #region 团组操作权限验证 76 酒店预定模块
  9207. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9208. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9209. #endregion
  9210. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9211. #region 页面操作权限验证
  9212. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9213. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9214. #endregion
  9215. #endregion
  9216. decimal _rate = 1.00M;
  9217. string _currency = "";
  9218. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  9219. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9220. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  9221. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  9222. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  9223. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  9224. {
  9225. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  9226. }
  9227. _currency = _GroupCostParameter.Currency;
  9228. bool isIntType = int.TryParse(_currency, out int currId);
  9229. if (isIntType)
  9230. {
  9231. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  9232. }
  9233. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  9234. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  9235. if (currInfo == null)
  9236. {
  9237. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  9238. }
  9239. if (!_currency.ToUpper().Equals("CNY"))
  9240. {
  9241. _rate = _GroupCostParameter.Rate;
  9242. }
  9243. _rate = currInfo.Rate;
  9244. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9245. string strFileName = "HotelStatement/";
  9246. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9247. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  9248. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  9249. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  9250. #region 数据处理
  9251. foreach (var item in hrDtas)
  9252. {
  9253. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  9254. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  9255. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  9256. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  9257. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  9258. string roomCurr = currDatas.Find(it => it.Id == roomInfo.Currency)?.Name ?? "";
  9259. string singleRoomFeeStr = string.Empty,
  9260. doubleRoomFeeStr = string.Empty,
  9261. suiteRoomFeeStr = string.Empty,
  9262. otherRoomFeeStr = string.Empty,
  9263. payMoneyStr = string.Empty,
  9264. cardPriceStr = string.Empty;
  9265. if (roomCurr.Equals(_currency))
  9266. {
  9267. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  9268. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  9269. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  9270. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  9271. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  9272. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  9273. }
  9274. else
  9275. {
  9276. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  9277. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  9278. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  9279. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  9280. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  9281. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  9282. }
  9283. string breakfastPriceStr = string.Empty,
  9284. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  9285. governmentRentStr = string.Empty,
  9286. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  9287. cityTaxStrStr = string.Empty,
  9288. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  9289. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  9290. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  9291. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  9292. pcfds.Add(new HotelReservations_PCFD_View()
  9293. {
  9294. City = item.City,
  9295. HotelName = item.HotelName,
  9296. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  9297. // SingleRoomCount = item.SingleRoomCount,
  9298. SingleRoomPrice = singleRoomFeeStr,
  9299. // DoubleRoomCount = item.DoubleRoomCount,
  9300. DoubleRoomPrice = doubleRoomFeeStr,
  9301. //SuiteRoomCount = item.SuiteRoomCount,
  9302. SuiteRoomPrice = suiteRoomFeeStr,
  9303. OtherRoomPrice = otherRoomFeeStr,
  9304. //OtherRoomCount = item.OtherRoomCount,
  9305. BreakfastPrice = breakfastPriceStr,
  9306. GovernmentRent = governmentRentStr,
  9307. CityTax = cityTaxStrStr,
  9308. RoomExplanation = item.RoomExplanation,
  9309. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == roomInfo.PayDId).First()?.Name ?? "",
  9310. PayTime = roomInfo.ConsumptionDate,
  9311. BankNo = roomInfo.BankNo,
  9312. PayMoney = payMoneyStr,
  9313. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  9314. ConsumptionPatterns = roomInfo.ConsumptionPatterns,
  9315. CardPrice = cardPriceStr,
  9316. Remark = ccpInfo.Remark
  9317. });
  9318. }
  9319. #endregion
  9320. //载入模板
  9321. WorkbookDesigner designer = new WorkbookDesigner();
  9322. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  9323. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  9324. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  9325. designer.SetDataSource("TourNo", groupInfo.TourCode);
  9326. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  9327. designer.SetDataSource("Opertor", userInfo.CnName);
  9328. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  9329. dt.TableName = "ViewMyHotelReservations";
  9330. designer.SetDataSource(dt);
  9331. designer.Process();
  9332. string fileName = ($"HotelReservation/{groupInfo.TeamName}_酒店预订成本_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls").Replace(":", "");
  9333. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  9334. designer.Workbook.Save(serverPath);
  9335. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  9336. #region 删除指定行
  9337. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  9338. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  9339. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  9340. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  9341. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  9342. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  9343. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  9344. cssIndex = dt.Columns["CityTax"].Ordinal,
  9345. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  9346. remarkIndex = dt.Columns["Remark"].Ordinal;
  9347. //删除指定列
  9348. foreach (DataRow item in dt.Rows)
  9349. {
  9350. string singleStr = item["SingleRoomPrice"].ToString();
  9351. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  9352. if (containsDigitButNotZero1) singleDel = false;
  9353. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  9354. string doubleStr = item["DoubleRoomPrice"].ToString();
  9355. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9356. if (containsDigitButNotZero2) doubleDel = false;
  9357. string suiteStr = item["SuiteRoomPrice"].ToString();
  9358. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9359. if (containsDigitButNotZero3) suiteDel = false;
  9360. string otherStr = item["OtherRoomPrice"].ToString();
  9361. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  9362. if (containsDigitButNotZero4) otherDel = false;
  9363. string zcStr = item["BreakfastPrice"].ToString();
  9364. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  9365. if (containsDigitButNotZero5) zcDel = false;
  9366. string dsStr = item["GovernmentRent"].ToString();
  9367. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  9368. if (containsDigitButNotZero6) dsDel = false;
  9369. string cssStr = item["CityTax"].ToString();
  9370. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  9371. if (containsDigitButNotZero7) cssDel = false;
  9372. string cpStr = item["ConsumptionPatterns"].ToString();
  9373. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  9374. string remarkStr = item["Remark"].ToString();
  9375. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  9376. }
  9377. DeleteColumn(serverPath, remarkIndex, remarkDel);
  9378. DeleteColumn(serverPath, cpIndex, cpDel);
  9379. DeleteColumn(serverPath, dsIndex, dsDel);
  9380. DeleteColumn(serverPath, cssIndex, cssDel);
  9381. DeleteColumn(serverPath, zcIndex, zcDel);
  9382. DeleteColumn(serverPath, otherIndex, otherDel);
  9383. DeleteColumn(serverPath, suiteIndex, suiteDel);
  9384. DeleteColumn(serverPath, doubleIndex, doubleDel);
  9385. DeleteColumn(serverPath, singleIndex, singleDel);
  9386. #endregion
  9387. //只保留第一个表格
  9388. DeleteSheet(serverPath);
  9389. return Ok(JsonView(true, "操作成功", url = rst));
  9390. }
  9391. /// <summary>
  9392. /// 删除指定列
  9393. /// </summary>
  9394. /// <param name="file"></param>
  9395. /// <param name="columnIndex"></param>
  9396. /// <param name="isDel"></param>
  9397. private void DeleteColumn(string file, int columnIndex, bool isDel)
  9398. {
  9399. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9400. //wb.Save(file);
  9401. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  9402. if (sheet1 != null)
  9403. {
  9404. if (isDel)
  9405. {
  9406. Cells cells = sheet1.Cells;
  9407. cells.DeleteColumn(columnIndex);
  9408. }
  9409. }
  9410. wb.Save(file);
  9411. }
  9412. /// <summary>
  9413. /// 删除sheet
  9414. /// </summary>
  9415. /// <param name="file"></param>
  9416. /// <param name="sheetName"></param>
  9417. private void DeleteSheet(string file, string sheetName = "")
  9418. {
  9419. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9420. //wb.Save(file);
  9421. List<string> sheets = new List<string>();
  9422. foreach (var item in wb.Worksheets)
  9423. {
  9424. sheets.Add(item.Name);
  9425. }
  9426. if (sheets.Count > 0)
  9427. {
  9428. sheets.RemoveAt(0);//不删除第一个sheet
  9429. foreach (var item in sheets)
  9430. {
  9431. wb.Worksheets.RemoveAt(item);
  9432. }
  9433. }
  9434. wb.Save(file);
  9435. }
  9436. /// <summary>
  9437. /// 酒店预订
  9438. /// 确认单
  9439. /// </summary>
  9440. /// <param name="_dto"></param>
  9441. /// <returns></returns>
  9442. [HttpPost]
  9443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9444. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  9445. {
  9446. try
  9447. {
  9448. #region 参数验证
  9449. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9450. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9451. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9452. #region 团组操作权限验证 76 酒店预定模块
  9453. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9454. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9455. #endregion
  9456. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9457. #region 页面操作权限验证
  9458. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9459. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9460. #endregion
  9461. #endregion
  9462. //团组信息
  9463. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  9464. //酒店数据
  9465. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  9466. if (listhoteldata.Count < 0)
  9467. {
  9468. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  9469. }
  9470. //利datatable存储
  9471. DataTable dt = new DataTable();
  9472. dt.Columns.Add("CheckInDate", typeof(string));
  9473. dt.Columns.Add("City", typeof(string));
  9474. dt.Columns.Add("Hotel", typeof(string));
  9475. dt.Columns.Add("Room", typeof(string));
  9476. for (int i = 0; i < listhoteldata.Count; i++)
  9477. {
  9478. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  9479. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  9480. while (dayStart < dayEnd)
  9481. {
  9482. string temp = "";
  9483. DataRow row = dt.NewRow();
  9484. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  9485. row["City"] = listhoteldata[i].City;
  9486. row["Hotel"] = listhoteldata[i].HotelName;
  9487. if (listhoteldata[i].SingleRoomCount > 0)
  9488. {
  9489. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  9490. }
  9491. if (listhoteldata[i].DoubleRoomCount > 0)
  9492. {
  9493. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  9494. }
  9495. if (listhoteldata[i].SuiteRoomCount > 0)
  9496. {
  9497. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  9498. }
  9499. if (listhoteldata[i].OtherRoomCount > 0)
  9500. {
  9501. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  9502. }
  9503. row["Room"] = temp;
  9504. dt.Rows.Add(row);
  9505. dayStart = dayStart.AddDays(1);
  9506. }
  9507. }
  9508. Dictionary<string, string> dic = new Dictionary<string, string>();
  9509. dic.Add("Dele", di.TeamName);
  9510. dic.Add("City", di.VisitCountry);
  9511. //模板路径
  9512. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  9513. //载入模板
  9514. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  9515. DocumentBuilder builder = new DocumentBuilder(doc);
  9516. foreach (var key in dic.Keys)
  9517. {
  9518. builder.MoveToBookmark(key);
  9519. builder.Write(dic[key]);
  9520. }
  9521. //获取word里所有表格
  9522. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9523. //获取所填表格的序数
  9524. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9525. var rowStart = tableOne.Rows[0]; //获取第1行
  9526. //循环赋值
  9527. for (int i = 0; i < dt.Rows.Count; i++)
  9528. {
  9529. builder.MoveToCell(0, i + 1, 0, 0);
  9530. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  9531. builder.MoveToCell(0, i + 1, 1, 0);
  9532. builder.Write(dt.Rows[i]["City"].ToString());
  9533. builder.MoveToCell(0, i + 1, 2, 0);
  9534. builder.Write(dt.Rows[i]["Hotel"].ToString());
  9535. builder.MoveToCell(0, i + 1, 3, 0);
  9536. builder.Write(dt.Rows[i]["Room"].ToString());
  9537. }
  9538. //删除多余行
  9539. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  9540. {
  9541. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  9542. }
  9543. string strFileName = di.TeamName + "酒店确认单.doc";
  9544. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  9545. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  9546. return Ok(JsonView(true, "成功", url));
  9547. }
  9548. catch (Exception ex)
  9549. {
  9550. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  9551. }
  9552. }
  9553. #endregion
  9554. #region 团组状态
  9555. /// <summary>
  9556. /// 团组状态列表 Page
  9557. /// </summary>
  9558. /// <param name="dto">团组列表请求dto</param>
  9559. /// <returns></returns>
  9560. [HttpPost]
  9561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9562. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  9563. {
  9564. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9565. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  9566. {
  9567. string sqlWhere = string.Empty;
  9568. if (dto.IsSure == 0) //未完成
  9569. {
  9570. sqlWhere += string.Format(@" And IsSure = 0");
  9571. }
  9572. else if (dto.IsSure == 1) //已完成
  9573. {
  9574. sqlWhere += string.Format(@" And IsSure = 1");
  9575. }
  9576. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  9577. {
  9578. string tj = dto.SearchCriteria;
  9579. 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}%')",
  9580. tj, tj, tj, tj, tj);
  9581. }
  9582. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  9583. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  9584. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  9585. From (
  9586. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  9587. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  9588. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  9589. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  9590. From Grp_DelegationInfo gdi
  9591. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  9592. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  9593. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  9594. Where gdi.IsDel = 0 {0}
  9595. ) temp ", sqlWhere);
  9596. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  9597. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  9598. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  9599. }
  9600. else
  9601. {
  9602. return Ok(JsonView(false, "查询失败"));
  9603. }
  9604. }
  9605. /// <summary>
  9606. /// 团组状态
  9607. /// 设置操作完成
  9608. /// </summary>
  9609. /// <param name="dto">团组列表请求dto</param>
  9610. /// <returns></returns>
  9611. [HttpPost]
  9612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9613. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  9614. {
  9615. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9616. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  9617. {
  9618. Id = dto.Id,
  9619. IsSure = 1
  9620. };
  9621. var result = await _sqlSugar.Updateable(_DelegationInfo)
  9622. .UpdateColumns(it => new { it.IsSure })
  9623. .WhereColumns(it => new { it.Id })
  9624. .ExecuteCommandAsync();
  9625. if (result > 0)
  9626. {
  9627. return Ok(JsonView(true, "操作完成!"));
  9628. }
  9629. return Ok(JsonView(false, "操作失败!"));
  9630. }
  9631. #endregion
  9632. #region 保险费用录入
  9633. /// <summary>
  9634. /// 根据团组Id查询保险费用列表
  9635. /// </summary>
  9636. /// <param name="dto"></param>
  9637. /// <returns></returns>
  9638. [HttpPost]
  9639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9640. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  9641. {
  9642. try
  9643. {
  9644. Result groupData = await _customersRep.CustomersByDiId(dto);
  9645. if (groupData.Code != 0)
  9646. {
  9647. return Ok(JsonView(false, groupData.Msg));
  9648. }
  9649. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9650. }
  9651. catch (Exception ex)
  9652. {
  9653. return Ok(JsonView(false, ex.Message));
  9654. }
  9655. }
  9656. /// <summary>
  9657. /// 根据保险费用Id查询保险费用详细
  9658. /// </summary>
  9659. /// <param name="dto"></param>
  9660. /// <returns></returns>
  9661. [HttpPost]
  9662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9663. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  9664. {
  9665. try
  9666. {
  9667. Result groupData = await _customersRep.CustomersById(dto);
  9668. if (groupData.Code != 0)
  9669. {
  9670. return Ok(JsonView(false, groupData.Msg));
  9671. }
  9672. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9673. }
  9674. catch (Exception ex)
  9675. {
  9676. return Ok(JsonView(false, ex.Message));
  9677. }
  9678. }
  9679. /// <summary>
  9680. /// 保险费用录入页面初始化绑定
  9681. /// </summary>
  9682. /// <param name="dto"></param>
  9683. /// <returns></returns>
  9684. [HttpPost]
  9685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9686. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  9687. {
  9688. try
  9689. {
  9690. Result groupData = await _customersRep.CustomersInitialize(dto);
  9691. if (groupData.Code != 0)
  9692. {
  9693. return Ok(JsonView(false, groupData.Msg));
  9694. }
  9695. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9696. }
  9697. catch (Exception ex)
  9698. {
  9699. return Ok(JsonView(false, ex.Message));
  9700. }
  9701. }
  9702. /// <summary>
  9703. /// 保险费用操作(Status:1.新增,2.修改)
  9704. /// </summary>
  9705. /// <param name="dto"></param>
  9706. /// <returns></returns>
  9707. [HttpPost]
  9708. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9709. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  9710. {
  9711. try
  9712. {
  9713. Result groupData = await _customersRep.OpCustomers(dto);
  9714. if (groupData.Code != 0)
  9715. {
  9716. return Ok(JsonView(false, groupData.Msg));
  9717. }
  9718. #region 应用推送
  9719. try
  9720. {
  9721. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9722. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9723. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9724. }
  9725. catch (Exception ex)
  9726. {
  9727. }
  9728. #endregion
  9729. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9730. }
  9731. catch (Exception ex)
  9732. {
  9733. return Ok(JsonView(false, ex.Message));
  9734. }
  9735. }
  9736. /// <summary>
  9737. /// 保险文件上传
  9738. /// </summary>
  9739. /// <param name="file"></param>
  9740. /// <returns></returns>
  9741. [HttpPost]
  9742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9743. public async Task<IActionResult> UploadCus(IFormFile file)
  9744. {
  9745. try
  9746. {
  9747. if (file != null)
  9748. {
  9749. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9750. //文件名称
  9751. string projectFileName = file.FileName;
  9752. //上传的文件的路径
  9753. string filePath = "";
  9754. if (!Directory.Exists(fileDir))
  9755. {
  9756. Directory.CreateDirectory(fileDir);
  9757. }
  9758. //上传的文件的路径
  9759. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  9760. using (FileStream fs = System.IO.File.Create(filePath))
  9761. {
  9762. file.CopyTo(fs);
  9763. fs.Flush();
  9764. }
  9765. return Ok(JsonView(true, "上传成功!", projectFileName));
  9766. }
  9767. else
  9768. {
  9769. return Ok(JsonView(false, "上传失败!"));
  9770. }
  9771. }
  9772. catch (Exception ex)
  9773. {
  9774. return Ok(JsonView(false, "程序错误!"));
  9775. throw;
  9776. }
  9777. }
  9778. /// <summary>
  9779. /// 保险删除指定文件
  9780. /// </summary>
  9781. /// <param name="dto"></param>
  9782. /// <returns></returns>
  9783. [HttpPost]
  9784. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9785. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  9786. {
  9787. try
  9788. {
  9789. string filePath = "";
  9790. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9791. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  9792. //int id = 0;
  9793. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  9794. // 删除该文件
  9795. try
  9796. {
  9797. System.IO.File.Delete(filePath);
  9798. 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()
  9799. {
  9800. Attachment = "",
  9801. }).ExecuteCommandAsync();
  9802. if (result != 0)
  9803. {
  9804. return Ok(JsonView(true, "成功!"));
  9805. }
  9806. else
  9807. {
  9808. return Ok(JsonView(false, "失败!"));
  9809. }
  9810. }
  9811. catch (Exception)
  9812. {
  9813. 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()
  9814. {
  9815. Attachment = "",
  9816. }).ExecuteCommandAsync();
  9817. if (result != 0)
  9818. {
  9819. return Ok(JsonView(true, "成功!"));
  9820. }
  9821. else
  9822. {
  9823. return Ok(JsonView(false, "失败!"));
  9824. }
  9825. }
  9826. }
  9827. catch (Exception ex)
  9828. {
  9829. return Ok(JsonView(false, "程序错误!"));
  9830. throw;
  9831. }
  9832. }
  9833. /// <summary>
  9834. /// 保险费用操作(删除)
  9835. /// </summary>
  9836. /// <param name="dto"></param>
  9837. /// <returns></returns>
  9838. [HttpPost]
  9839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9840. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  9841. {
  9842. try
  9843. {
  9844. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  9845. if (!res)
  9846. {
  9847. return Ok(JsonView(false, "删除失败"));
  9848. }
  9849. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  9850. {
  9851. IsDel = 1,
  9852. DeleteUserId = dto.DeleteUserId,
  9853. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9854. }).ExecuteCommandAsync();
  9855. return Ok(JsonView(true, "删除成功!"));
  9856. }
  9857. catch (Exception ex)
  9858. {
  9859. return Ok(JsonView(false, "程序错误!"));
  9860. throw;
  9861. }
  9862. }
  9863. #endregion
  9864. #region 接团客户名单 PageId 104
  9865. /// <summary>
  9866. /// 接团客户名单
  9867. /// 迁移数据(慎用!)
  9868. /// </summary>
  9869. /// <param name="dto"></param>
  9870. /// <returns></returns>
  9871. [HttpPost]
  9872. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9873. public async Task<IActionResult> PostTourClientListChange()
  9874. {
  9875. try
  9876. {
  9877. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  9878. //var groupClinetData1
  9879. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  9880. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  9881. int updateCount = 0;
  9882. if (oldOAClientList.Count > 0)
  9883. {
  9884. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  9885. _sqlSugar.BeginTran();
  9886. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  9887. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  9888. foreach (var item in oldOAClientList)
  9889. {
  9890. int comId = 0;
  9891. string format = "yyyy-MM-dd HH:mm:ss";
  9892. string data11 = "1990-01-01 00:00";
  9893. var data1 = IsValidDate(item.OPdate, format);
  9894. if (data1) data11 = item.OPdate;
  9895. //客户公司验证
  9896. if (!string.IsNullOrEmpty(item.Company))
  9897. {
  9898. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  9899. if (clientComInfo == null) // add
  9900. {
  9901. var addInfo = new Crm_CustomerCompany()
  9902. {
  9903. CompanyAbbreviation = "",
  9904. CompanyFullName = item.Company,
  9905. Address = "",
  9906. PostCodes = "",
  9907. LastedOpUserId = item.OPer,
  9908. LastedOpDt = Convert.ToDateTime(data11),
  9909. CreateUserId = item.OPer,
  9910. CreateTime = Convert.ToDateTime(data11),
  9911. IsDel = 0
  9912. };
  9913. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  9914. if (comId1 > 0) comId = comId1;
  9915. }
  9916. else comId = clientComInfo.Id;
  9917. }
  9918. //客户人员验证
  9919. int clientId = 0;
  9920. string name = item.LastName + item.Name;
  9921. if (!string.IsNullOrEmpty(name))
  9922. {
  9923. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  9924. if (clientInfo == null)
  9925. {
  9926. DateTime? dateTime = null;
  9927. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  9928. if (isDt) dateTime = birthDayDt;
  9929. var addInfo1 = new Crm_DeleClient()
  9930. {
  9931. CrmCompanyId = comId,
  9932. DiId = -1,
  9933. LastName = item.LastName,
  9934. FirstName = item.Name,
  9935. OldName = "",
  9936. Pinyin = item.Pinyin,
  9937. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  9938. Marriage = 0,
  9939. Phone = item.Phone,
  9940. Job = item.Job,
  9941. BirthDay = dateTime
  9942. };
  9943. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  9944. if (clientId1 > 0) clientId = clientId1;
  9945. }
  9946. else clientId = clientInfo.Id;
  9947. }
  9948. if (clientId < 1)
  9949. {
  9950. continue;
  9951. }
  9952. int airType = 0;
  9953. if (item.AirType == "超经舱") airType = 459;
  9954. else if (item.AirType == "公务舱") airType = 458;
  9955. else if (item.AirType == "经济舱") airType = 460;
  9956. else if (item.AirType == "其他") airType = 565;
  9957. else if (item.AirType == "头等舱") airType = 457;
  9958. var _TourClientListEntity = new Grp_TourClientList()
  9959. {
  9960. DiId = item.Diid,
  9961. ClientId = clientId,
  9962. CreateUserId = item.OPer,
  9963. CreateTime = Convert.ToDateTime(data11),
  9964. Remark = item.Remark,
  9965. IsDel = item.Isdel,
  9966. ShippingSpaceTypeId = airType,
  9967. ShippingSpaceSpecialNeeds = item.AirRemark,
  9968. HotelSpecialNeeds = item.RoomType
  9969. };
  9970. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  9971. if (_TourClientList > 0)
  9972. {
  9973. updateCount++;
  9974. }
  9975. }
  9976. _sqlSugar.CommitTran();
  9977. }
  9978. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  9979. }
  9980. catch (Exception ex)
  9981. {
  9982. _sqlSugar.RollbackTran();
  9983. return Ok(JsonView(false, ex.Message));
  9984. }
  9985. return Ok(JsonView(true));
  9986. }
  9987. private bool IsValidDate(string dateString, string format)
  9988. {
  9989. DateTime dateValue;
  9990. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  9991. return valid;
  9992. }
  9993. /// <summary>
  9994. /// 接团客户名单
  9995. /// 根据团组Id查询List
  9996. /// </summary>
  9997. /// <param name="dto"></param>
  9998. /// <returns></returns>
  9999. [HttpPost]
  10000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10001. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  10002. {
  10003. #region 参数验证
  10004. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  10005. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10006. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  10007. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10008. #region 页面操作权限验证
  10009. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10010. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10011. #endregion
  10012. #endregion
  10013. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  10014. if (viewData.Code != 0)
  10015. {
  10016. return Ok(JsonView(false, viewData.Msg));
  10017. }
  10018. return Ok(JsonView(viewData.Data));
  10019. }
  10020. /// <summary>
  10021. /// 接团客户名单
  10022. /// 基础数据 Init
  10023. /// </summary>
  10024. /// <param name="_dto"></param>
  10025. /// <returns></returns>
  10026. [HttpPost]
  10027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10028. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  10029. {
  10030. #region 参数验证
  10031. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10032. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10033. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10034. #region 页面操作权限验证
  10035. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10036. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10037. #endregion
  10038. #endregion
  10039. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  10040. if (viewData.Code != 0)
  10041. {
  10042. return Ok(JsonView(false, viewData.Msg));
  10043. }
  10044. return Ok(JsonView(viewData.Data));
  10045. }
  10046. /// <summary>
  10047. /// 接团客户名单
  10048. /// 根据 Id查询 Details
  10049. /// </summary>
  10050. /// <param name="_dto"></param>
  10051. /// <returns></returns>
  10052. [HttpPost]
  10053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10054. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  10055. {
  10056. #region 参数验证
  10057. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10058. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10059. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10060. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10061. #region 页面操作权限验证
  10062. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10063. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10064. #endregion
  10065. #endregion
  10066. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  10067. if (viewData.Code != 0)
  10068. {
  10069. return Ok(JsonView(false, viewData.Msg));
  10070. }
  10071. return Ok(JsonView(viewData.Data));
  10072. }
  10073. /// <summary>
  10074. /// 接团客户名单
  10075. /// Add Or Edit
  10076. /// </summary>
  10077. /// <param name="_dto"></param>
  10078. /// <returns></returns>
  10079. [HttpPost]
  10080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10081. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  10082. {
  10083. #region 参数验证
  10084. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10085. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10086. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10087. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10088. #region 页面操作权限验证
  10089. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10090. if (_dto.Id == 0) //添加
  10091. {
  10092. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10093. }
  10094. else if (_dto.Id >= 0) //修改
  10095. {
  10096. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10097. }
  10098. #endregion
  10099. #endregion
  10100. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  10101. if (viewData.Code != 0)
  10102. {
  10103. return Ok(JsonView(false, viewData.Msg));
  10104. }
  10105. return Ok(JsonView(true));
  10106. }
  10107. /// <summary>
  10108. /// 接团客户名单
  10109. /// AddMultiple(添加多个)
  10110. /// </summary>
  10111. /// <param name="_dto"></param>
  10112. /// <returns></returns>
  10113. [HttpPost]
  10114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10115. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  10116. {
  10117. #region 参数验证
  10118. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10119. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10120. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10121. #region 页面操作权限验证
  10122. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10123. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10124. #endregion
  10125. #endregion
  10126. var viewData = await _tourClientListRep._AddMultiple(_dto);
  10127. if (viewData.Code != 0)
  10128. {
  10129. return Ok(JsonView(false, viewData.Msg));
  10130. }
  10131. return Ok(JsonView(true));
  10132. }
  10133. /// <summary>
  10134. /// 接团客户名单
  10135. /// Del
  10136. /// </summary>
  10137. /// <param name="_dto"></param>
  10138. /// <returns></returns>
  10139. [HttpPost]
  10140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10141. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  10142. {
  10143. #region 参数验证
  10144. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10145. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10146. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10147. #region 页面操作权限验证
  10148. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10149. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  10150. #endregion
  10151. #endregion
  10152. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  10153. if (viewData.Code != 0)
  10154. {
  10155. return Ok(JsonView(false, viewData.Msg));
  10156. }
  10157. return Ok(JsonView(true));
  10158. }
  10159. /// <summary>
  10160. /// 接团客户名单
  10161. /// 文件下载 客户名单
  10162. /// </summary>
  10163. /// <param name="_dto"></param>
  10164. /// <returns></returns>
  10165. [HttpPost]
  10166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10167. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  10168. {
  10169. #region 参数验证
  10170. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10171. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10172. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  10173. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10174. #region 页面操作权限验证
  10175. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10176. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10177. #endregion
  10178. #endregion
  10179. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  10180. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  10181. From Grp_TourClientList tcl
  10182. Left Join
  10183. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  10184. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  10185. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  10186. From Crm_DeleClient dc
  10187. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  10188. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  10189. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  10190. Where dc.IsDel = 0) temp
  10191. On temp.DcId =tcl.ClientId
  10192. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  10193. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  10194. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  10195. //载入模板
  10196. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  10197. if (_dto.Language == 1)
  10198. {
  10199. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  10200. }
  10201. //载入模板
  10202. var doc = new Document(tempPath);
  10203. DocumentBuilder builder = new DocumentBuilder(doc);
  10204. //获取word里所有表格
  10205. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10206. //获取所填表格的序数
  10207. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10208. var rowStart = tableOne.Rows[0]; //获取第1行
  10209. if (_dto.Language == 0)
  10210. {
  10211. //循环赋值
  10212. for (int i = 0; i < DcList.Count; i++)
  10213. {
  10214. builder.MoveToCell(0, i + 1, 0, 0);
  10215. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  10216. builder.MoveToCell(0, i + 1, 1, 0);
  10217. int sex = DcList[i].Sex;
  10218. string sexStr = string.Empty;
  10219. if (sex == 0) sexStr = "男";
  10220. else if (sex == 1) sexStr = "女";
  10221. else sexStr = "未设置";
  10222. builder.Write(sexStr);
  10223. builder.MoveToCell(0, i + 1, 2, 0);
  10224. string birthDay = DcList[i].BirthDay;
  10225. string birthDayStr = string.Empty;
  10226. if (!string.IsNullOrEmpty(birthDay))
  10227. {
  10228. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  10229. }
  10230. builder.Write(birthDayStr);
  10231. builder.MoveToCell(0, i + 1, 3, 0);
  10232. string company = "";
  10233. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10234. {
  10235. company = DcList[i].CompanyFullName.ToString();
  10236. }
  10237. builder.Write(company);
  10238. builder.MoveToCell(0, i + 1, 4, 0);
  10239. builder.Write(DcList[i].Job);
  10240. }
  10241. }
  10242. else if (_dto.Language == 1)
  10243. {
  10244. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  10245. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  10246. //循环赋值
  10247. for (int i = 0; i < DcList.Count; i++)
  10248. {
  10249. string PYName = "";
  10250. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  10251. {
  10252. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  10253. string PY_First = DcList[i].Pinyin.Split('/')[1];
  10254. PYName = PY_First + " " + PY_Last;
  10255. }
  10256. else
  10257. {
  10258. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  10259. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  10260. PYName = PY_First + " " + PY_Last;
  10261. }
  10262. builder.MoveToCell(0, i + 1, 0, 0);
  10263. builder.Write(PYName);
  10264. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  10265. builder.MoveToCell(0, i + 1, 1, 0);
  10266. builder.Write(sex);
  10267. DateTime birthDt;
  10268. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  10269. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : "";
  10270. builder.MoveToCell(0, i + 1, 2, 0);
  10271. builder.Write(birthday);
  10272. string company = "";
  10273. try
  10274. {
  10275. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10276. {
  10277. //查询对照表
  10278. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  10279. if (tempCec != null)
  10280. {
  10281. company = tempCec.enName;
  10282. }
  10283. //翻译
  10284. else
  10285. {
  10286. company = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].CompanyFullName.ToString().Trim());
  10287. }
  10288. }
  10289. }
  10290. catch (Exception)
  10291. {
  10292. }
  10293. builder.MoveToCell(0, i + 1, 3, 0);
  10294. builder.Write(company);
  10295. string job = "";
  10296. try
  10297. {
  10298. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  10299. {
  10300. //查询对照表
  10301. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  10302. if (tempPec != null)
  10303. {
  10304. job = tempPec.enName;
  10305. }
  10306. //翻译
  10307. else
  10308. {
  10309. job = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].Job.ToString().Trim());
  10310. }
  10311. }
  10312. }
  10313. catch (Exception ex)
  10314. {
  10315. }
  10316. builder.MoveToCell(0, i + 1, 4, 0);
  10317. builder.Write(job);
  10318. }
  10319. }
  10320. //删除多余行
  10321. while (tableOne.Rows.Count > DcList.Count + 1)
  10322. {
  10323. tableOne.Rows.RemoveAt(DcList.Count + 1);
  10324. }
  10325. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  10326. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  10327. doc.Save(fileDir);
  10328. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  10329. return Ok(JsonView(true, "操作成功!", Url));
  10330. }
  10331. #endregion
  10332. #region 团组倒推表
  10333. /// <summary>
  10334. /// 倒推表基础数据
  10335. /// Init
  10336. /// </summary>
  10337. /// <param name="dto"></param>
  10338. /// <returns></returns>
  10339. [HttpPost]
  10340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10341. public async Task<IActionResult> PostInvertedListInit()
  10342. {
  10343. var viewData = await _invertedListRep._Init();
  10344. if (viewData.Code != 0)
  10345. {
  10346. return Ok(JsonView(false, viewData.Msg));
  10347. }
  10348. return Ok(JsonView(viewData.Data));
  10349. }
  10350. /// <summary>
  10351. /// 倒推表
  10352. /// Info
  10353. /// </summary>
  10354. /// <param name="dto"></param>
  10355. /// <returns></returns>
  10356. [HttpPost]
  10357. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10358. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  10359. {
  10360. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  10361. if (viewData.Code != 0)
  10362. {
  10363. return Ok(JsonView(false, viewData.Msg));
  10364. }
  10365. return Ok(JsonView(viewData.Data));
  10366. }
  10367. /// <summary>
  10368. /// 倒推表
  10369. /// Create
  10370. /// </summary>
  10371. /// <param name="dto"></param>
  10372. /// <returns></returns>
  10373. [HttpPost]
  10374. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10375. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  10376. {
  10377. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  10378. if (viewData.Code != 0)
  10379. {
  10380. return Ok(JsonView(false, viewData.Msg));
  10381. }
  10382. return Ok(JsonView(viewData.Data));
  10383. }
  10384. /// <summary>
  10385. /// 倒推表
  10386. /// Update
  10387. /// </summary>
  10388. /// <param name="dto"></param>
  10389. /// <returns></returns>
  10390. [HttpPost]
  10391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10392. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  10393. {
  10394. var viewData = await _invertedListRep._Update(dto);
  10395. if (viewData.Code != 0)
  10396. {
  10397. return Ok(JsonView(false, viewData.Msg));
  10398. }
  10399. return Ok(JsonView(viewData.Data));
  10400. }
  10401. /// <summary>
  10402. /// 倒推表
  10403. /// File Download
  10404. /// </summary>
  10405. /// <param name="dto"></param>
  10406. /// <returns></returns>
  10407. [HttpPost]
  10408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10409. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  10410. {
  10411. var info2 = await _invertedListRep._Info(1, dto.DiId);
  10412. if (info2.Code != 0)
  10413. {
  10414. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  10415. }
  10416. var info1 = info2.Data as InvertedListInfoView;
  10417. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  10418. string teamName = "";
  10419. if (info != null) teamName = info.TeamName;
  10420. //载入模板
  10421. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  10422. DocumentBuilder builder = new DocumentBuilder(doc);
  10423. //利用键值对存放数据
  10424. Dictionary<string, string> dic = new Dictionary<string, string>();
  10425. dic.Add("TeamName", teamName);
  10426. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  10427. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  10428. dic.Add("BPRemark", info1.ApprovalDataRemark);
  10429. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  10430. dic.Add("SQRemark", info1.ApprovalRemark);
  10431. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  10432. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  10433. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  10434. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  10435. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  10436. dic.Add("QZRemark", info1.VisaInformationRemark);
  10437. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  10438. dic.Add("SQQZRemark", info1.SendVisaRemark);
  10439. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  10440. dic.Add("CQRemark", info1.IssueVisaRemark);
  10441. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  10442. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  10443. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  10444. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  10445. #region 填充word模板书签内容
  10446. foreach (var key in dic.Keys)
  10447. {
  10448. builder.MoveToBookmark(key);
  10449. builder.Write(dic[key]);
  10450. }
  10451. #endregion
  10452. var fileDir = AppSettingsHelper.Get("WordBasePath");
  10453. string fileName = $"{teamName}团出行准备流程表.doc";
  10454. string filePath = fileDir + $@"InvertedList/{fileName}";
  10455. doc.Save(filePath);
  10456. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  10457. return Ok(JsonView(true, "操作成功!", Url));
  10458. }
  10459. #endregion
  10460. #region 三公签证费用(签证费、代办费)
  10461. /// <summary>
  10462. /// 三公签证费用(签证费、代办费)
  10463. /// List
  10464. /// </summary>
  10465. /// <returns></returns>
  10466. [HttpPost]
  10467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10468. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  10469. {
  10470. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  10471. if (_view.Code != 0)
  10472. {
  10473. return Ok(JsonView(false, _view.Msg));
  10474. }
  10475. return Ok(JsonView(true, "操作成功!", _view.Data));
  10476. }
  10477. /// <summary>
  10478. /// 三公签证费用(签证费、代办费)
  10479. /// Add Or Update
  10480. /// </summary>
  10481. /// <returns></returns>
  10482. [HttpPost]
  10483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10484. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  10485. {
  10486. var _view = await _visaFeeInfoRep._Update(_dto);
  10487. if (_view.Code != 0)
  10488. {
  10489. return Ok(JsonView(false, _view.Msg));
  10490. }
  10491. return Ok(JsonView(true, _view.Msg));
  10492. }
  10493. #endregion
  10494. #region 酒店询价
  10495. /// <summary>
  10496. /// 酒店询价
  10497. /// Init
  10498. /// </summary>
  10499. /// <param name="dto"></param>
  10500. /// <returns></returns>
  10501. [HttpPost]
  10502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10503. public async Task<IActionResult> PostHotelInquiryInit()
  10504. {
  10505. var res = await _hotelInquiryRep._Init();
  10506. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10507. return Ok(JsonView(true, res.Msg, res.Data));
  10508. }
  10509. /// <summary>
  10510. /// 酒店询价
  10511. /// page Item
  10512. /// </summary>
  10513. /// <param name="_dto"></param>
  10514. /// <returns></returns>
  10515. [HttpPost]
  10516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10517. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  10518. {
  10519. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  10520. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10521. var view = res.Data as PageDataViewBase;
  10522. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  10523. }
  10524. /// <summary>
  10525. /// 酒店询价
  10526. /// info
  10527. /// </summary>
  10528. /// <param name="_dto"></param>
  10529. /// <returns></returns>
  10530. [HttpPost]
  10531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10532. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  10533. {
  10534. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  10535. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10536. return Ok(JsonView(true, res.Msg, res.Data));
  10537. }
  10538. /// <summary>
  10539. /// 酒店询价
  10540. /// Add Or Edit
  10541. /// </summary>
  10542. /// <param name="_dto"></param>
  10543. /// <returns></returns>
  10544. [HttpPost]
  10545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10546. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  10547. {
  10548. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  10549. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10550. return Ok(JsonView(true, res.Msg, res.Data));
  10551. }
  10552. /// <summary>
  10553. /// 酒店询价
  10554. /// Del
  10555. /// </summary>
  10556. /// <param name="_dto"></param>
  10557. /// <returns></returns>
  10558. [HttpPost]
  10559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10560. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  10561. {
  10562. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  10563. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10564. return Ok(JsonView(true, res.Msg, res.Data));
  10565. }
  10566. #endregion
  10567. #region 下载匹配op行程单
  10568. /// <summary>
  10569. /// 匹配op行程单
  10570. /// Init
  10571. /// </summary>
  10572. /// <param name="dto">团组列表请求dto</param>
  10573. /// <returns></returns>
  10574. [HttpPost]
  10575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10576. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  10577. {
  10578. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10579. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10580. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  10581. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  10582. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  10583. .Where(it => it.IsDel == 0)
  10584. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  10585. .OrderByDescending(it => it.CreateUserId)
  10586. .ToList();
  10587. if (groupInfos.Count < 1) return Ok(JsonView(false,"暂无和你相关的团组信息!"));
  10588. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10589. var diids = groupInfos.Select(it => it.Id).ToList();
  10590. List<string> countrys = new List<string>();
  10591. foreach (var item in country)
  10592. {
  10593. var data = _groupRepository.FormartTeamName(item);
  10594. var dataArray = _groupRepository.GroupSplitCountry(data);
  10595. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10596. }
  10597. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  10598. List<string> areaArray = new List<string>(); //GetGroupCityLine
  10599. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  10600. foreach (var item in areaItem)
  10601. {
  10602. string areaStr = item.Value;
  10603. if (!string.IsNullOrEmpty(areaStr))
  10604. {
  10605. string[] str1 = areaStr.Split("-");
  10606. if (str1.Length > 0)
  10607. {
  10608. areaArray.AddRange(str1);
  10609. }
  10610. }
  10611. }
  10612. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  10613. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  10614. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  10615. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  10616. .ToList();
  10617. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  10618. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  10619. .Where(it => countriesIds.Contains(it.Id))
  10620. .Select(it => new { it.Id, Name = it.Name_CN })
  10621. .ToList();
  10622. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName) )
  10623. .Select(it => it.TeamName).ToList();
  10624. stopwatch.Stop();
  10625. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames,countriesDatas, citiesDatas = cityDatas }));
  10626. }
  10627. ///// <summary>
  10628. ///// 匹配op行程单
  10629. ///// Init 查询区域数据
  10630. ///// </summary>
  10631. ///// <param name="dto">团组列表请求dto</param>
  10632. ///// <returns></returns>
  10633. //[HttpPost]
  10634. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10635. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  10636. //{
  10637. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10638. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  10639. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  10640. // if (string.IsNullOrEmpty(countriesDataStr))
  10641. // {
  10642. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  10643. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  10644. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  10645. // }
  10646. // else
  10647. // {
  10648. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  10649. // }
  10650. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  10651. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  10652. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  10653. // List<dynamic> childList = new List<dynamic>();
  10654. // int parentId = dto.CountriesId;
  10655. // if (provinceData.Count > 1)
  10656. // {
  10657. // foreach (var item1 in provinceData)
  10658. // {
  10659. // List<dynamic> childList1 = new List<dynamic>();
  10660. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  10661. // foreach (var item2 in citiesData1)
  10662. // {
  10663. // List<dynamic> childList2 = new List<dynamic>();
  10664. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10665. // foreach (var item3 in countiesData1)
  10666. // {
  10667. // childList2.Add(new
  10668. // {
  10669. // id = item3.Id,
  10670. // parentId = item2.Id,
  10671. // level = "district",
  10672. // name = item3.Name_CN,
  10673. // });
  10674. // }
  10675. // childList1.Add(new
  10676. // {
  10677. // id = item2.Id,
  10678. // parentId = item1.Id,
  10679. // level = "city",
  10680. // name = item2.Name_CN,
  10681. // childList = childList2
  10682. // });
  10683. // }
  10684. // childList.Add(new
  10685. // {
  10686. // id = item1.Id,
  10687. // parentId = parentId,
  10688. // level = "province",
  10689. // name = item1.Name_CN,
  10690. // childList = childList1
  10691. // });
  10692. // }
  10693. // //城市
  10694. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  10695. // foreach (var item2 in citiesData2)
  10696. // {
  10697. // List<dynamic> childList22 = new List<dynamic>();
  10698. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10699. // foreach (var item3 in countiesData1)
  10700. // {
  10701. // childList22.Add(new
  10702. // {
  10703. // id = item3.Id,
  10704. // parentId = item2.Id,
  10705. // level = "district",
  10706. // name = item3.Name_CN,
  10707. // });
  10708. // }
  10709. // childList.Add(new
  10710. // {
  10711. // id = item2.Id,
  10712. // parentId = parentId,
  10713. // level = "city",
  10714. // name = item2.Name_CN,
  10715. // childList = childList22
  10716. // });
  10717. // }
  10718. // }
  10719. // else
  10720. // {
  10721. // foreach (var item2 in citiesData)
  10722. // {
  10723. // string cname = item2.Name_CN;
  10724. // List<dynamic> childList1 = new List<dynamic>();
  10725. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10726. // foreach (var item3 in countiesData1)
  10727. // {
  10728. // childList1.Add(new
  10729. // {
  10730. // Id = item3.Id,
  10731. // parentId = item2.Id,
  10732. // level = "district",
  10733. // name = item3.Name_CN
  10734. // });
  10735. // }
  10736. // childList.Add(new
  10737. // {
  10738. // id = item2.Id,
  10739. // parentId = parentId,
  10740. // level = "city",
  10741. // name = item2.Name_CN,
  10742. // childList = childList1
  10743. // });
  10744. // }
  10745. // }
  10746. // stopwatch.Stop();
  10747. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  10748. //}
  10749. /// <summary>
  10750. /// 匹配op行程单
  10751. /// 接团信息列表 Page
  10752. /// </summary>
  10753. /// <param name="dto">团组列表请求dto</param>
  10754. /// <returns></returns>
  10755. [HttpPost]
  10756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10757. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  10758. {
  10759. var swatch = new Stopwatch();
  10760. swatch.Start();
  10761. #region 参数验证
  10762. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10763. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10764. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10765. #region 页面操作权限验证
  10766. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10767. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  10768. #endregion
  10769. #endregion
  10770. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10771. {
  10772. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  10773. string sqlWhere = "";
  10774. if (!string.IsNullOrEmpty(dto.Country))
  10775. {
  10776. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  10777. }
  10778. if (!string.IsNullOrEmpty(dto.Area))
  10779. {
  10780. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  10781. }
  10782. if (!string.IsNullOrEmpty(dto.TeamName))
  10783. {
  10784. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  10785. }
  10786. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  10787. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  10788. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  10789. swatch.Stop();
  10790. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  10791. }
  10792. else
  10793. {
  10794. return Ok(JsonView(false, "查询失败"));
  10795. }
  10796. }
  10797. /// <summary>
  10798. /// 匹配op行程单
  10799. /// 行程单下载
  10800. /// </summary>
  10801. /// <param name="dto">团组列表请求dto</param>
  10802. /// <returns></returns>
  10803. [HttpPost]
  10804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10805. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  10806. {
  10807. #region 参数验证
  10808. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10809. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10810. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10811. #region 页面操作权限验证
  10812. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10813. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  10814. #endregion
  10815. #endregion
  10816. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10817. {
  10818. var res = ExportTravel(new InitOpTravelDto() { Diid = dto.diId });
  10819. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  10820. }
  10821. else
  10822. {
  10823. return Ok(JsonView(false, "下载失败!"));
  10824. }
  10825. }
  10826. #endregion
  10827. #region 国家信息 数据 注释
  10828. //[HttpPost]
  10829. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  10830. //{
  10831. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  10832. // foreach (var item in dto)
  10833. // {
  10834. // infos.Add(new Grp_GroupsTaskAssignment()
  10835. // {
  10836. // DIId = item,
  10837. // CTId = 82,
  10838. // UId = 248,
  10839. // IsEnable = 1,
  10840. // CreateUserId = 233,
  10841. // CreateTime = DateTime.Now,
  10842. // IsDel = 0
  10843. // });
  10844. // infos.Add(new Grp_GroupsTaskAssignment()
  10845. // {
  10846. // DIId = item,
  10847. // CTId = 82,
  10848. // UId = 286,
  10849. // IsEnable = 1,
  10850. // CreateUserId = 233,
  10851. // CreateTime = DateTime.Now,
  10852. // IsDel = 0
  10853. // });
  10854. // }
  10855. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  10856. // return Ok("操作成功");
  10857. //}
  10858. //public class paramJsonDto
  10859. //{
  10860. // public List<CountriesInfo> str { get; set; }
  10861. //}
  10862. //[HttpPost]
  10863. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  10864. //{
  10865. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  10866. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  10867. // List<Sys_Cities> cities = new List<Sys_Cities>();
  10868. // List<Sys_Cities> districts = new List<Sys_Cities>();
  10869. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  10870. // _sqlSugar.BeginTran();
  10871. // int countitiesIndex = 0;
  10872. // foreach (var item in dto.str)
  10873. // {
  10874. // dynamic data = item.c;
  10875. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  10876. // if (data != null)
  10877. // {
  10878. // countitiesIndex++;
  10879. // foreach (var item1 in data)
  10880. // {
  10881. // string cnname = item1.cn;
  10882. // string enname = item1.en;
  10883. // Sys_Cities provinceInfo = new Sys_Cities()
  10884. // {
  10885. // CountriesId = countriesId,
  10886. // Name_CN = cnname,
  10887. // Name_EN = enname,
  10888. // ParentId = 0,
  10889. // IsCapital = 1,
  10890. // CreateUserId = 208,
  10891. // CreateTime = DateTime.Now,
  10892. // IsDel = 0
  10893. // };
  10894. // if (item1.lv == "province") //省份
  10895. // {
  10896. // provinceInfo.Level = 1;
  10897. // int provinceId = 0;
  10898. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  10899. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  10900. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10901. // var data1 = item1.c;
  10902. // foreach (var item2 in data1)
  10903. // {
  10904. // if (item2.lv == "city")
  10905. // {
  10906. // string citycnname = item2.cn;
  10907. // string cityenname = item2.en;
  10908. // Sys_Cities cityInfo = new Sys_Cities()
  10909. // {
  10910. // CountriesId = countriesId,
  10911. // ParentId = provinceId,
  10912. // Level = 2,
  10913. // Name_CN = citycnname,
  10914. // Name_EN = cityenname,
  10915. // IsCapital = 1,
  10916. // CreateUserId = 208,
  10917. // CreateTime = DateTime.Now,
  10918. // IsDel = 0
  10919. // };
  10920. // if (item2.c != null)
  10921. // {
  10922. // int cityId = 0;
  10923. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  10924. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10925. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  10926. // foreach (var item3 in item2.c)
  10927. // {
  10928. // if (item3.lv == "district")
  10929. // {
  10930. // var districtInfo = new Sys_Cities()
  10931. // {
  10932. // CountriesId = countriesId,
  10933. // Name_CN = item3.cn,
  10934. // Name_EN = item3.en,
  10935. // Level = 3,
  10936. // ParentId = cityId,
  10937. // IsCapital = 1,
  10938. // CreateUserId = 208,
  10939. // CreateTime = DateTime.Now,
  10940. // IsDel = 0
  10941. // };
  10942. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10943. // //{
  10944. // districts.Add(districtInfo);
  10945. // //}
  10946. // }
  10947. // }
  10948. // }
  10949. // else
  10950. // {
  10951. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  10952. // //{
  10953. // cities.Add(cityInfo);
  10954. // //}
  10955. // }
  10956. // }
  10957. // }
  10958. // }
  10959. // else if (item1.lv == "city")//城市
  10960. // {
  10961. // provinceInfo.Level = 2;
  10962. // if (item1.c != null)
  10963. // {
  10964. // int cityId = 0;
  10965. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  10966. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10967. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10968. // foreach (var item3 in item1.c)
  10969. // {
  10970. // if (item3.lv == "district")
  10971. // {
  10972. // var districtInfo = new Sys_Cities()
  10973. // {
  10974. // CountriesId = countriesId,
  10975. // Name_CN = item3.cn,
  10976. // Name_EN = item3.en,
  10977. // Level = 3,
  10978. // ParentId = cityId,
  10979. // IsCapital = 1,
  10980. // CreateUserId = 208,
  10981. // CreateTime = DateTime.Now,
  10982. // IsDel = 0
  10983. // };
  10984. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10985. // //{
  10986. // districts.Add(districtInfo);
  10987. // //}
  10988. // }
  10989. // }
  10990. // }
  10991. // else
  10992. // {
  10993. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  10994. // //{
  10995. // cities.Add(provinceInfo);
  10996. // //}
  10997. // }
  10998. // }
  10999. // }
  11000. // }
  11001. // }
  11002. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  11003. // cities = cities.Distinct().ToList();
  11004. // districts = districts.Distinct().ToList();
  11005. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  11006. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  11007. // cities.AddRange(districts);
  11008. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  11009. // //_sqlSugar.RollbackTran();
  11010. // _sqlSugar.CommitTran();
  11011. // return Ok(JsonView(false, "操作成功!"));
  11012. //}
  11013. //[HttpPost]
  11014. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  11015. //{
  11016. // List<CountitiesInfo> infos = dto.MyProperty;
  11017. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  11018. // _sqlSugar.BeginTran();
  11019. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11020. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  11021. // foreach (var item in infos)
  11022. // {
  11023. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  11024. // if (countryInfo != null)
  11025. // {
  11026. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  11027. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  11028. // if (cityInfo1 != null)
  11029. // {
  11030. // cityInfo1.IsCapital = 0;
  11031. // cityInfos.Add(cityInfo1);
  11032. // }
  11033. // }
  11034. // }
  11035. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  11036. // .UpdateColumns(it => it.IsCapital)
  11037. // .WhereColumns(it => it.Id)
  11038. // .ExecuteCommand();
  11039. // //_sqlSugar.RollbackTran();
  11040. // _sqlSugar.CommitTran();
  11041. // return Ok(JsonView(false, "操作成功!"));
  11042. //}
  11043. //public class CounrtiesDto
  11044. //{
  11045. // public List<CountitiesInfo> MyProperty { get; set; }
  11046. //}
  11047. //public class CountitiesInfo
  11048. //{
  11049. // /// <summary>
  11050. // /// 圣约翰
  11051. // /// </summary>
  11052. // public string capital_name_chinese { get; set; }
  11053. // /// <summary>
  11054. // ///
  11055. // /// </summary>
  11056. // public string capital_name { get; set; }
  11057. // /// <summary>
  11058. // ///
  11059. // /// </summary>
  11060. // public string country_type { get; set; }
  11061. // /// <summary>
  11062. // /// 安提瓜和巴布达
  11063. // /// </summary>
  11064. // public string country_name_chinese { get; set; }
  11065. // /// <summary>
  11066. // /// 安提瓜和巴布达
  11067. // /// </summary>
  11068. // public string country_name_chinese_short { get; set; }
  11069. // /// <summary>
  11070. // /// 安提瓜和巴布达
  11071. // /// </summary>
  11072. // public string country_name_chinese_UN { get; set; }
  11073. // /// <summary>
  11074. // ///
  11075. // /// </summary>
  11076. // public string country_name_english_abbreviation { get; set; }
  11077. // /// <summary>
  11078. // ///
  11079. // /// </summary>
  11080. // public string country_name_english_formal { get; set; }
  11081. // /// <summary>
  11082. // ///
  11083. // /// </summary>
  11084. // public string country_name_english_UN { get; set; }
  11085. // /// <summary>
  11086. // ///
  11087. // /// </summary>
  11088. // public string continent_name { get; set; }
  11089. // /// <summary>
  11090. // ///
  11091. // /// </summary>
  11092. // public string subregion_name { get; set; }
  11093. // /// <summary>
  11094. // ///
  11095. // /// </summary>
  11096. // public string country_code2 { get; set; }
  11097. // /// <summary>
  11098. // ///
  11099. // /// </summary>
  11100. // public string country_code3 { get; set; }
  11101. // /// <summary>
  11102. // ///
  11103. // /// </summary>
  11104. // public string phone_code { get; set; }
  11105. //}
  11106. //public class CountriesInfo : BasicInfo
  11107. //{
  11108. // public List<CitiesInfo> c { get; set; }
  11109. //}
  11110. //public class CitiesInfo : BasicInfo
  11111. //{
  11112. // public List<AreaInfo> c { get; set; }
  11113. //}
  11114. //public class AreaInfo : BasicInfo
  11115. //{
  11116. // public List<AreaInfo> c { get; set; }
  11117. //}
  11118. //public class BasicInfo
  11119. //{
  11120. // public string code { get; set; }
  11121. // public string cn { get; set; }
  11122. // public string lv { get; set; }
  11123. // public string en { get; set; }
  11124. //}
  11125. #endregion
  11126. #region 查看邀请方
  11127. /// <summary>
  11128. /// 查看邀请方
  11129. /// 邀请方信息 Init
  11130. /// </summary>
  11131. /// <param name="dto"></param>
  11132. /// <returns></returns>
  11133. [HttpPost]
  11134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11135. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  11136. {
  11137. string sqlWhere = string.Empty;
  11138. if (!string.IsNullOrEmpty(dto.Search))
  11139. {
  11140. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  11141. }
  11142. string sql = string.Format($@"Select
  11143. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  11144. Id,
  11145. UnitName
  11146. From Res_InvitationOfficialActivityData
  11147. Where IsDel = 0
  11148. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  11149. RefAsync<int> total = 0;
  11150. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11151. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  11152. }
  11153. /// <summary>
  11154. /// 查看邀请方
  11155. /// 国家信息 Init
  11156. /// </summary>
  11157. /// <param name="dto"></param>
  11158. /// <returns></returns>
  11159. [HttpPost]
  11160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11161. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  11162. {
  11163. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  11164. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11165. var diids = groupInfos.Select(it => it.Id).ToList();
  11166. List<string> countrys = new List<string>();
  11167. foreach (var item in country)
  11168. {
  11169. var data = _groupRepository.FormartTeamName(item);
  11170. var dataArray = _groupRepository.GroupSplitCountry(data);
  11171. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  11172. }
  11173. countrys = countrys.Distinct().ToList();
  11174. for (int i = 0; i < countrys.Count; i++)
  11175. {
  11176. string item = countrys[i];
  11177. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  11178. {
  11179. countrys.Remove(item);
  11180. i--;
  11181. }
  11182. }
  11183. RefAsync<int> total = 0;
  11184. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  11185. .Where(it => countrys.Contains(it.Name_CN))
  11186. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  11187. .Select(it => new { id = it.Id, name = it.Name_CN })
  11188. .ToPageListAsync(dto.PageIndex,dto.PageSize, total);
  11189. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  11190. }
  11191. /// <summary>
  11192. /// 查看邀请方
  11193. /// 城市信息 Init
  11194. /// </summary>
  11195. /// <param name="dto"></param>
  11196. /// <returns></returns>
  11197. [HttpPost]
  11198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11199. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  11200. {
  11201. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  11202. RefAsync<int> total = 0;
  11203. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  11204. .Where(it => it.CountriesId == dto.CountiesId)
  11205. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  11206. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  11207. .Select(it => new { id = it.Id, name = it.Name_CN })
  11208. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11209. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  11210. }
  11211. /// <summary>
  11212. /// 查看邀请方
  11213. /// 团组名称 Init
  11214. /// </summary>
  11215. /// <param name="dto"></param>
  11216. /// <returns></returns>
  11217. [HttpPost]
  11218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11219. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  11220. {
  11221. var watch = new Stopwatch();
  11222. watch.Start();
  11223. RefAsync<int> total = 0;
  11224. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  11225. .InnerJoin<Grp_DelegationInfo>((oa,di) => oa.DiId == di.Id)
  11226. .Where((oa, di) => oa.IsDel == 0)
  11227. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  11228. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  11229. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  11230. .Distinct()
  11231. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11232. watch.Stop();
  11233. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  11234. }
  11235. /// <summary>
  11236. /// 查看邀请方
  11237. /// 团组 & 邀请方信息
  11238. /// </summary>
  11239. /// <param name="dto"></param>
  11240. /// <returns></returns>
  11241. [HttpPost]
  11242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11243. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  11244. {
  11245. var watch = new Stopwatch();
  11246. watch.Start();
  11247. RefAsync<int> total = 0;
  11248. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  11249. .AS("Grp_DelegationInfo")
  11250. .Includes(x => x.InvitingInfos)
  11251. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  11252. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  11253. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  11254. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  11255. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  11256. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  11257. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11258. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  11259. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  11260. infos.ForEach(x => {
  11261. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  11262. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  11263. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  11264. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  11265. });
  11266. watch.Stop();
  11267. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  11268. }
  11269. #endregion
  11270. #region 报批行程
  11271. /// <summary>
  11272. /// 报批行程初始化
  11273. /// </summary>
  11274. /// <param name="dto"></param>
  11275. /// <returns></returns>
  11276. [HttpPost]
  11277. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  11278. {
  11279. const int chiNumber = 5;
  11280. var jw = JsonView(false);
  11281. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11282. var group = groupList.First();
  11283. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11284. group = groupList.First(x => x.Id == diid);
  11285. if (group == null)
  11286. {
  11287. jw.Msg = "暂无团组!";
  11288. return Ok(jw);
  11289. }
  11290. var resultArr = new ArrayList();
  11291. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  11292. if (content.Count == 0)
  11293. {
  11294. ////黑屏代码数据
  11295. //DataTable dt = GetTableByBlackCode(group.Id);
  11296. //if (dt.Rows[0]["Day"] == null || dt.Rows[0]["Day"].ToString() == "")//判断黑屏代码数据是否正确生成
  11297. //{
  11298. //}
  11299. //else
  11300. //{
  11301. // jw.Msg = "黑屏代码有误!";
  11302. // return Ok(jw);
  11303. //}
  11304. DateTime StartDate = (group.VisitStartDate);
  11305. DateTime EndDate = (group.VisitEndDate);
  11306. TimeSpan t3 = EndDate - StartDate; //两个时间相减 。默认得到的是 两个时间之间的天数 得到:365.00:00:00
  11307. var getDay = t3.Days;
  11308. if (getDay == 0) getDay = 1;
  11309. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11310. _sqlSugar.BeginTran();
  11311. for (int i = 0; i < getDay; i++)
  11312. {
  11313. DateTime NewData = StartDate.AddDays(i);
  11314. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11315. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11316. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ") 第" + intToString(i + 1) + "天";
  11317. appro.Diid = diid ?? -1;
  11318. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11319. appro.Id = thisId;
  11320. appro.CreateUserId = dto.UserId;
  11321. appro.CreateTime = DateTime.Now;
  11322. content.Add(appro);
  11323. }
  11324. _sqlSugar.CommitTran();
  11325. }
  11326. foreach (var x in content)
  11327. {
  11328. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  11329. if (chiList.Count < chiNumber)
  11330. {
  11331. for (int i = chiList.Count; i < chiNumber; i++)
  11332. {
  11333. chiList.Add(new Grp_ApprovalTravelDetails());
  11334. }
  11335. }
  11336. resultArr.Add(new
  11337. {
  11338. x.Id,
  11339. x.Date,
  11340. x.Diid,
  11341. chiList = chiList.Select(x1 => new
  11342. {
  11343. timeInterval = x1.Time == null ? new string [1] : x1.Time.Split('-'),
  11344. x1.Details,
  11345. x1.ParentId,
  11346. x1.Id
  11347. })
  11348. });
  11349. }
  11350. var data = new
  11351. {
  11352. groupList = groupList.Select(x => new
  11353. {
  11354. x.TeamName,
  11355. x.Id
  11356. }),
  11357. content = resultArr,
  11358. groupInfo = new
  11359. {
  11360. group.VisitDays,
  11361. group.TourCode,
  11362. group.VisitPNumber,
  11363. group.TeamName,
  11364. group.Id,
  11365. group.VisitStartDate,
  11366. group.VisitEndDate
  11367. },
  11368. };
  11369. jw = JsonView(true,"获取成功!",data);
  11370. return Ok(jw);
  11371. }
  11372. /// <summary>
  11373. /// 报批行程删除
  11374. /// </summary>
  11375. /// <param name="dto"></param>
  11376. /// <returns></returns>
  11377. [HttpPost]
  11378. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  11379. {
  11380. var jw = JsonView(false);
  11381. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x=>x.Id == dto.Diid && x.IsDel == 0);
  11382. if (group == null)
  11383. {
  11384. jw.Msg = "团组参数有误!";
  11385. return Ok(jw);
  11386. }
  11387. try
  11388. {
  11389. _sqlSugar.BeginTran();
  11390. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x=>x.Id).ToList();
  11391. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  11392. {
  11393. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11394. DeleteUserId = dto.uesrId,
  11395. IsDel = 1
  11396. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  11397. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  11398. {
  11399. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11400. DeleteUserId = dto.uesrId,
  11401. IsDel = 1
  11402. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  11403. _sqlSugar.CommitTran();
  11404. jw = JsonView(true, "删除成功");
  11405. }
  11406. catch (Exception ex)
  11407. {
  11408. jw = JsonView(false, ex.Message);
  11409. }
  11410. return Ok(jw);
  11411. }
  11412. /// <summary>
  11413. /// 报批行程保存
  11414. /// </summary>
  11415. /// <param name="dto"></param>
  11416. /// <returns></returns>
  11417. [HttpPost]
  11418. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  11419. {
  11420. var jw = JsonView(false);
  11421. var Find = dto.Arr.Find(x => x.id == 0);
  11422. if (Find != null)
  11423. {
  11424. jw.Msg = "生成的ID为0!";
  11425. return Ok(jw);
  11426. }
  11427. foreach (var item in dto.Arr)
  11428. {
  11429. foreach (var chi in item.chiList)
  11430. {
  11431. if (chi.parentId == 0)
  11432. {
  11433. chi.parentId = item.id;
  11434. }
  11435. }
  11436. }
  11437. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  11438. _sqlSugar.BeginTran();
  11439. if (chiArr.Where(x=>x.id == 0).Count() == chiArr.Count)
  11440. {
  11441. var parentIds = dto.Arr.Select(x => x.id).ToList();
  11442. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x=>new Grp_ApprovalTravelDetails
  11443. {
  11444. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11445. DeleteUserId = dto.UserId,
  11446. IsDel = 1
  11447. }).ExecuteCommand();
  11448. }
  11449. try
  11450. {
  11451. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  11452. {
  11453. CreateTime = DateTime.Now,
  11454. CreateUserId = dto.UserId,
  11455. Details = x.details,
  11456. ParentId = x.parentId,
  11457. Time = x.timeInterval.Count > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11458. Remark = "",
  11459. IsDel = 0
  11460. }).ToList()).ExecuteCommand();
  11461. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  11462. {
  11463. Id = x.id,
  11464. Details = x.details,
  11465. ParentId = x.parentId,
  11466. Time = x.timeInterval.Count > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11467. }).ToList()).UpdateColumns(x=> new Grp_ApprovalTravelDetails
  11468. {
  11469. Details = x.Details,
  11470. ParentId = x.ParentId,
  11471. Time = x.Time
  11472. }).ExecuteCommand();
  11473. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  11474. {
  11475. Id = x.id,
  11476. Date = x.date,
  11477. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  11478. {
  11479. Date = x.Date
  11480. }).ExecuteCommand();
  11481. _sqlSugar.CommitTran();
  11482. jw = JsonView(true, "保存成功!");
  11483. }
  11484. catch (Exception ex)
  11485. {
  11486. _sqlSugar.RollbackTran();
  11487. jw = JsonView(false, "保存失败!" + ex.Message);
  11488. }
  11489. return Ok(jw);
  11490. }
  11491. /// <summary>
  11492. /// 报批行程生成
  11493. /// </summary>
  11494. /// <param name="dto"></param>
  11495. /// <returns></returns>
  11496. [HttpPost]
  11497. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  11498. {
  11499. var jw = JsonView(false);
  11500. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11501. if (group == null)
  11502. {
  11503. jw.Msg = "暂无该团组!";
  11504. return Ok(jw);
  11505. }
  11506. DateTime StartDate = (group.VisitStartDate);
  11507. DateTime EndDate = (group.VisitEndDate);
  11508. TimeSpan t3 = EndDate - StartDate;
  11509. var getDay = t3.Days;
  11510. if (getDay == 0) getDay = 1;
  11511. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11512. var resultArr = new ArrayList();
  11513. if (officialActivitiesArr.Count == 0)
  11514. {
  11515. jw.Msg = "暂无公务出访信息!";
  11516. return Ok(jw);
  11517. }
  11518. try
  11519. {
  11520. _sqlSugar.BeginTran();
  11521. DeleteApprovalJourney(new
  11522. Domain.Dtos.Groups.DeleteApprovalJourney
  11523. {
  11524. Diid = dto.Diid,
  11525. uesrId = dto.Userid
  11526. });
  11527. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11528. for (int i = 0; i < getDay; i++)
  11529. {
  11530. DateTime NewData = StartDate.AddDays(i);
  11531. 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();
  11532. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11533. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11534. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ") 第" + intToString(i + 1) + "天";
  11535. appro.Diid = dto.Diid;
  11536. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11537. appro.Id = thisId;
  11538. appro.CreateUserId = dto.Userid;
  11539. appro.CreateTime = DateTime.Now;
  11540. var chiarr = new List<Grp_ApprovalTravelDetails>();
  11541. foreach (var item in gwinfo)
  11542. {
  11543. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  11544. chi.Details = "拜访" + item.Client;
  11545. chi.ParentId = thisId;
  11546. chi.Time = item.Time;
  11547. chiarr.Add(chi);
  11548. }
  11549. if (chiarr.Count < 5)
  11550. {
  11551. for (int j = chiarr.Count; j < 5; j++)
  11552. {
  11553. chiarr.Add(new
  11554. Grp_ApprovalTravelDetails());
  11555. }
  11556. }
  11557. resultArr.Add(new
  11558. {
  11559. appro.Id,
  11560. appro.Date,
  11561. appro.Diid,
  11562. chiList = chiarr.Select(x1 => new
  11563. {
  11564. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  11565. x1.Details,
  11566. x1.ParentId,
  11567. x1.Id
  11568. })
  11569. });
  11570. }
  11571. _sqlSugar.CommitTran();
  11572. jw = JsonView(true, "生成成功!", resultArr);
  11573. }
  11574. catch (Exception ex)
  11575. {
  11576. jw.Code = 400;
  11577. jw.Msg = "生成失败!" + ex.Message;
  11578. }
  11579. return Ok(jw);
  11580. }
  11581. /// <summary>
  11582. /// 报批行程word导出
  11583. /// </summary>
  11584. /// <param name="dto"></param>
  11585. /// <returns></returns>
  11586. [HttpPost]
  11587. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  11588. {
  11589. var jw = JsonView(false);
  11590. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11591. if (group == null)
  11592. {
  11593. jw.Msg = "暂无该团组!";
  11594. return Ok(jw);
  11595. }
  11596. //模板路径
  11597. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx");
  11598. //载入模板
  11599. Document doc = new Document(tempPath);
  11600. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11601. //获取所填表格的序数
  11602. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11603. Aspose.Words.Tables.Row titleRowClone = null;
  11604. Aspose.Words.Tables.Row CenterRowClone = null;
  11605. int index = 0;
  11606. int indexChi = 0;
  11607. int SetIndex = 0;
  11608. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  11609. //获取数据,放到datatable
  11610. foreach (var item in ApprovalTravelArr)
  11611. {
  11612. if (index > 0)
  11613. {
  11614. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  11615. tableOne.AppendChild(titleRowClone);
  11616. }
  11617. var textTime = item.Date;
  11618. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  11619. SetCells(tableOne, doc, SetIndex, 0, textTime);
  11620. SetIndex++;
  11621. if (ChiRep.Count > 0)
  11622. {
  11623. foreach (var itemChi in ChiRep)
  11624. {
  11625. var txtTime = itemChi.Time;
  11626. var txtDetail = itemChi.Details;
  11627. if (indexChi > 0)
  11628. {
  11629. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11630. tableOne.AppendChild(CenterRowClone);
  11631. }
  11632. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  11633. {
  11634. SetCells(tableOne, doc, SetIndex, 0, "");
  11635. SetCells(tableOne, doc, SetIndex, 1, "");
  11636. indexChi++;
  11637. SetIndex++;
  11638. break;
  11639. }
  11640. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  11641. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  11642. indexChi++;
  11643. SetIndex++;
  11644. }
  11645. }
  11646. else
  11647. {
  11648. if (indexChi > 0)
  11649. {
  11650. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11651. tableOne.AppendChild(CenterRowClone);
  11652. }
  11653. SetCells(tableOne, doc, SetIndex, 0, "");
  11654. SetCells(tableOne, doc, SetIndex, 1, "");
  11655. indexChi++;
  11656. SetIndex++;
  11657. }
  11658. index++;
  11659. }
  11660. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  11661. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName);
  11662. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; ;
  11663. jw.Code = 200;
  11664. jw.Msg = "";
  11665. return Ok(jw);
  11666. }
  11667. private string intToString(int numberVal)
  11668. {
  11669. string numberval = numberVal.ToString();
  11670. Dictionary<char, string> Number = new Dictionary<char, string>();
  11671. Number.Add('1', "一");
  11672. Number.Add('2', "二");
  11673. Number.Add('3', "三");
  11674. Number.Add('4', "四");
  11675. Number.Add('5', "五");
  11676. Number.Add('6', "六");
  11677. Number.Add('7', "七");
  11678. Number.Add('8', "八");
  11679. Number.Add('9', "九");
  11680. string stringNumberVal = string.Empty;
  11681. for (int i = 0; i < numberval.Length; i++)
  11682. {
  11683. if (i == 0)
  11684. {
  11685. stringNumberVal += Number[numberval[i]];
  11686. }
  11687. else if (i >= 1)
  11688. {
  11689. if (numberval[i] == '0')
  11690. {
  11691. stringNumberVal = "十";
  11692. }
  11693. else
  11694. {
  11695. stringNumberVal += "十" + Number[numberval[i]];
  11696. }
  11697. }
  11698. }
  11699. return stringNumberVal;
  11700. }
  11701. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  11702. {
  11703. //获取table中的某个单元格,从0开始
  11704. Cell lshCell = table.Rows[rows].Cells[cells];
  11705. //将单元格中的第一个段落移除
  11706. lshCell.FirstParagraph.Remove();
  11707. //新建一个段落
  11708. Paragraph p = new Paragraph(doc);
  11709. var r = new Run(doc, val);
  11710. //把设置的值赋给之前新建的段落
  11711. p.AppendChild(r);
  11712. //将此段落加到单元格内
  11713. lshCell.AppendChild(p);
  11714. }
  11715. #endregion
  11716. // /// <summary>
  11717. // ///
  11718. // /// </summary>
  11719. // /// <param name="_dto"></param>
  11720. // /// <returns></returns>
  11721. // [HttpPost]
  11722. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11723. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11724. // {
  11725. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11726. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  11727. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  11728. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11729. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  11730. // dic_psg.Add("客人", 974);
  11731. // dic_psg.Add("司机", 975);
  11732. // dic_psg.Add("导游", 976);
  11733. // dic_psg.Add("公司内部人员", 977);
  11734. // dic_psg.Add("司机/导游/公司内部人员", 978);
  11735. // foreach (var item in list_visa)
  11736. // {
  11737. // Grp_VisaInfo temp = new Grp_VisaInfo();
  11738. // temp.Id = item.Id;
  11739. // temp.DIId = item.DIId;
  11740. // temp.VisaClient = item.VisaClient;
  11741. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  11742. // temp.VisaCurrency = item.VisaCurrency;
  11743. // temp.IsThird = item.IsThird;
  11744. // if (dic_psg.ContainsKey(item.PassengerType))
  11745. // {
  11746. // temp.PassengerType = dic_psg[item.PassengerType];
  11747. // }
  11748. // else {
  11749. // temp.PassengerType = -1;
  11750. // }
  11751. // temp.VisaNumber = item.VisaNumber;
  11752. // temp.VisaFreeNumber = item.VisaFreeNumber;
  11753. // temp.CreateUserId = item.Operators;
  11754. // DateTime dt_ct;
  11755. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  11756. // if (b_ct)
  11757. // {
  11758. // temp.CreateTime = dt_ct;
  11759. // }
  11760. // else
  11761. // {
  11762. // temp.CreateTime = DateTime.Now;
  11763. // }
  11764. // temp.DeleteTime = "";
  11765. // temp.DeleteUserId = 0;
  11766. // temp.Remark = item.Remark;
  11767. // if (string.IsNullOrEmpty(temp.Remark)) {
  11768. // temp.Remark = "";
  11769. // }
  11770. // temp.IsDel = item.IsDel;
  11771. // temp.VisaDescription = item.VisaAttachment;
  11772. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  11773. //([Id]
  11774. // ,[DIId]
  11775. // ,[VisaClient]
  11776. // ,[VisaPrice]
  11777. // ,[VisaCurrency]
  11778. // ,[IsThird]
  11779. // ,[PassengerType]
  11780. // ,[VisaNumber]
  11781. // ,[VisaFreeNumber]
  11782. // ,[CreateUserId]
  11783. // ,[CreateTime]
  11784. // ,[DeleteTime]
  11785. // ,[DeleteUserId]
  11786. // ,[Remark]
  11787. // ,[IsDel]
  11788. // ,[visaDescription])
  11789. // VALUES
  11790. // ({0},{1},'{2}',{3},{4}
  11791. //,{5},{6},{7},{8},{9}
  11792. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  11793. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  11794. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  11795. //);
  11796. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  11797. // }
  11798. // return Ok(JsonView(true, "操作成功!"));
  11799. // }
  11800. /// <summary>
  11801. /// 123132123
  11802. /// </summary>
  11803. /// <param name="_dto"></param>
  11804. /// <returns></returns>
  11805. [HttpPost]
  11806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11807. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11808. {
  11809. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11810. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  11811. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  11812. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11813. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  11814. dicDetail.Add(789, 1034);
  11815. dicDetail.Add(790, 1035);
  11816. dicDetail.Add(791, 1036);
  11817. dicDetail.Add(792, 1037);
  11818. dicDetail.Add(793, 1038);
  11819. dicDetail.Add(794, 1039);
  11820. dicDetail.Add(795, 1040);
  11821. dicDetail.Add(796, 1041);
  11822. dicDetail.Add(797, 1042);
  11823. dicDetail.Add(798, 1043);
  11824. dicDetail.Add(801, 1044);
  11825. dicDetail.Add(802, 1045);
  11826. dicDetail.Add(803, 1046);
  11827. Dictionary<int, int> dic = new Dictionary<int, int>();
  11828. dic.Add(806, 1027);
  11829. dic.Add(807, 1028);
  11830. dic.Add(808, 1029);
  11831. dic.Add(809, 1030);
  11832. dic.Add(810, 1031);
  11833. dic.Add(811, 1032);
  11834. dic.Add(812, 1033);
  11835. foreach (var item in list_visa)
  11836. {
  11837. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  11838. temp.Coefficient = item.coefficient;
  11839. DateTime dtCrt;
  11840. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  11841. if (b1)
  11842. {
  11843. temp.CreateTime = dtCrt;
  11844. }
  11845. else
  11846. {
  11847. temp.CreateTime = DateTime.Now;
  11848. }
  11849. temp.CreateUserId = item.Operators;
  11850. temp.DeleteTime = "";
  11851. temp.DeleteUserId = 0;
  11852. temp.DiId = int.Parse(item.DIID);
  11853. temp.FilePath = item.FilePath;
  11854. temp.IsDel = item.IsDel;
  11855. temp.Price = item.Price;
  11856. temp.PriceCount = 1;
  11857. temp.PriceCurrency = item.Currency;
  11858. int detailId = 0;
  11859. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  11860. {
  11861. detailId = dicDetail[item.PriceTypeDetail];
  11862. }
  11863. temp.PriceDetailType = detailId;
  11864. temp.PriceDt = DateTime.Now;
  11865. temp.PriceName = item.PriceName;
  11866. temp.PriceSum = item.Price;
  11867. int tid = 0;
  11868. if (dic.ContainsKey(item.PriceType))
  11869. {
  11870. tid = dic[item.PriceType];
  11871. }
  11872. temp.PriceType = tid;
  11873. temp.Remark = item.Remark;
  11874. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  11875. }
  11876. return Ok(JsonView(true, "操作成功!"));
  11877. }
  11878. }
  11879. }