GroupsController.cs 731 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using EyeSoft.Collections.Generic;
  6. using EyeSoft.IO;
  7. using Microsoft.AspNetCore.SignalR;
  8. using MySqlX.XDevAPI.Relational;
  9. using NPOI.HSSF.UserModel;
  10. using NPOI.SS.Format;
  11. using NPOI.SS.UserModel;
  12. using NPOI.SS.Util;
  13. using NPOI.XSSF.UserModel;
  14. using OASystem.API.OAMethodLib;
  15. using OASystem.API.OAMethodLib.File;
  16. using OASystem.API.OAMethodLib.Hub.HubClients;
  17. using OASystem.API.OAMethodLib.Hub.Hubs;
  18. using OASystem.API.OAMethodLib.JuHeAPI;
  19. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  20. using OASystem.Domain.Dtos.CRM;
  21. using OASystem.Domain.Dtos.FileDto;
  22. using OASystem.Domain.Dtos.Financial;
  23. using OASystem.Domain.Dtos.Groups;
  24. using OASystem.Domain.Entities.Customer;
  25. using OASystem.Domain.Entities.Financial;
  26. using OASystem.Domain.Entities.Groups;
  27. using OASystem.Domain.ViewModels;
  28. using OASystem.Domain.ViewModels.Groups;
  29. using OASystem.Domain.ViewModels.Statistics;
  30. using OASystem.Infrastructure.Repositories.Financial;
  31. using OASystem.Infrastructure.Repositories.Groups;
  32. using OfficeOpenXml;
  33. using Quartz.Util;
  34. using SqlSugar;
  35. using SqlSugar.Extensions;
  36. using System.Collections;
  37. using System.Data;
  38. using System.Data.OleDb;
  39. using System.Diagnostics;
  40. using System.Globalization;
  41. using System.IO;
  42. using System.IO.Compression;
  43. using System.Net.Http;
  44. using System.Reflection.PortableExecutable;
  45. using Ubiety.Dns.Core;
  46. using static OASystem.API.OAMethodLib.JWTHelper;
  47. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  48. using Bookmark = Aspose.Words.Bookmark;
  49. using Cell = Aspose.Words.Tables.Cell;
  50. using Table = Aspose.Words.Tables.Table;
  51. namespace OASystem.API.Controllers
  52. {
  53. /// <summary>
  54. /// 团组相关
  55. /// </summary>
  56. //[Authorize]
  57. [Route("api/[controller]/[action]")]
  58. public class GroupsController : ControllerBase
  59. {
  60. private readonly ILogger<GroupsController> _logger;
  61. private readonly GrpScheduleRepository _grpScheduleRep;
  62. private readonly IMapper _mapper;
  63. private readonly DelegationInfoRepository _groupRepository;
  64. private readonly TaskAssignmentRepository _taskAssignmentRep;
  65. private readonly AirTicketResRepository _airTicketResRep;
  66. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  67. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  68. private readonly DelegationEnDataRepository _delegationEnDataRep;
  69. private readonly DelegationVisaRepository _delegationVisaRep;
  70. private readonly VisaPriceRepository _visaPriceRep;
  71. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  72. private readonly HotelPriceRepository _hotelPriceRep;
  73. private readonly CustomersRepository _customersRep;
  74. private readonly MessageRepository _message;
  75. private readonly SqlSugarClient _sqlSugar;
  76. private readonly TourClientListRepository _tourClientListRep;
  77. private readonly TeamRateRepository _teamRateRep;
  78. #region 成本相关
  79. private readonly CheckBoxsRepository _checkBoxs;
  80. private readonly GroupCostRepository _GroupCostRepository;
  81. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  82. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  83. #endregion
  84. private readonly SetDataRepository _setDataRep;
  85. private string url;
  86. private string path;
  87. private readonly EnterExitCostRepository _enterExitCostRep;
  88. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  89. private readonly UsersRepository _usersRep;
  90. private readonly IJuHeApiService _juHeApi;
  91. private readonly InvertedListRepository _invertedListRep;
  92. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  93. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  94. private readonly ThreeCodeRepository _threeCodeRepository;
  95. private readonly HotelInquiryRepository _hotelInquiryRep;
  96. private readonly FeeAuditRepository _feeAuditRep;
  97. private readonly VisaCommissionRepository _visaCommissionRep;
  98. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  99. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  100. public GroupsController(ILogger<GroupsController> logger, IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  101. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  102. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  103. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  104. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  105. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  106. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  107. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
  108. ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep, VisaCommissionRepository visaCommissionRep, ForeignReceivablesRepository ffrRep,
  109. OpinionaireRepository opinionaireRep)
  110. {
  111. _logger = logger;
  112. _mapper = mapper;
  113. _grpScheduleRep = grpScheduleRep;
  114. _groupRepository = groupRepository;
  115. _taskAssignmentRep = taskAssignmentRep;
  116. _airTicketResRep = airTicketResRep;
  117. _sqlSugar = sqlSugar;
  118. url = AppSettingsHelper.Get("ExcelBaseUrl");
  119. path = AppSettingsHelper.Get("ExcelBasePath");
  120. if (!System.IO.Directory.Exists(path))
  121. {
  122. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  123. }
  124. _decreasePaymentsRep = decreasePaymentsRep;
  125. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  126. _delegationEnDataRep = delegationEnDataRep;
  127. _enterExitCostRep = enterExitCostRep;
  128. _delegationVisaRep = delegationVisaRep;
  129. _message = message;
  130. _visaPriceRep = visaPriceRep;
  131. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  132. _checkBoxs = checkBoxs;
  133. _GroupCostRepository = GroupCostRepository;
  134. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  135. _GroupCostParameterRepository = GroupCostParameterRepository;
  136. _hotelPriceRep = hotelPriceRep;
  137. _customersRep = customersRep;
  138. _setDataRep = setDataRep;
  139. _tourClientListRep = tourClientListRep;
  140. _teamRateRep = teamRateRep;
  141. _hubContext = hubContext;
  142. _usersRep = usersRep;
  143. _juHeApi = juHeApi;
  144. _invertedListRep = invertedListRep;
  145. _visaFeeInfoRep = visaFeeInfoRep;
  146. _ticketBlackCodeRep = ticketBlackCodeRep;
  147. _hotelInquiryRep = hotelInquiryRep;
  148. _threeCodeRepository = threeCodeRepository;
  149. _feeAuditRep = feeAuditRep;
  150. _visaCommissionRep = visaCommissionRep;
  151. _ffrRep = ffrRep;
  152. _opinionaireRep = opinionaireRep;
  153. }
  154. #region 流程管控
  155. /// <summary>
  156. /// 获取团组流程管控信息
  157. /// </summary>
  158. /// <param name="paras">参数Json字符串</param>
  159. /// <returns></returns>
  160. [HttpPost]
  161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  162. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  163. {
  164. if (string.IsNullOrEmpty(_jsonDto.Paras))
  165. {
  166. return Ok(JsonView(false, "参数为空"));
  167. }
  168. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  169. if (_ScheduleDto != null)
  170. {
  171. if (_ScheduleDto.SearchType == 2)//获取列表
  172. {
  173. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  174. return Ok(JsonView(_grpScheduleViewList));
  175. }
  176. else//获取对象
  177. {
  178. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  179. if (_grpScheduleView != null)
  180. {
  181. return Ok(JsonView(_grpScheduleView));
  182. }
  183. }
  184. }
  185. else
  186. {
  187. return Ok(JsonView(false, "参数反序列化失败"));
  188. }
  189. return Ok(JsonView(false, "暂无数据!"));
  190. }
  191. /// <summary>
  192. /// 修改团组流程管控详细表数据
  193. /// </summary>
  194. /// <param name="paras"></param>
  195. /// <returns></returns>
  196. [HttpPost]
  197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  198. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  199. {
  200. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  201. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  202. .SetColumns(it => it.Duty == _detail.Duty)
  203. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  204. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  205. .SetColumns(it => it.JobContent == _detail.JobContent)
  206. .SetColumns(it => it.Remark == _detail.Remark)
  207. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  208. .Where(s => s.Id == dto.Id)
  209. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  210. .ExecuteCommandAsync();
  211. if (result > 0)
  212. {
  213. return Ok(JsonView(true, "保存成功!"));
  214. }
  215. return Ok(JsonView(false, "保存失败!"));
  216. }
  217. /// <summary>
  218. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  219. /// </summary>
  220. /// <param name="dto"></param>
  221. /// <returns></returns>
  222. [HttpPost]
  223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  224. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  225. {
  226. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  227. _detail.IsDel = 1;
  228. _detail.DeleteUserId = dto.Duty;
  229. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  230. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  231. .SetColumns(it => it.IsDel == _detail.IsDel)
  232. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  233. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  234. .Where(it => it.Id == dto.Id)
  235. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  236. //.WhereColumns(s => s.Id == dto.Id)
  237. .ExecuteCommandAsync();
  238. if (result > 0)
  239. {
  240. return Ok(JsonView(true, "删除成功!"));
  241. }
  242. return Ok(JsonView(false, "删除失败!"));
  243. }
  244. /// <summary>
  245. /// 增加团组流程管控详细表数据
  246. /// </summary>
  247. /// <param name="dto"></param>
  248. /// <returns></returns>
  249. [HttpPost]
  250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  251. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  252. {
  253. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  254. if (DateTime.Now < _detail.ExpectBeginDt)
  255. {
  256. _detail.StepStatus = 0;
  257. }
  258. else
  259. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  260. _detail.StepStatus = 1;
  261. }
  262. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  263. if (result > 0)
  264. {
  265. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  266. return Ok(JsonView(true, "添加成功!", _result));
  267. }
  268. return Ok(JsonView(false, "添加失败!"));
  269. }
  270. #endregion
  271. #region 团组基本信息
  272. /// <summary>
  273. /// 接团信息列表
  274. /// </summary>
  275. /// <param name="dto">团组列表请求dto</param>
  276. /// <returns></returns>
  277. [HttpPost]
  278. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  279. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  280. {
  281. var groupData = await _groupRepository.GetGroupList(dto);
  282. if (groupData.Code != 0)
  283. {
  284. return Ok(JsonView(false, groupData.Msg));
  285. }
  286. return Ok(JsonView(groupData.Data));
  287. }
  288. /// <summary>
  289. /// 分页查询团组列表
  290. /// </summary>
  291. /// <param name="dto"></param>
  292. /// <returns></returns>
  293. [HttpPost]
  294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  295. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  296. {
  297. var watch = new Stopwatch();
  298. watch.Start();
  299. RefAsync<int> total = 0;
  300. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  301. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  302. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  303. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  304. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  305. .Distinct()
  306. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  307. watch.Stop();
  308. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  309. }
  310. /// <summary>
  311. /// 接团信息列表 Page
  312. /// </summary>
  313. /// <param name="dto">团组列表请求dto</param>
  314. /// <returns></returns>
  315. [HttpPost]
  316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  317. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  318. {
  319. #region 参数验证
  320. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  321. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  322. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  323. #region 页面操作权限验证
  324. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  325. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  326. #endregion
  327. #endregion
  328. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  329. {
  330. string sqlWhere = string.Empty;
  331. if (dto.IsSure == 0) //未完成
  332. {
  333. sqlWhere += string.Format(@" And IsSure = 0");
  334. }
  335. else if (dto.IsSure == 1) //已完成
  336. {
  337. sqlWhere += string.Format(@" And IsSure = 1");
  338. }
  339. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  340. {
  341. string tj = dto.SearchCriteria;
  342. 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}%')",
  343. tj, tj, tj, tj, tj);
  344. }
  345. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  346. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  347. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  348. JietuanOperator,IsSure,CreateTime,IsBid
  349. From (
  350. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  351. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  352. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  353. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  354. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  355. From Grp_DelegationInfo gdi
  356. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  357. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  358. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  359. Where gdi.IsDel = 0 {0}
  360. ) temp", sqlWhere);
  361. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  362. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  363. #region 处理所属部门
  364. /*
  365. * 1.sq 和 gyy 等显示 市场部
  366. * 2.王鸽和主管及张总还有管理员号统一国交部
  367. * 2-1. 4 管理员 ,21 张海麟
  368. */
  369. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  370. List<int> userIds1 = new List<int>() { 4, 21 };
  371. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  372. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  373. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  374. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  375. .ToList();
  376. foreach (var item in _DelegationList)
  377. {
  378. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  379. }
  380. #endregion
  381. var _view = new
  382. {
  383. PageFuncAuth = pageFunAuthView,
  384. Data = _DelegationList
  385. };
  386. return Ok(JsonView(true, "查询成功!", _view, total));
  387. }
  388. else
  389. {
  390. return Ok(JsonView(false, "查询失败"));
  391. }
  392. }
  393. /// <summary>
  394. /// 团组列表
  395. /// </summary>
  396. /// <returns></returns>
  397. [HttpPost]
  398. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  399. {
  400. #region 参数验证
  401. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  402. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  403. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  404. #region 页面操作权限验证
  405. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  406. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  407. #endregion
  408. #endregion
  409. if (dto.PortType != 1 && dto.PortType != 2)
  410. {
  411. return Ok(JsonView(false, "查询失败!"));
  412. }
  413. string orderbyStr = "order by gdi.CreateTime Desc";
  414. string sqlWhere = string.Empty;
  415. if (dto.IsSure == 0) //未完成
  416. {
  417. sqlWhere += string.Format(@" And IsSure = 0");
  418. }
  419. else if (dto.IsSure == 1) //已完成
  420. {
  421. sqlWhere += string.Format(@" And IsSure = 1");
  422. }
  423. //团组类型
  424. if (dto.TeamDid > 0)
  425. {
  426. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  427. }
  428. //团组名称
  429. if (!string.IsNullOrEmpty(dto.TeamName))
  430. {
  431. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  432. }
  433. //客户名称
  434. if (!string.IsNullOrEmpty(dto.ClientName))
  435. {
  436. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  437. }
  438. //客户单位
  439. if (!string.IsNullOrEmpty(dto.ClientUnit))
  440. {
  441. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  442. }
  443. //出访时间
  444. if (!string.IsNullOrEmpty(dto.visitDataTime))
  445. {
  446. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  447. orderbyStr = "order by gdi.VisitDate";
  448. }
  449. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  450. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  451. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  452. JietuanOperator,IsSure,CreateTime
  453. From (
  454. Select row_number() over({0}) as Row_Number,
  455. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  456. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  457. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  458. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  459. From Grp_DelegationInfo gdi
  460. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  461. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  462. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  463. Where gdi.IsDel = 0 {1}
  464. ) temp ", orderbyStr, sqlWhere);
  465. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  466. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  467. #region 处理所属部门
  468. /*
  469. * 1.sq 和 gyy 等显示 市场部
  470. * 2.王鸽和主管及张总还有管理员号统一国交部
  471. * 2-1. 4 管理员 ,21 张海麟
  472. */
  473. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  474. List<int> userIds1 = new List<int>() { 4, 21 };
  475. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  476. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  477. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  478. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  479. .ToList();
  480. foreach (var item in _DelegationList)
  481. {
  482. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  483. }
  484. #endregion
  485. var _view = new
  486. {
  487. PageFuncAuth = pageFunAuthView,
  488. Data = _DelegationList
  489. };
  490. return Ok(JsonView(true, "查询成功!", _view, total));
  491. }
  492. /// <summary>
  493. /// 接团信息详情
  494. /// </summary>
  495. /// <param name="dto">团组info请求dto</param>
  496. /// <returns></returns>
  497. [HttpPost]
  498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  499. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  500. {
  501. var groupData = await _groupRepository.GetGroupInfo(dto);
  502. if (groupData.Code != 0)
  503. {
  504. return Ok(JsonView(false, groupData.Msg));
  505. }
  506. return Ok(JsonView(groupData.Data));
  507. }
  508. /// <summary>
  509. /// 接团信息 编辑添加
  510. /// 基础信息数据源
  511. /// </summary>
  512. /// <param name="dto"></param>
  513. /// <returns></returns>
  514. [HttpPost]
  515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  516. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  517. {
  518. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  519. if (groupData.Code != 0)
  520. {
  521. return Ok(JsonView(false, groupData.Msg));
  522. }
  523. return Ok(JsonView(groupData.Data));
  524. }
  525. /// <summary>
  526. /// 接团信息 操作(增改)
  527. /// </summary>
  528. /// <param name="dto"></param>
  529. /// <returns></returns>
  530. [HttpPost]
  531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  532. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  533. {
  534. try
  535. {
  536. decimal ffrPrice = 0.00M;
  537. DateTime? visitDt = null;
  538. if (dto.Status == 2)
  539. {
  540. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  541. if (groupInfo != null)
  542. {
  543. ffrPrice = groupInfo.PaymentMoney;
  544. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  545. }
  546. }
  547. var groupData = await _groupRepository.GroupOperation(dto);
  548. if (groupData.Code != 0)
  549. {
  550. return Ok(JsonView(false, groupData.Msg));
  551. }
  552. int diId = 0;
  553. //添加时 默认加入团组汇率
  554. if (dto.Status == 1) //添加
  555. {
  556. diId = groupData.Data;
  557. //添加默认币种
  558. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  559. //默认分配权限
  560. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  561. //消息提示 王鸽 主管号
  562. List<int> _managerIds = new List<int>() { 22, 32 };
  563. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  564. if (userIds.Count > 0)
  565. {
  566. userIds.Add(208);
  567. //创建团组管控
  568. GroupStepForDelegation.CreateWorkStep(diId);
  569. //发送消息
  570. string groupName = dto.TeamName;
  571. string createGroupUser = string.Empty;
  572. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  573. if (userInfo != null) createGroupUser = userInfo.CnName;
  574. string title = $"系统通知";
  575. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  576. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  577. }
  578. //默认创建倒推表
  579. await _invertedListRep._Create(dto.UserId, diId);
  580. }
  581. else if (dto.Status == 2)
  582. {
  583. diId = dto.Id;
  584. }
  585. #region 签证人员团组时间通知
  586. #region 计算出访起止时间
  587. var startTime = new DateTime();
  588. var endTime = new DateTime();
  589. if (DateTime.TryParse(dto.VisitDate, out startTime))
  590. {
  591. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  592. }
  593. #endregion
  594. if (diId > 0)
  595. {
  596. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  597. }
  598. #endregion
  599. #region 团组操作默认添加/修改收款账单
  600. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  601. {
  602. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  603. .Where(x => x.IsDel == 0 &&
  604. x.Diid == diId &&
  605. x.Remark.Equals("预付款")
  606. )
  607. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  608. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  609. .FirstAsync();
  610. ffrInfo = new Fin_ForeignReceivables()
  611. {
  612. Diid = diId,
  613. PriceName = dto.ClientUnit,
  614. Price = dto.PaymentMoney,
  615. Count = 1,
  616. Unit = $"元",
  617. ItemSumPrice = dto.PaymentMoney,
  618. Rate = 1.0000M,
  619. Currency = 836,
  620. AddingWay = 0,
  621. CreateUserId = dto.UserId,
  622. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  623. Remark = $"预付款"
  624. };
  625. if (ffrInfo == null) //Add
  626. {
  627. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  628. }
  629. else //修改
  630. {
  631. await _sqlSugar.Updateable(ffrInfo)
  632. .UpdateColumns(x => new
  633. {
  634. x.PriceName,
  635. x.Price,
  636. x.ItemSumPrice,
  637. x.CreateTime,
  638. x.CreateUserId
  639. })
  640. .WhereColumns(x => x.Id)
  641. .ExecuteCommandAsync();
  642. }
  643. }
  644. #endregion
  645. return Ok(JsonView(true, "操作成功!", diId));
  646. }
  647. catch (Exception ex)
  648. {
  649. Logs("[response]" + JsonConvert.SerializeObject(dto));
  650. Logs(ex.Message);
  651. return Ok(JsonView(false, ex.Message));
  652. }
  653. }
  654. /// <summary>
  655. /// 接团流程操作(增改)
  656. /// 安卓端使用 建团时添加客户名单
  657. /// </summary>
  658. /// <param name="dto"></param>
  659. /// <returns></returns>
  660. [HttpPost]
  661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  662. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  663. {
  664. try
  665. {
  666. #region 参数验证
  667. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  668. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  669. #region 页面操作权限验证
  670. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  671. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  672. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  673. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  674. #endregion
  675. #endregion
  676. _sqlSugar.BeginTran();
  677. decimal ffrPrice = 0.00M;
  678. DateTime? visitDt = null;
  679. if (dto.Status == 2)
  680. {
  681. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  682. if (groupInfo != null)
  683. {
  684. ffrPrice = groupInfo.PaymentMoney;
  685. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  686. }
  687. }
  688. var _dto = new GroupOperationDto();
  689. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  690. var groupData = await _groupRepository.GroupOperation(_dto);
  691. if (groupData.Code != 0)
  692. {
  693. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  694. }
  695. int diId = 0;
  696. //添加时 默认加入团组汇率
  697. if (dto.Status == 1) //添加
  698. {
  699. diId = groupData.Data;
  700. //添加默认币种
  701. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  702. //默认分配权限
  703. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  704. //消息提示 王鸽 主管号
  705. List<int> _managerIds = new List<int>() { 22, 32 };
  706. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  707. if (userIds.Count > 0)
  708. {
  709. userIds.Add(208);
  710. //创建团组管控
  711. GroupStepForDelegation.CreateWorkStep(diId);
  712. //发送消息
  713. string groupName = dto.TeamName;
  714. string createGroupUser = string.Empty;
  715. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  716. if (userInfo != null) createGroupUser = userInfo.CnName;
  717. string title = $"系统通知";
  718. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  719. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  720. }
  721. #region 应用推送
  722. try
  723. {
  724. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  725. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  726. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  727. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  728. {
  729. List<string> userList = new List<string>() { users.QiyeChatUserId };
  730. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  731. }
  732. }
  733. catch (Exception ex)
  734. {
  735. }
  736. #endregion
  737. //默认创建倒推表
  738. await _invertedListRep._Create(dto.UserId, diId);
  739. }
  740. if (dto.Status == 2)
  741. {
  742. diId = dto.Id;
  743. if (diId == 0)
  744. {
  745. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  746. }
  747. }
  748. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  749. if (viewData.Code != 0)
  750. {
  751. _sqlSugar.RollbackTran();
  752. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  753. }
  754. #region 团组操作默认添加/修改收款账单
  755. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  756. {
  757. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  758. .Where(x => x.IsDel == 0 &&
  759. x.Diid == diId &&
  760. x.Remark.Equals("预付款")
  761. )
  762. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  763. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  764. .FirstAsync();
  765. ffrInfo = new Fin_ForeignReceivables()
  766. {
  767. Diid = diId,
  768. PriceName = dto.ClientUnit,
  769. Price = dto.PaymentMoney,
  770. Count = 1,
  771. Unit = $"元",
  772. ItemSumPrice = dto.PaymentMoney,
  773. Rate = 1.0000M,
  774. Currency = 836,
  775. AddingWay = 0,
  776. CreateUserId = dto.UserId,
  777. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  778. Remark = $"预付款"
  779. };
  780. if (ffrInfo == null) //Add
  781. {
  782. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  783. }
  784. else //修改
  785. {
  786. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  787. .UpdateColumns(x => new
  788. {
  789. x.PriceName,
  790. x.Price,
  791. x.ItemSumPrice,
  792. x.CreateTime,
  793. x.CreateUserId
  794. })
  795. .WhereColumns(x => x.Id)
  796. .ExecuteCommandAsync();
  797. }
  798. }
  799. #endregion
  800. #region 签证人员团组时间通知
  801. #region 计算出访起止时间
  802. var startTime = new DateTime();
  803. var endTime = new DateTime();
  804. if (DateTime.TryParse(dto.VisitDate, out startTime))
  805. {
  806. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  807. }
  808. #endregion
  809. if (diId > 0)
  810. {
  811. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  812. }
  813. #endregion
  814. _sqlSugar.CommitTran();
  815. return Ok(JsonView(true, "添加成功"));
  816. }
  817. catch (Exception ex)
  818. {
  819. _sqlSugar.RollbackTran();
  820. return Ok(JsonView(false, ex.Message));
  821. }
  822. }
  823. /// <summary>
  824. /// 接团信息 操作(删除)
  825. /// </summary>
  826. /// <param name="dto"></param>
  827. /// <returns></returns>
  828. [HttpPost]
  829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  830. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  831. {
  832. try
  833. {
  834. var groupData = await _groupRepository.GroupDel(dto);
  835. if (groupData.Code != 0)
  836. {
  837. return Ok(JsonView(false, groupData.Msg));
  838. }
  839. return Ok(JsonView(true));
  840. }
  841. catch (Exception ex)
  842. {
  843. Logs("[response]" + JsonConvert.SerializeObject(dto));
  844. Logs(ex.Message);
  845. return Ok(JsonView(false, ex.Message));
  846. }
  847. }
  848. /// <summary>
  849. /// 获取团组销售报价号
  850. /// 团组添加时 使用
  851. /// </summary>
  852. /// <returns></returns>
  853. [HttpPost]
  854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  855. public async Task<IActionResult> GetGroupSalesQuoteNo()
  856. {
  857. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  858. if (groupData.Code != 0)
  859. {
  860. return Ok(JsonView(false, groupData.Msg));
  861. }
  862. object salesQuoteNo = new
  863. {
  864. SalesQuoteNo = groupData.Data
  865. };
  866. return Ok(JsonView(salesQuoteNo));
  867. }
  868. /// <summary>
  869. /// 设置确认出团
  870. /// </summary>
  871. /// <param name="dto"></param>
  872. /// <returns></returns>
  873. [HttpPost]
  874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  875. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  876. {
  877. var groupData = await _groupRepository.ConfirmationGroup(dto);
  878. if (groupData.Code != 0)
  879. {
  880. return Ok(JsonView(false, groupData.Msg));
  881. }
  882. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  883. #region OA消息推送
  884. try
  885. {
  886. string groupName = groupInfo.TeamName;
  887. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  888. List<int> userIds = new List<int>();
  889. listUser.ForEach(s => userIds.Add(s.Id));
  890. string title = $"系统通知";
  891. string content = $"团组[{groupName}]已确认出团!";
  892. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  893. }
  894. catch (Exception ex)
  895. {
  896. }
  897. #endregion
  898. #region 应用推送
  899. try
  900. {
  901. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  902. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  903. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  904. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  905. {
  906. List<string> userList = new List<string>() { users.QiyeChatUserId };
  907. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  908. }
  909. }
  910. catch (Exception ex)
  911. {
  912. }
  913. #endregion
  914. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  915. return Ok(JsonView(true, "操作成功!", groupData.Data));
  916. }
  917. /// <summary>
  918. /// 获取团组名称data And 签证国别Data
  919. /// </summary>
  920. /// <param name="dto"></param>
  921. /// <returns></returns>
  922. [HttpPost]
  923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  924. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  925. {
  926. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  927. if (groupData.Code != 0)
  928. {
  929. return Ok(JsonView(false, groupData.Msg));
  930. }
  931. return Ok(JsonView(groupData.Data));
  932. }
  933. /// <summary>
  934. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  935. /// </summary>
  936. /// <returns></returns>
  937. [HttpPost]
  938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  939. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  940. {
  941. try
  942. {
  943. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  944. if (groupData.Code != 0)
  945. {
  946. return Ok(JsonView(false, groupData.Msg));
  947. }
  948. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  949. }
  950. catch (Exception ex)
  951. {
  952. return Ok(JsonView(false, "程序错误!"));
  953. throw;
  954. }
  955. }
  956. /// <summary>
  957. /// 团组清单 Excel
  958. /// </summary>
  959. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  960. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  961. /// <returns></returns>
  962. [HttpGet]
  963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  964. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  965. {
  966. DateTime _beginDt, _endDt;
  967. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  968. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  969. if (!beginBool && !endBool)
  970. {
  971. return Ok(JsonView(false, "开始或结束时间不正确!"));
  972. }
  973. string sql = string.Format(@"
  974. SELECT
  975. ROW_NUMBER,
  976. Id,
  977. SalesQuoteNo,
  978. TourCode,
  979. TeamTypeId,
  980. TeamType,
  981. TeamLevId,
  982. TeamLev,
  983. TeamName,
  984. ClientName,
  985. ClientUnit,
  986. VisitDate,
  987. VisitDays,
  988. VisitPNumber,
  989. JietuanOperatorId,
  990. JietuanOperator,
  991. IsSure,
  992. CreateTime,
  993. IsBid
  994. FROM
  995. (
  996. SELECT
  997. ROW_NUMBER() OVER(
  998. ORDER BY
  999. gdi.CreateTime Desc
  1000. ) AS ROW_NUMBER,
  1001. gdi.Id,
  1002. SalesQuoteNo,
  1003. TourCode,
  1004. ssd.Id TeamTypeId,
  1005. ssd.Name TeamType,
  1006. ssd1.Id TeamLevId,
  1007. ssd1.Name TeamLev,
  1008. TeamName,
  1009. ClientName,
  1010. ClientUnit,
  1011. VisitDate,
  1012. VisitDays,
  1013. VisitPNumber,
  1014. JietuanOperator JietuanOperatorId,
  1015. su.CnName JietuanOperator,
  1016. IsSure,
  1017. gdi.CreateTime,
  1018. gdi.IsBid
  1019. FROM
  1020. Grp_DelegationInfo gdi
  1021. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1022. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1023. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1024. WHERE
  1025. gdi.IsDel = 0
  1026. AND gdi.IsBid = 0
  1027. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1028. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1029. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1030. #region 处理所属部门
  1031. /*
  1032. * 1.sq 和 gyy 等显示 市场部
  1033. * 2.王鸽和主管及张总还有管理员号统一国交部
  1034. * 2-1. 4 管理员 ,21 张海麟
  1035. */
  1036. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1037. List<int> userIds1 = new List<int>() { 4, 21 };
  1038. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1039. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1040. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1041. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1042. .ToListAsync();
  1043. foreach (var item in groupList)
  1044. {
  1045. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1046. }
  1047. #endregion
  1048. #region Excel
  1049. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1050. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1051. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1052. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1053. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1054. //载入模板
  1055. WorkbookDesigner designer = new WorkbookDesigner();
  1056. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1057. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1058. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1059. dt.TableName = "GroupList";
  1060. designer.SetDataSource(dt);
  1061. designer.Process();
  1062. if (!Directory.Exists(savePath))
  1063. {
  1064. Directory.CreateDirectory(savePath);
  1065. }
  1066. string serverPath = $"{savePath}{fileName}";
  1067. designer.Workbook.Save(serverPath);
  1068. string rst = $"{servicePath}{ftpPath}{fileName}";
  1069. #endregion
  1070. return Ok(JsonView(true, "操作成功!", rst));
  1071. }
  1072. #endregion
  1073. #region 团组&签证
  1074. /// <summary>
  1075. /// 根据团组Id获取签证客户信息List
  1076. /// </summary>
  1077. /// <param name="dto">请求dto</param>
  1078. /// <returns></returns>
  1079. [HttpPost]
  1080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1081. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1082. {
  1083. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1084. if (groupData.Code != 0)
  1085. {
  1086. return Ok(JsonView(false, groupData.Msg));
  1087. }
  1088. return Ok(JsonView(groupData.Data));
  1089. }
  1090. /// <summary>
  1091. /// IOS获取团组签证拍照上传进度01(团组列表)
  1092. /// </summary>
  1093. /// <param name="dto">请求dto</param>
  1094. /// <returns></returns>
  1095. [HttpPost]
  1096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1097. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1098. {
  1099. if (dto == null)
  1100. {
  1101. return Ok(JsonView(false, "参数为空"));
  1102. }
  1103. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1104. return Ok(JsonView(visaList));
  1105. }
  1106. /// <summary>
  1107. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1108. /// </summary>
  1109. /// <returns></returns>
  1110. [HttpPost]
  1111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1112. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1113. {
  1114. if (dto == null)
  1115. {
  1116. return Ok(JsonView(false, "请求错误:"));
  1117. }
  1118. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1119. return Ok(JsonView(list));
  1120. }
  1121. /// <summary>
  1122. /// IOS获取团组签证拍照上传进度03(相册)
  1123. /// </summary>
  1124. /// <returns></returns>
  1125. [HttpPost]
  1126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1127. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1128. {
  1129. if (dto == null)
  1130. {
  1131. return Ok(JsonView(false, "请求错误:"));
  1132. }
  1133. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1134. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1135. list.ForEach(s => s.url = url);
  1136. return Ok(JsonView(list));
  1137. }
  1138. /// <summary>
  1139. /// IOS获取团组签证拍照上传进度04(图片上传)
  1140. /// </summary>
  1141. /// <param name="dto"></param>
  1142. /// <returns></returns>
  1143. [HttpPost]
  1144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1145. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1146. {
  1147. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1148. //if (!string.IsNullOrEmpty(result))
  1149. //{
  1150. //}
  1151. //else {
  1152. // return Ok(JsonView(false, "上传失败"));
  1153. //}
  1154. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1155. int sucNum = 0;
  1156. try
  1157. {
  1158. foreach (var item in dto.base64DataList)
  1159. {
  1160. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1161. string result = decodeBase64ToImage(item, imageName);
  1162. if (!string.IsNullOrEmpty(result))
  1163. {
  1164. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1165. pic.CreateUserId = dto.CreateUserId;
  1166. pic.PicName = imageName;
  1167. pic.PicPath = result;
  1168. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1169. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1170. if (insertResult > 0)
  1171. {
  1172. sucNum++;
  1173. }
  1174. }
  1175. }
  1176. }
  1177. catch (Exception ex)
  1178. {
  1179. return Ok(JsonView(false, ex.Message));
  1180. }
  1181. string msg = string.Format(@"成功上传{0}张", sucNum);
  1182. return Ok(JsonView(true, msg));
  1183. }
  1184. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1185. {
  1186. string filename = "";//声明一个string类型的相对路径
  1187. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1188. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1189. try//会有异常抛出,try,catch一下
  1190. {
  1191. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1192. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1193. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1194. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1195. //文件名称
  1196. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1197. //上传的文件的路径
  1198. string filePath = "";
  1199. if (!Directory.Exists(fileDir))
  1200. {
  1201. Directory.CreateDirectory(fileDir);
  1202. }
  1203. //上传的文件的路径
  1204. filePath = fileDir + filename;
  1205. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1206. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1207. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1208. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1209. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1210. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1211. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1212. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1213. bitmap.Dispose();
  1214. }
  1215. catch (Exception e)
  1216. {
  1217. string massage = e.Message;
  1218. Logs("IOS图片上传Error:" + massage);
  1219. //filename = e.Message;
  1220. }
  1221. return filename;//返回相对路径
  1222. }
  1223. /// <summary>
  1224. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1225. /// </summary>
  1226. /// <param name="dto"></param>
  1227. /// <returns></returns>
  1228. [HttpPost]
  1229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1230. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1231. {
  1232. if (dto == null)
  1233. {
  1234. return Ok(JsonView(false, "请求错误:"));
  1235. }
  1236. string msg = "参数错误";
  1237. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1238. {
  1239. try
  1240. {
  1241. //_delegationVisaRep.BeginTran();
  1242. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1243. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1244. .Where(s => s.Id == dto.visaProgressCustomerId)
  1245. .ExecuteCommandAsync();
  1246. if (updCount > 0 && dto.publishCode == 1)
  1247. {
  1248. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1249. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1250. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1251. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1252. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1253. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1254. if (groupData == null)
  1255. {
  1256. _delegationVisaRep.RollbackTran();
  1257. }
  1258. string title = string.Format(@"[签证进度更新]");
  1259. string content = string.Format(@"测试文本");
  1260. bool rst = await _message.AddMsg(new MessageDto()
  1261. {
  1262. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1263. IssuerId = dto.publisher,
  1264. Title = title,
  1265. Content = content,
  1266. ReleaseTime = DateTime.Now,
  1267. UIdList = new List<int> {
  1268. 234
  1269. }
  1270. });
  1271. if (rst)
  1272. {
  1273. return Ok(JsonView(true, "发送通知成功"));
  1274. }
  1275. }
  1276. //_delegationVisaRep.CommitTran();
  1277. }
  1278. catch (Exception)
  1279. {
  1280. //_delegationVisaRep.RollbackTran();
  1281. }
  1282. }
  1283. return Ok(JsonView(true, msg));
  1284. }
  1285. #endregion
  1286. #region 团组任务分配
  1287. /// <summary>
  1288. /// 团组任务分配初始化
  1289. /// </summary>
  1290. /// <param name="dto"></param>
  1291. /// <returns></returns>
  1292. [HttpPost]
  1293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1294. public async Task<IActionResult> GetTaskAssignmen()
  1295. {
  1296. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1297. if (groupData.Code != 0)
  1298. {
  1299. return Ok(JsonView(false, groupData.Msg));
  1300. }
  1301. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1302. }
  1303. /// <summary>
  1304. /// 团组任务分配查询
  1305. /// </summary>
  1306. /// <param name="dto"></param>
  1307. /// <returns></returns>
  1308. [HttpPost]
  1309. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1310. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1311. {
  1312. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1313. if (groupData.Code != 0)
  1314. {
  1315. return Ok(JsonView(false, groupData.Msg));
  1316. }
  1317. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1318. }
  1319. /// <summary>
  1320. /// 团组任务分配操作
  1321. /// </summary>
  1322. /// <param name="dto"></param>
  1323. /// <returns></returns>
  1324. [HttpPost]
  1325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1326. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1327. {
  1328. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1329. if (groupData.Code != 0)
  1330. {
  1331. return Ok(JsonView(false, groupData.Msg));
  1332. }
  1333. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1334. }
  1335. /// <summary>
  1336. /// 团组任务分配
  1337. /// 批量分配
  1338. /// 查询团组
  1339. /// </summary>
  1340. /// <param name="dto"></param>
  1341. /// <returns></returns>
  1342. [HttpPost]
  1343. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1344. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1345. {
  1346. //参数验证
  1347. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1348. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1349. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1350. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1351. }
  1352. /// <summary>
  1353. /// 团组任务分配
  1354. /// 批量分配
  1355. /// </summary>
  1356. /// <param name="dto"></param>
  1357. /// <returns></returns>
  1358. [HttpPost]
  1359. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1360. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1361. {
  1362. //参数验证
  1363. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1364. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1365. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1366. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1367. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1368. }
  1369. #endregion
  1370. #region 团组费用审核
  1371. /// <summary>
  1372. /// 费用审核
  1373. /// 团组列表 Page
  1374. /// </summary>
  1375. /// <param name="_dto">团组列表请求dto</param>
  1376. /// <returns></returns>
  1377. [HttpPost]
  1378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1379. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1380. {
  1381. #region 参数验证
  1382. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1383. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1384. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1385. #region 页面操作权限验证
  1386. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1387. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1388. #endregion
  1389. #endregion
  1390. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1391. {
  1392. string sqlWhere = string.Empty;
  1393. if (_dto.IsSure == 0) //未完成
  1394. {
  1395. sqlWhere += string.Format(@" And IsSure = 0");
  1396. }
  1397. else if (_dto.IsSure == 1) //已完成
  1398. {
  1399. sqlWhere += string.Format(@" And IsSure = 1");
  1400. }
  1401. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1402. {
  1403. string tj = _dto.SearchCriteria;
  1404. 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}%')",
  1405. tj, tj, tj, tj, tj);
  1406. }
  1407. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1408. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1409. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1410. From (
  1411. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1412. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1413. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1414. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1415. From Grp_DelegationInfo gdi
  1416. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1417. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1418. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1419. Where gdi.IsDel = 0 {0}
  1420. ) temp ", sqlWhere);
  1421. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1422. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1423. var _view = new
  1424. {
  1425. PageFuncAuth = pageFunAuthView,
  1426. Data = _DelegationList
  1427. };
  1428. return Ok(JsonView(true, "查询成功!", _view, total));
  1429. }
  1430. else
  1431. {
  1432. return Ok(JsonView(false, "查询失败"));
  1433. }
  1434. }
  1435. /// <summary>
  1436. /// 获取团组费用审核
  1437. /// </summary>
  1438. /// <param name="paras">参数Json字符串</param>
  1439. /// <returns></returns>
  1440. [HttpPost]
  1441. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1442. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1443. {
  1444. try
  1445. {
  1446. #region 参数验证
  1447. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1448. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1449. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1450. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1451. #region 页面操作权限验证
  1452. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1453. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1454. #endregion
  1455. #endregion
  1456. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1457. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1458. #region 费用清单
  1459. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1460. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1461. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1462. List<Grp_CreditCardPayment> entityList = _groupRepository
  1463. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1464. .Where(exp.ToExpression())
  1465. .ToList();
  1466. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1467. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1468. /*
  1469. * 76://酒店预订
  1470. */
  1471. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1472. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1473. .ToListAsync();
  1474. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1475. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1476. .ToListAsync();
  1477. /*
  1478. * 79://车/导游地接
  1479. */
  1480. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1481. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1482. .ToListAsync();
  1483. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1484. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1485. .ToListAsync();
  1486. /*
  1487. * 80: //签证
  1488. */
  1489. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1490. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1491. .ToListAsync();
  1492. /*
  1493. *81: //邀请/公务活动
  1494. */
  1495. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1496. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1497. .ToListAsync();
  1498. /*
  1499. * 82: //团组客户保险
  1500. */
  1501. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1502. /*
  1503. * Lable = 85 机票预订
  1504. */
  1505. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1506. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1507. .ToListAsync();
  1508. /*
  1509. * 85 机票预定
  1510. */
  1511. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1512. /*
  1513. * 98 其他款项
  1514. */
  1515. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1516. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1517. .ToListAsync();
  1518. /*
  1519. * 285:收款退还
  1520. */
  1521. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1522. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1523. .ToListAsync();
  1524. /*
  1525. * 1015: //超支费用
  1526. */
  1527. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1528. /*
  1529. * 币种信息
  1530. */
  1531. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1532. /*
  1533. * 车/导游地接 费用类型
  1534. */
  1535. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1536. /*
  1537. * 车/导游地接 费用类型
  1538. */
  1539. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1540. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1541. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1542. /*
  1543. * 用户信息
  1544. */
  1545. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1546. /*
  1547. * 费用模块
  1548. */
  1549. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1550. string priceModule = string.Empty;
  1551. if (sdPriceName != null)
  1552. {
  1553. priceModule = sdPriceName.Name;
  1554. }
  1555. /*
  1556. * 成本信息
  1557. */
  1558. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1559. decimal _groupRate = 0.0000M;
  1560. string _groupCurrencyCode = "-";
  1561. if (groupCost != null)
  1562. {
  1563. _groupRate = groupCost.Rate;
  1564. if (int.TryParse(groupCost.Currency, out int _currency))
  1565. {
  1566. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1567. }
  1568. else _groupCurrencyCode = groupCost.Currency;
  1569. }
  1570. string costContentSql = $"Select * From Grp_GroupCost";
  1571. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1572. //处理日期为空的天数
  1573. for (int i = 0; i < groupCostDetails.Count; i++)
  1574. if (i != 0)
  1575. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1576. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1577. /*
  1578. * 处理详情数据
  1579. */
  1580. foreach (var entity in entityList)
  1581. {
  1582. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1583. _detail.Id = entity.Id;
  1584. _detail.PriceName = priceModule;
  1585. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1586. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1587. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1588. //处理金额
  1589. if (entity.CTable == 1015)
  1590. {
  1591. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1592. if (czInfo != null)
  1593. {
  1594. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1595. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1596. }
  1597. }
  1598. /*
  1599. * 应付款金额
  1600. */
  1601. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1602. string PaymentCurrency_WaitPay = "Unknown";
  1603. string hotelCurrncyCode = "Unknown";
  1604. string hotelCurrncyName = "Unknown";
  1605. if (sdPaymentCurrency_WaitPay != null)
  1606. {
  1607. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1608. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1609. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1610. if (hotelCurrncyCode.Equals("CNY"))
  1611. {
  1612. entity.DayRate = 1.0000M;
  1613. }
  1614. }
  1615. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1616. /*
  1617. * 此次付款金额
  1618. */
  1619. decimal CurrPayStr = 0.00M,
  1620. OriginalCurrPay = 0.00M;
  1621. if (entity.PayPercentage == 0)
  1622. {
  1623. if (entity.PayThenMoney != 0)
  1624. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1625. }
  1626. else
  1627. {
  1628. if (entity.PayMoney != 0)
  1629. {
  1630. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1631. }
  1632. }
  1633. if (_dto.Label == 79)
  1634. {
  1635. string original = string.Empty;
  1636. if (hotelCurrncyCode.Equals("CNY"))
  1637. {
  1638. OriginalCurrPay = CurrPayStr;
  1639. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1640. }
  1641. else
  1642. {
  1643. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1644. //760 EUR(7600.00 CNY)
  1645. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1646. }
  1647. }
  1648. else
  1649. {
  1650. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1651. }
  1652. /*
  1653. * 剩余尾款
  1654. */
  1655. decimal BalanceStr = 0;
  1656. if (CurrPayStr != 0)
  1657. {
  1658. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1659. BalanceStr = 0;
  1660. else
  1661. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1662. }
  1663. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1664. /*
  1665. * Bus名称
  1666. */
  1667. _detail.BusName = "待增加";
  1668. /*
  1669. *费用所属
  1670. */
  1671. switch (entity.CTable)
  1672. {
  1673. case 76://酒店预订
  1674. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1675. if (hotelReservations != null)
  1676. {
  1677. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1678. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1679. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1680. string roomFeeStr = "", roomFeestr1 = "";
  1681. //是否比较房型价格
  1682. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1683. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1684. roomFeeStr += $"<br/>";
  1685. if (hotelReservations.SingleRoomPrice > 0)
  1686. {
  1687. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1688. __isSingle = true;
  1689. }
  1690. if (hotelReservations.DoubleRoomPrice > 0)
  1691. {
  1692. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1693. __isDouble = true;
  1694. }
  1695. if (hotelReservations.SuiteRoomPrice > 0)
  1696. {
  1697. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1698. __isSuite = true;
  1699. }
  1700. if (hotelReservations.OtherRoomPrice > 0)
  1701. {
  1702. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1703. __isOther = true;
  1704. }
  1705. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1706. else roomFeeStr += " 0.00 * 0";
  1707. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1708. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1709. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1710. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1711. /*
  1712. * 费用类型
  1713. * 1:房费
  1714. * 2:早餐
  1715. * 3:地税
  1716. * 4:城市税
  1717. * </summary>
  1718. */
  1719. //地税
  1720. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1721. if (governmentRentData != null)
  1722. {
  1723. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1724. governmentRentFee = governmentRentData.Price;
  1725. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1726. if (governmentRentCurrData != null)
  1727. {
  1728. governmentRentCode = governmentRentCurrData.Name;
  1729. governmentRentName = $"({governmentRentCurrData.Remark})";
  1730. }
  1731. }
  1732. //城市税
  1733. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1734. if (cityTaxData != null)
  1735. {
  1736. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1737. cityTaxFee = cityTaxData.Price;
  1738. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1739. if (cityTaxCurrData != null)
  1740. {
  1741. cityTaxCode = cityTaxCurrData.Name;
  1742. cityTaxName = $"({cityTaxCurrData.Remark})";
  1743. }
  1744. }
  1745. //酒店早餐
  1746. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1747. if (breakfastData != null)
  1748. {
  1749. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1750. breakfastFee = breakfastData.Price;
  1751. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1752. if (breakfastCurrData != null)
  1753. {
  1754. breakfastCode = breakfastCurrData.Name;
  1755. breakfastName = $"({breakfastCurrData.Remark})";
  1756. }
  1757. }
  1758. //房间费用
  1759. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1760. if (roomData != null)
  1761. {
  1762. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1763. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1764. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1765. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1766. roomFee = roomData.Price;
  1767. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1768. if (roomCurrData != null)
  1769. {
  1770. roomCode = roomCurrData.Name;
  1771. roomName = $"({roomCurrData.Remark})";
  1772. }
  1773. }
  1774. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1775. string hotelCostStr = "";
  1776. decimal hotelCsotTotal = 0.00M;
  1777. if (groupCost != null)
  1778. {
  1779. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1780. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1781. }
  1782. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1783. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1784. string hotelCost_day = "";
  1785. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1786. foreach (var item in hotelCostDetails1)
  1787. {
  1788. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1789. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1790. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1791. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1792. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1793. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1794. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1795. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1796. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1797. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1798. hotelCost_day += @$"<br/>";
  1799. }
  1800. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1801. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1802. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1803. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1804. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1805. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1806. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1807. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1808. $"房间说明: {hotelReservations.Remark} <br/>" +
  1809. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1810. $"{hotelBreakfastStr}" +
  1811. $"{hotelGovernmentRentStr}" +
  1812. $"{hotelCityTaxStr}";
  1813. _detail.PriceNameContent = hotelReservations.HotelName;
  1814. }
  1815. break;
  1816. case 79://车/导游地接
  1817. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1818. if (touristGuideGroundReservations != null)
  1819. {
  1820. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1821. {
  1822. _detail.BusName = touristGuideGroundReservations.BusName;
  1823. }
  1824. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1825. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1826. //if (isInt)
  1827. //{
  1828. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1829. // if (cityInfo != null)
  1830. // {
  1831. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1832. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1833. // if (carFeeItem != null)
  1834. // {
  1835. // nameContent += $@"({carFeeItem.Name})";
  1836. // }
  1837. // _detail.PriceNameContent = nameContent;
  1838. // }
  1839. //}
  1840. //else
  1841. //{
  1842. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1843. //}
  1844. var touristGuideGroundReservationsContents =
  1845. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1846. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1847. foreach (var item in touristGuideGroundReservationsContents)
  1848. {
  1849. string typeName = "Unknown";
  1850. string carCurrencyCode = "Unknown";
  1851. string carCurrencyName = "Unknown";
  1852. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1853. if (carTypeData != null) typeName = carTypeData.Name;
  1854. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1855. if (currencyData != null)
  1856. {
  1857. carCurrencyCode = currencyData.Name;
  1858. carCurrencyName = currencyData.Remark;
  1859. }
  1860. //op、成本 币种是否一致
  1861. bool IsCurrencyAgreement = false;
  1862. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1863. string opCostStr = string.Empty;
  1864. decimal opCostTypePrice = 0.00M;
  1865. #region 处理成本各项费用
  1866. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1867. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1868. if (opCost.Count > 0)
  1869. {
  1870. switch (item.SId)
  1871. {
  1872. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1873. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1874. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1875. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1876. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1877. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1878. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1879. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1880. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1881. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1882. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1883. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1884. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1885. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1886. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1887. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1888. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1889. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1890. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1891. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1892. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1893. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1894. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1895. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1896. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1897. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1898. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1899. }
  1900. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1901. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1902. }
  1903. #endregion
  1904. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1905. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1906. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1907. $"{opTypeStr} {opCostStr}<br/>" +
  1908. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1909. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1910. }
  1911. _detail.PriceMsgContent = priceMsg;
  1912. }
  1913. break;
  1914. case 80: //签证
  1915. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1916. if (visaInfo != null)
  1917. {
  1918. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1919. _detail.PriceNameContent = visaInfo.VisaDescription;
  1920. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1921. }
  1922. break;
  1923. case 81: //邀请/公务活动
  1924. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1925. if (_ioa != null)
  1926. {
  1927. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1928. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1929. sendCurrName = "Unknown", //快递费用币种 Name
  1930. sendCurrCode = "Unknown", //快递费用币种 Code
  1931. eventsCurrName = "Unknown", //公务活动费币种 Name
  1932. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1933. translateCurrName = "Unknown", //公务翻译费 Name
  1934. translateCurrCode = "Unknown"; //公务翻译费 Code
  1935. #region 处理费用币种
  1936. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1937. if (inviteCurrData != null)
  1938. {
  1939. inviteCurrName = inviteCurrData.Remark;
  1940. inviteCurrCode = inviteCurrData.Name;
  1941. }
  1942. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1943. if (sendCurrData != null)
  1944. {
  1945. sendCurrName = sendCurrData.Remark;
  1946. sendCurrCode = sendCurrData.Name;
  1947. }
  1948. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1949. if (eventsCurrData != null)
  1950. {
  1951. eventsCurrName = eventsCurrData.Remark;
  1952. eventsCurrCode = eventsCurrData.Name;
  1953. }
  1954. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1955. if (translateCurrData != null)
  1956. {
  1957. translateCurrName = translateCurrData.Remark;
  1958. translateCurrCode = translateCurrData.Name;
  1959. }
  1960. #endregion
  1961. _detail.PriceNameContent = _ioa.InviterArea;
  1962. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1963. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1964. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1965. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1966. $@"备注:" + _ioa.Remark + "<br/>";
  1967. }
  1968. break;
  1969. case 82: //团组客户保险
  1970. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1971. if (customers != null)
  1972. {
  1973. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1974. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1975. }
  1976. break;
  1977. case 85: //机票预订
  1978. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1979. if (jpRes != null)
  1980. {
  1981. string FlightsDescription = jpRes.FlightsDescription;
  1982. string PriceDescription = jpRes.PriceDescription;
  1983. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1984. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1985. }
  1986. break;
  1987. case 98://其他款项
  1988. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1989. if (gdpRes != null)
  1990. {
  1991. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1992. _detail.PriceNameContent = gdpRes.PriceName;
  1993. }
  1994. break;
  1995. case 285://收款退还
  1996. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1997. if (refundAndOtherMoney != null)
  1998. {
  1999. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2000. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2001. }
  2002. break;
  2003. case 751://酒店早餐
  2004. break;
  2005. case 1015://超支费用
  2006. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2007. if (groupExtraCost != null)
  2008. {
  2009. _detail.PriceNameContent = groupExtraCost.PriceName;
  2010. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2011. }
  2012. break;
  2013. default:
  2014. break;
  2015. }
  2016. /*
  2017. * 申请人
  2018. */
  2019. string operatorName = " - ";
  2020. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2021. if (_opUser != null)
  2022. {
  2023. operatorName = _opUser.CnName;
  2024. }
  2025. _detail.OperatorName = operatorName;
  2026. /*
  2027. * 审核人
  2028. */
  2029. string auditOperatorName = "Unknown";
  2030. if (entity.AuditGMOperate == 0)
  2031. auditOperatorName = " - ";
  2032. else if (entity.AuditGMOperate == 4)
  2033. auditOperatorName = "自动审核";
  2034. else
  2035. {
  2036. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2037. if (_adUser != null)
  2038. {
  2039. auditOperatorName = _adUser.CnName;
  2040. }
  2041. }
  2042. _detail.AuditOperatorName = auditOperatorName;
  2043. /*
  2044. * 超预算比例
  2045. */
  2046. string overBudgetStr = "";
  2047. if (entity.ExceedBudget == -1)
  2048. overBudgetStr = sdPriceName.Name + "尚无预算";
  2049. else if (entity.ExceedBudget == 0)
  2050. {
  2051. if (entity.CTable == 76 || entity.CTable == 79)
  2052. {
  2053. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2054. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2055. }
  2056. else
  2057. {
  2058. overBudgetStr = "未超预算";
  2059. }
  2060. }
  2061. else
  2062. overBudgetStr = entity.ExceedBudget.ToString("P");
  2063. _detail.OverBudget = overBudgetStr;
  2064. /*
  2065. * 已审核金额
  2066. */
  2067. decimal auditFee = 0.00M;
  2068. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  2069. /*
  2070. * 费用总计
  2071. */
  2072. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2073. {
  2074. CurrencyId = entity.PaymentCurrency,
  2075. CurrencyName = PaymentCurrency_WaitPay,
  2076. AmountPayable = entity.PayMoney,
  2077. ThisPayment = OriginalCurrPay,
  2078. BalancePayment = BalanceStr,
  2079. AuditedFunds = auditFee
  2080. });
  2081. _detail.IsAuditGM = entity.IsAuditGM;
  2082. detailList.Add(_detail);
  2083. }
  2084. #endregion
  2085. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2086. /*
  2087. * 下方描述处理
  2088. */
  2089. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2090. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2091. if (ccpCurrencyPrice != null)
  2092. {
  2093. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2094. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2095. }
  2096. else
  2097. {
  2098. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2099. }
  2100. string amountPayableStr = string.Format(@"应付款总金额: ");
  2101. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2102. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2103. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2104. foreach (var item in nonDuplicat)
  2105. {
  2106. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2107. if (strs.Count > 0)
  2108. {
  2109. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2110. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2111. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2112. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  2113. //单独处理此次付款金额
  2114. if (item.CurrencyId == 836) //人民币
  2115. {
  2116. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2117. }
  2118. else
  2119. {
  2120. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2121. }
  2122. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  2123. //单独处理已审核费用
  2124. if (item.CurrencyId == 836) //人民币
  2125. {
  2126. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2127. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  2128. }
  2129. else
  2130. {
  2131. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  2132. }
  2133. }
  2134. }
  2135. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2136. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2137. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2138. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  2139. var _view1 = new
  2140. {
  2141. PageFuncAuth = pageFunAuthView,
  2142. Data = _view
  2143. };
  2144. return Ok(JsonView(_view1));
  2145. }
  2146. catch (Exception ex)
  2147. {
  2148. return Ok(JsonView(false, ex.Message));
  2149. }
  2150. }
  2151. /// <summary>
  2152. /// 费用审核
  2153. /// 修改团组费用审核状态
  2154. /// </summary>
  2155. /// <param name="_dto">参数Json字符串</param>
  2156. /// <returns></returns>
  2157. [HttpPost]
  2158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2159. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2160. {
  2161. #region 参数验证
  2162. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2163. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2164. #endregion
  2165. #region 页面操作权限验证
  2166. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2167. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2168. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2169. #endregion
  2170. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2171. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2172. DateTime dtNow = DateTime.Now;
  2173. _groupRepository.BeginTran();
  2174. int rst = 0;
  2175. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2176. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2177. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2178. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2179. List<dynamic> msgDatas = new List<dynamic>();
  2180. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2181. foreach (var item in idList)
  2182. {
  2183. int CreditId = int.Parse(item);
  2184. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2185. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2186. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2187. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2188. .Where(s => s.Id == CreditId)
  2189. .ExecuteCommandAsync();
  2190. if (result < 1)
  2191. {
  2192. rst = -1;
  2193. _groupRepository.RollbackTran();
  2194. return Ok(JsonView(false, "操作失败并回滚!"));
  2195. }
  2196. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2197. if (creditData != null)
  2198. {
  2199. #region 应用通知配置
  2200. try
  2201. {
  2202. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2203. }
  2204. catch (Exception ex)
  2205. {
  2206. }
  2207. #endregion
  2208. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2209. string groupNameStr = string.Empty;
  2210. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2211. if (groupData != null) groupNameStr = groupData.TeamName;
  2212. string creditTypeStr = string.Empty;
  2213. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2214. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2215. string creditCurrency = string.Empty;
  2216. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2217. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2218. if (creditCurrency.Equals("CNY"))
  2219. {
  2220. creditData.DayRate = 1.0000M;
  2221. }
  2222. if (creditData.PayPercentage == 0.00M)
  2223. {
  2224. creditData.PayPercentage = 100M;
  2225. }
  2226. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2227. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2228. string msgContent = "";
  2229. if (creditCurrency.Equals("CNY"))
  2230. {
  2231. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2232. }
  2233. else
  2234. {
  2235. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2236. }
  2237. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2238. }
  2239. }
  2240. if (rst == 0)
  2241. {
  2242. _groupRepository.CommitTran();
  2243. foreach (var item in msgDatas)
  2244. {
  2245. //发送消息
  2246. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2247. }
  2248. #region 应用推送
  2249. try
  2250. {
  2251. foreach (var ccpId in dic_ccp_user.Keys)
  2252. {
  2253. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2254. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2255. }
  2256. }
  2257. catch (Exception)
  2258. {
  2259. }
  2260. #endregion
  2261. return Ok(JsonView(true, "操作成功!"));
  2262. }
  2263. return Ok(JsonView(false, "操作失败!"));
  2264. }
  2265. #endregion
  2266. #region 机票费用录入
  2267. /// <summary>
  2268. /// 机票录入当前登录人可操作团组
  2269. /// </summary>
  2270. /// <param name="dto"></param>
  2271. /// <returns></returns>
  2272. [HttpPost]
  2273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2274. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2275. {
  2276. try
  2277. {
  2278. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2279. if (groupData.Code != 0)
  2280. {
  2281. return Ok(JsonView(false, groupData.Msg));
  2282. }
  2283. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2284. }
  2285. catch (Exception ex)
  2286. {
  2287. return Ok(JsonView(false, "程序错误!"));
  2288. throw;
  2289. }
  2290. }
  2291. /// <summary>
  2292. /// 机票费用录入列表
  2293. /// </summary>
  2294. /// <param name="dto"></param>
  2295. /// <returns></returns>
  2296. [HttpPost]
  2297. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2298. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2299. {
  2300. try
  2301. {
  2302. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2303. if (groupData.Code != 0)
  2304. {
  2305. return Ok(JsonView(false, groupData.Msg));
  2306. }
  2307. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2308. }
  2309. catch (Exception ex)
  2310. {
  2311. return Ok(JsonView(false, ex.Message));
  2312. throw;
  2313. }
  2314. }
  2315. /// <summary>
  2316. /// 根据id查询费用录入信息
  2317. /// </summary>
  2318. /// <param name="dto"></param>
  2319. /// <returns></returns>
  2320. [HttpPost]
  2321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2322. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2323. {
  2324. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2325. if (groupData.Code != 0)
  2326. {
  2327. return Ok(JsonView(false, groupData.Msg));
  2328. }
  2329. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2330. }
  2331. /// <summary>
  2332. /// 机票费用录入操作(Status:1.新增,2.修改)
  2333. /// </summary>
  2334. /// <param name="dto"></param>
  2335. /// <returns></returns>
  2336. [HttpPost]
  2337. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2338. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2339. {
  2340. try
  2341. {
  2342. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2343. if (groupData.Code != 0)
  2344. {
  2345. return Ok(JsonView(false, groupData.Msg));
  2346. }
  2347. #region 应用推送
  2348. try
  2349. {
  2350. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2351. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2352. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2353. }
  2354. catch (Exception ex)
  2355. {
  2356. }
  2357. #endregion
  2358. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2359. }
  2360. catch (Exception ex)
  2361. {
  2362. return Ok(JsonView(false, "程序错误!"));
  2363. throw;
  2364. }
  2365. }
  2366. /// <summary>
  2367. /// 根据舱位类型查询接团客户名单信息
  2368. /// </summary>
  2369. /// <param name="dto"></param>
  2370. /// <returns></returns>
  2371. [HttpPost]
  2372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2373. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2374. {
  2375. try
  2376. {
  2377. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2378. if (crm_Groups.Count != 0)
  2379. {
  2380. List<dynamic> Customer = new List<dynamic>();
  2381. foreach (var item in crm_Groups)
  2382. {
  2383. var data = new
  2384. {
  2385. Id = item.Id,
  2386. Pinyin = item.Pinyin,
  2387. Name = item.LastName + item.FirstName
  2388. };
  2389. Customer.Add(data);
  2390. }
  2391. return Ok(JsonView(true, "查询成功!", Customer));
  2392. }
  2393. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2394. }
  2395. catch (Exception ex)
  2396. {
  2397. return Ok(JsonView(false, "程序错误!"));
  2398. throw;
  2399. }
  2400. }
  2401. /// <summary>
  2402. /// 根据团号获取客户信息
  2403. /// </summary>
  2404. /// <param name="dto"></param>
  2405. /// <returns></returns>
  2406. [HttpPost]
  2407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2408. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2409. {
  2410. var jw = JsonView(false);
  2411. if (dto.DIID < 1)
  2412. {
  2413. jw.Msg += "请输入正确的diid";
  2414. return Ok(jw);
  2415. }
  2416. var arr = getSimplClientList(dto.DIID);
  2417. jw = JsonView(true, "获取成功!", arr);
  2418. return Ok(jw);
  2419. }
  2420. private List<SimplClientInfo> getSimplClientList(int diId)
  2421. {
  2422. 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);
  2423. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2424. return arr;
  2425. }
  2426. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2427. {
  2428. string result = origin;
  2429. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2430. {
  2431. string[] temparr = origin.Split(',');
  2432. string fistrStr = temparr[0];
  2433. int count = temparr.Count();
  2434. int tempId;
  2435. bool success = int.TryParse(fistrStr, out tempId);
  2436. if (success)
  2437. {
  2438. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2439. if (tempInfo != null)
  2440. {
  2441. if (count > 1)
  2442. {
  2443. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2444. }
  2445. else
  2446. {
  2447. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2448. }
  2449. }
  2450. }
  2451. }
  2452. return result;
  2453. }
  2454. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2455. {
  2456. string result = origin;
  2457. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2458. {
  2459. string[] temparr = origin.Split(',');
  2460. result = "";
  2461. foreach (var item in temparr)
  2462. {
  2463. int tempId;
  2464. bool success = int.TryParse(item, out tempId);
  2465. if (success)
  2466. {
  2467. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2468. if (tempInfo != null)
  2469. {
  2470. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2471. }
  2472. }
  2473. }
  2474. }
  2475. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2476. return result;
  2477. }
  2478. /// <summary>
  2479. /// 机票费用录入,删除
  2480. /// </summary>
  2481. /// <param name="dto"></param>
  2482. /// <returns></returns>
  2483. [HttpPost]
  2484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2485. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2486. {
  2487. try
  2488. {
  2489. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2490. if (res)
  2491. {
  2492. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2493. {
  2494. IsDel = 1,
  2495. DeleteUserId = dto.DeleteUserId,
  2496. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2497. }).ExecuteCommandAsync();
  2498. return Ok(JsonView(true, "删除成功!"));
  2499. }
  2500. return Ok(JsonView(false, "删除失败!"));
  2501. }
  2502. catch (Exception ex)
  2503. {
  2504. return Ok(JsonView(false, "程序错误!"));
  2505. throw;
  2506. }
  2507. }
  2508. /// <summary>
  2509. /// 导出机票录入报表
  2510. /// </summary>
  2511. /// <param name="dto"></param>
  2512. /// <returns></returns>
  2513. [HttpPost]
  2514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2515. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2516. {
  2517. try
  2518. {
  2519. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2520. if (groupData.Code != 0)
  2521. {
  2522. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2523. }
  2524. else
  2525. {
  2526. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2527. if (AirTicketReservations.Count != 0)
  2528. {
  2529. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2530. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2531. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2532. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2533. WorkbookDesigner designer = new WorkbookDesigner();
  2534. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2535. decimal countCost = 0;
  2536. foreach (var item in AirTicketReservations)
  2537. {
  2538. #region 处理客人姓名
  2539. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2540. item.ClientName = clientNames;
  2541. #endregion
  2542. if (item.BankType == "其他")
  2543. {
  2544. item.BankNo = "--";
  2545. }
  2546. else
  2547. {
  2548. if (!string.IsNullOrEmpty(item.BankType))
  2549. {
  2550. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2551. }
  2552. }
  2553. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2554. item.Price = System.Decimal.Round(item.Price, 2);
  2555. countCost += Convert.ToDecimal(item.Price);
  2556. }
  2557. designer.SetDataSource("Export", AirTicketReservations);
  2558. designer.SetDataSource("ExportDiCode", diCode);
  2559. designer.SetDataSource("ExportDiName", diName);
  2560. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2561. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2562. designer.Process();
  2563. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2564. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2565. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2566. return Ok(JsonView(true, "成功", url = rst));
  2567. }
  2568. else
  2569. {
  2570. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2571. }
  2572. }
  2573. }
  2574. catch (Exception ex)
  2575. {
  2576. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2577. throw;
  2578. }
  2579. }
  2580. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2581. /// <summary>
  2582. /// 行程单导出
  2583. /// </summary>
  2584. /// <param name="dto"></param>
  2585. /// <returns></returns>
  2586. [HttpPost]
  2587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2588. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2589. {
  2590. try
  2591. {
  2592. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2593. if (groupData.Code != 0)
  2594. {
  2595. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2596. }
  2597. else
  2598. {
  2599. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2600. if (dto.Language == "CN")
  2601. {
  2602. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2603. DocumentBuilder builder = new DocumentBuilder(doc);
  2604. int tableIndex = 0;//表格索引
  2605. //得到文档中的第一个表格
  2606. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2607. foreach (var item in _AirTicketReservations)
  2608. {
  2609. #region 处理固定数据
  2610. string[] FlightsCode = item.FlightsCode.Split('/');
  2611. if (FlightsCode.Length != 0)
  2612. {
  2613. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2614. if (_AirCompany != null)
  2615. {
  2616. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2617. }
  2618. else
  2619. {
  2620. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2621. }
  2622. }
  2623. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2624. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2625. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2626. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2627. string name = "";
  2628. foreach (string clientName in nameArray)
  2629. {
  2630. if (!name.Contains(clientName))
  2631. {
  2632. name += clientName + ",";
  2633. }
  2634. }
  2635. if (!string.IsNullOrWhiteSpace(name))
  2636. {
  2637. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2638. }
  2639. else
  2640. {
  2641. table.Range.Bookmarks["ClientName"].Text = "--";
  2642. }
  2643. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2644. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2645. table.Range.Bookmarks["JointTicket"].Text = "--";
  2646. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2647. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2648. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2649. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2650. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2651. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2652. #endregion
  2653. #region 循环数据处理
  2654. List<AirInfo> airs = new List<AirInfo>();
  2655. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2656. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2657. for (int i = 0; i < FlightsCode.Length; i++)
  2658. {
  2659. AirInfo air = new AirInfo();
  2660. string[] tempstr = DayArray[i]
  2661. .Replace("\r\n", string.Empty)
  2662. .Replace("\\r\\n", string.Empty)
  2663. .TrimStart().TrimEnd()
  2664. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2665. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2666. string starCity = "";
  2667. if (star_Three != null)
  2668. {
  2669. starCity = star_Three.AirPort;
  2670. }
  2671. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2672. string EndCity = "";
  2673. if (End_Three != null)
  2674. {
  2675. EndCity = End_Three.AirPort;
  2676. }
  2677. air.Destination = starCity + "/" + EndCity;
  2678. air.Flight = FlightsCode[i];
  2679. air.SeatingClass = item.CTypeName;
  2680. string dateTime = tempstr[2];
  2681. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2682. air.FlightDate = DateTemp;
  2683. air.DepartureTime = tempstr[5];
  2684. air.LandingTime = tempstr[6];
  2685. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2686. air.TicketStatus = "--";
  2687. air.Luggage = "--";
  2688. air.DepartureTerminal = "--";
  2689. air.LandingTerminal = "--";
  2690. airs.Add(air);
  2691. }
  2692. int row = 13;
  2693. for (int i = 0; i < airs.Count; i++)
  2694. {
  2695. if (airs.Count > 2)
  2696. {
  2697. for (int j = 0; j < airs.Count - 2; j++)
  2698. {
  2699. var CopyRow = table.Rows[12].Clone(true);
  2700. table.Rows.Add(CopyRow);
  2701. }
  2702. }
  2703. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2704. int index = 0;
  2705. foreach (PropertyInfo property in properties)
  2706. {
  2707. string value = property.GetValue(airs[i]).ToString();
  2708. Cell ishcel0 = table.Rows[row].Cells[index];
  2709. Paragraph p = new Paragraph(doc);
  2710. string s = value;
  2711. p.AppendChild(new Run(doc, s));
  2712. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2713. ishcel0.AppendChild(p);
  2714. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2715. index++;
  2716. }
  2717. row++;
  2718. }
  2719. #endregion
  2720. Paragraph lastParagraph = new Paragraph(doc);
  2721. //第一个表格末尾加段落
  2722. table.ParentNode.InsertAfter(lastParagraph, table);
  2723. //复制第一个表格
  2724. Table cloneTable = (Table)table.Clone(true);
  2725. //在文档末尾段落后面加入复制的表格
  2726. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2727. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2728. {
  2729. int rownewsIndex = 13;
  2730. for (int i = 0; i < 2; i++)
  2731. {
  2732. var CopyRow = table.Rows[12].Clone(true);
  2733. table.Rows.RemoveAt(13);
  2734. table.Rows.Add(CopyRow);
  2735. rownewsIndex++;
  2736. }
  2737. }
  2738. else
  2739. {
  2740. table.Rows.RemoveAt(12);
  2741. }
  2742. cloneTable.Rows.RemoveAt(12);
  2743. }
  2744. if (_AirTicketReservations.Count != 0)
  2745. {
  2746. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2747. if (FlightsCode.Length != 0)
  2748. {
  2749. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2750. if (_AirCompany != null)
  2751. {
  2752. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2753. }
  2754. else
  2755. {
  2756. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2757. }
  2758. }
  2759. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2760. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2761. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2762. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2763. string name = "";
  2764. foreach (string clientName in nameArray)
  2765. {
  2766. if (!name.Contains(clientName))
  2767. {
  2768. name += clientName + ",";
  2769. }
  2770. }
  2771. if (!string.IsNullOrWhiteSpace(name))
  2772. {
  2773. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2774. }
  2775. else
  2776. {
  2777. table.Range.Bookmarks["ClientName"].Text = "--";
  2778. }
  2779. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2780. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2781. table.Range.Bookmarks["JointTicket"].Text = "--";
  2782. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2783. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2784. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2785. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2786. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2787. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2788. }
  2789. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2790. //保存合并后的文档
  2791. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2792. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2793. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2794. return Ok(JsonView(true, "成功!", rst));
  2795. }
  2796. else
  2797. {
  2798. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2799. DocumentBuilder builder = new DocumentBuilder(doc);
  2800. int tableIndex = 0;//表格索引
  2801. //得到文档中的第一个表格
  2802. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2803. List<string> texts = new List<string>();
  2804. foreach (var item in _AirTicketReservations)
  2805. {
  2806. string[] FlightsCode = item.FlightsCode.Split('/');
  2807. if (FlightsCode.Length != 0)
  2808. {
  2809. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2810. if (_AirCompany != null)
  2811. {
  2812. if (!transDic.ContainsKey(_AirCompany.CnName))
  2813. {
  2814. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2815. }
  2816. }
  2817. else
  2818. {
  2819. if (!transDic.ContainsKey("--"))
  2820. {
  2821. transDic.Add("--", "--");
  2822. }
  2823. }
  2824. }
  2825. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2826. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2827. string name = "";
  2828. foreach (string clientName in nameArray)
  2829. {
  2830. name += clientName + ",";
  2831. }
  2832. if (!texts.Contains(name))
  2833. {
  2834. texts.Add(name);
  2835. }
  2836. List<AirInfo> airs = new List<AirInfo>();
  2837. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2838. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2839. for (int i = 0; i < FlightsCode.Length; i++)
  2840. {
  2841. AirInfo air = new AirInfo();
  2842. string[] tempstr = DayArray[i]
  2843. .Replace("\r\n", string.Empty)
  2844. .Replace("\\r\\n", string.Empty)
  2845. .TrimStart().TrimEnd()
  2846. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2847. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2848. if (star_Three != null)
  2849. {
  2850. if (!transDic.ContainsKey(star_Three.AirPort))
  2851. {
  2852. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2853. }
  2854. }
  2855. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2856. if (End_Three != null)
  2857. {
  2858. if (!transDic.ContainsKey(End_Three.AirPort))
  2859. {
  2860. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2861. }
  2862. }
  2863. if (!texts.Contains(item.CTypeName))
  2864. {
  2865. texts.Add(item.CTypeName);
  2866. }
  2867. }
  2868. }
  2869. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2870. if (transData.Count > 0)
  2871. {
  2872. foreach (TranslateResult item in transData)
  2873. {
  2874. if (!transDic.ContainsKey(item.Query))
  2875. {
  2876. transDic.Add(item.Query, item.Translation);
  2877. }
  2878. }
  2879. }
  2880. foreach (var item in _AirTicketReservations)
  2881. {
  2882. #region 处理固定数据
  2883. string[] FlightsCode = item.FlightsCode.Split('/');
  2884. if (FlightsCode.Length != 0)
  2885. {
  2886. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2887. if (_AirCompany != null)
  2888. {
  2889. string str = "--";
  2890. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2891. if (!string.IsNullOrEmpty(translateResult))
  2892. {
  2893. str = translateResult;
  2894. str = _airTicketResRep.Processing(str);
  2895. }
  2896. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2897. }
  2898. else
  2899. {
  2900. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2901. }
  2902. }
  2903. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2904. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2905. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2906. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2907. string names = "";
  2908. foreach (string clientName in nameArray)
  2909. {
  2910. names += clientName + ",";
  2911. }
  2912. if (!string.IsNullOrWhiteSpace(names))
  2913. {
  2914. string str = "--";
  2915. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2916. if (!string.IsNullOrEmpty(translateResult))
  2917. {
  2918. str = translateResult;
  2919. str = _airTicketResRep.Processing(str);
  2920. }
  2921. table.Range.Bookmarks["ClientName"].Text = str;
  2922. }
  2923. else
  2924. {
  2925. table.Range.Bookmarks["ClientName"].Text = "--";
  2926. }
  2927. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2928. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2929. table.Range.Bookmarks["JointTicket"].Text = "--";
  2930. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2931. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2932. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2933. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2934. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2935. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2936. #endregion
  2937. #region 循环数据处理
  2938. List<AirInfo> airs = new List<AirInfo>();
  2939. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2940. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2941. for (int i = 0; i < FlightsCode.Length; i++)
  2942. {
  2943. AirInfo air = new AirInfo();
  2944. string[] tempstr = DayArray[i]
  2945. .Replace("\r\n", string.Empty)
  2946. .Replace("\\r\\n", string.Empty)
  2947. .TrimStart().TrimEnd()
  2948. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2949. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2950. string starCity = "";
  2951. if (star_Three != null)
  2952. {
  2953. string str2 = "--";
  2954. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2955. if (!string.IsNullOrEmpty(translateResult2))
  2956. {
  2957. str2 = translateResult2;
  2958. str2 = _airTicketResRep.Processing(str2);
  2959. }
  2960. starCity = str2;
  2961. }
  2962. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2963. string EndCity = "";
  2964. if (End_Three != null)
  2965. {
  2966. string str1 = "--";
  2967. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2968. if (!string.IsNullOrEmpty(translateResult1))
  2969. {
  2970. str1 = translateResult1;
  2971. str1 = _airTicketResRep.Processing(str1);
  2972. }
  2973. EndCity = str1;
  2974. }
  2975. air.Destination = starCity + "/" + EndCity;
  2976. air.Flight = FlightsCode[i];
  2977. string str = "--";
  2978. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2979. if (!string.IsNullOrEmpty(translateResult))
  2980. {
  2981. str = translateResult;
  2982. str = _airTicketResRep.Processing(str);
  2983. }
  2984. air.SeatingClass = str;
  2985. string dateTime = tempstr[2];
  2986. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2987. air.FlightDate = DateTemp;
  2988. air.DepartureTime = tempstr[5];
  2989. air.LandingTime = tempstr[6];
  2990. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2991. air.TicketStatus = "--";
  2992. air.Luggage = "--";
  2993. air.DepartureTerminal = "--";
  2994. air.LandingTerminal = "--";
  2995. airs.Add(air);
  2996. }
  2997. int row = 13;
  2998. for (int i = 0; i < airs.Count; i++)
  2999. {
  3000. if (airs.Count > 2)
  3001. {
  3002. for (int j = 0; j < airs.Count - 2; j++)
  3003. {
  3004. var CopyRow = table.Rows[12].Clone(true);
  3005. table.Rows.Add(CopyRow);
  3006. }
  3007. }
  3008. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3009. int index = 0;
  3010. foreach (PropertyInfo property in properties)
  3011. {
  3012. string value = property.GetValue(airs[i]).ToString();
  3013. Cell ishcel0 = table.Rows[row].Cells[index];
  3014. Paragraph p = new Paragraph(doc);
  3015. string s = value;
  3016. p.AppendChild(new Run(doc, s));
  3017. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3018. ishcel0.AppendChild(p);
  3019. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3020. //ishcel0.CellFormat.VerticalAlignment=
  3021. index++;
  3022. }
  3023. row++;
  3024. }
  3025. #endregion
  3026. Paragraph lastParagraph = new Paragraph(doc);
  3027. //第一个表格末尾加段落
  3028. table.ParentNode.InsertAfter(lastParagraph, table);
  3029. //复制第一个表格
  3030. Table cloneTable = (Table)table.Clone(true);
  3031. //在文档末尾段落后面加入复制的表格
  3032. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3033. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3034. {
  3035. int rownewsIndex = 13;
  3036. for (int i = 0; i < 2; i++)
  3037. {
  3038. var CopyRow = table.Rows[12].Clone(true);
  3039. table.Rows.RemoveAt(13);
  3040. table.Rows.Add(CopyRow);
  3041. rownewsIndex++;
  3042. }
  3043. }
  3044. else
  3045. {
  3046. table.Rows.RemoveAt(12);
  3047. }
  3048. cloneTable.Rows.RemoveAt(12);
  3049. }
  3050. if (_AirTicketReservations.Count != 0)
  3051. {
  3052. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3053. if (FlightsCode.Length != 0)
  3054. {
  3055. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3056. if (_AirCompany != null)
  3057. {
  3058. string str = "--";
  3059. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3060. if (!string.IsNullOrEmpty(translateResult))
  3061. {
  3062. str = translateResult;
  3063. str = _airTicketResRep.Processing(str);
  3064. }
  3065. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3066. }
  3067. else
  3068. {
  3069. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3070. }
  3071. }
  3072. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3073. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3074. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3075. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3076. string names = "";
  3077. foreach (string clientName in nameArray)
  3078. {
  3079. names += clientName + ",";
  3080. }
  3081. if (!string.IsNullOrWhiteSpace(names))
  3082. {
  3083. string str = "--";
  3084. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3085. if (!string.IsNullOrEmpty(translateResult))
  3086. {
  3087. str = translateResult;
  3088. str = _airTicketResRep.Processing(str);
  3089. }
  3090. table.Range.Bookmarks["ClientName"].Text = str;
  3091. }
  3092. else
  3093. {
  3094. table.Range.Bookmarks["ClientName"].Text = "--";
  3095. }
  3096. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3097. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3098. table.Range.Bookmarks["JointTicket"].Text = "--";
  3099. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3100. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3101. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3102. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3103. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3104. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3105. }
  3106. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3107. //保存合并后的文档
  3108. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3109. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3110. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3111. return Ok(JsonView(true, "成功!", rst));
  3112. }
  3113. }
  3114. }
  3115. catch (Exception ex)
  3116. {
  3117. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3118. throw;
  3119. }
  3120. }
  3121. #endregion
  3122. #region 团组增减款项 --> 其他款项
  3123. /// <summary>
  3124. /// 团组增减款项下拉框绑定
  3125. /// </summary>
  3126. /// <param name="dto"></param>
  3127. /// <returns></returns>
  3128. [HttpPost]
  3129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3130. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3131. {
  3132. #region 参数验证
  3133. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3134. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3135. #endregion
  3136. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3137. }
  3138. /// <summary>
  3139. /// 根据团组Id查询团组增减款项
  3140. /// </summary>
  3141. /// <param name="dto"></param>
  3142. /// <returns></returns>
  3143. [HttpPost]
  3144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3145. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3146. {
  3147. #region 参数验证
  3148. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3149. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3150. #endregion
  3151. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3152. }
  3153. /// <summary>
  3154. /// 团组增减款项操作(Status:1.新增,2.修改)
  3155. /// </summary>
  3156. /// <param name="dto"></param>
  3157. /// <returns></returns>
  3158. [HttpPost]
  3159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3160. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3161. {
  3162. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3163. if (groupData.Code != 200)
  3164. {
  3165. return Ok(JsonView(false, groupData.Msg));
  3166. }
  3167. #region 应用推送
  3168. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3169. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3170. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3171. #endregion
  3172. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3173. }
  3174. /// <summary>
  3175. /// 团组增减款项操作 删除
  3176. /// </summary>
  3177. /// <param name="dto"></param>
  3178. /// <returns></returns>
  3179. [HttpPost]
  3180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3181. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3182. {
  3183. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3184. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3185. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3186. if (res.Code == 0)
  3187. {
  3188. return Ok(JsonView(true, "删除成功!"));
  3189. }
  3190. return Ok(JsonView(false, "删除失败!"));
  3191. }
  3192. /// <summary>
  3193. /// 根据团组增减款项Id查询
  3194. /// </summary>
  3195. /// <param name="dto"></param>
  3196. /// <returns></returns>
  3197. [HttpPost]
  3198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3199. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3200. {
  3201. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3202. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3203. }
  3204. /// <summary>
  3205. /// 查询供应商名称
  3206. /// </summary>
  3207. /// <param name="dto"></param>
  3208. /// <returns></returns>
  3209. [HttpPost]
  3210. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3211. {
  3212. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3213. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3214. ?? new List<Grp_DecreasePayments>();
  3215. dbResult = dbResult.Distinct(new
  3216. ProductComparer()).ToList();
  3217. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3218. {
  3219. x.Id,
  3220. x.SupplierAddress,
  3221. x.SupplierArea,
  3222. x.SupplierContact,
  3223. x.SupplierContactNumber,
  3224. x.SupplierEmail,
  3225. x.SupplierName,
  3226. x.SupplierSocialAccount,
  3227. x.SupplierTypeId,
  3228. }).ToList());
  3229. return Ok(jw);
  3230. }
  3231. /// <summary>
  3232. /// 团组增减款项 OTA匹配
  3233. /// </summary>
  3234. /// <param name="file"></param>
  3235. /// <returns></returns>
  3236. [HttpPost]
  3237. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3238. {
  3239. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3240. string fileName = file.FileName;
  3241. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3242. {
  3243. return Ok(JsonView(false, "请上传Excel文件!"));
  3244. }
  3245. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3246. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3247. if (!Directory.Exists(path))
  3248. {
  3249. Directory.CreateDirectory(path);
  3250. }
  3251. var filePath = @$"{path}/{fileName}";
  3252. //保存文件
  3253. using (FileStream fs = System.IO.File.Create(filePath))
  3254. {
  3255. file.CopyTo(fs);
  3256. fs.Flush();
  3257. }
  3258. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3259. //读取ExcelFile
  3260. DataTable dt = ExcelToDataTable(filePath);
  3261. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3262. dt.TableName = "TB";
  3263. //修改table列名
  3264. dt.Columns[0].ColumnName = "OTAOrderNo"; // OTA订单号
  3265. dt.Columns[1].ColumnName = "PackageName"; // 套餐名
  3266. dt.Columns[2].ColumnName = "IsPay"; // 是否支付
  3267. dt.Columns[3].ColumnName = "IsShipments"; // 是否发货
  3268. dt.Columns[4].ColumnName = "IsSendBack"; // 是否寄回
  3269. dt.Columns[5].ColumnName = "OrderTime"; // 下单时间
  3270. dt.Columns[6].ColumnName = "UseTime"; // 使用时间
  3271. dt.Columns[7].ColumnName = "Quantity"; // 台数
  3272. dt.Columns[8].ColumnName = "Days"; // 租赁天数
  3273. dt.Columns[9].ColumnName = "QuantityShipped";// 发货数量
  3274. dt.Columns[9].ColumnName = "TotalPrice"; // 总金额
  3275. dt.Columns[9].ColumnName = "GroupName"; // 团组名称
  3276. dt.Columns[9].ColumnName = "OATotalPrice"; // OA金额
  3277. var otaOrderNos = new List<string>();
  3278. foreach (DataRow item in dt.Rows)
  3279. {
  3280. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3281. }
  3282. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3283. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3284. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3285. .Select((dp, di) => new
  3286. {
  3287. dp.PriceName,
  3288. dp.OTAOrderNo,
  3289. dp.FeeTotal,
  3290. di.TeamName,
  3291. })
  3292. .ToListAsync();
  3293. foreach (DataRow item in dt.Rows)
  3294. {
  3295. var otaOrderNo = item["OTAOrderNo"].ToString();
  3296. var oaData = oaDatas.Find(x => x.OTAOrderNo.Contains(otaOrderNo));
  3297. if (oaData == null) continue;
  3298. item["GroupName"] = oaData.TeamName;
  3299. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3300. }
  3301. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3302. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3303. List<DataTable> datas = new List<DataTable>();
  3304. datas.Add(dt);
  3305. url = AsposeHelper.ExpertExcelToModel("信用卡对账模板-美元卡.xls", $"CreditCardBill", fileName1, pairs, datas);
  3306. return Ok(JsonView(true));
  3307. }
  3308. #region
  3309. private DataTable ExcelToDataTable(string filePath)
  3310. {
  3311. DataTable dataTable = new DataTable();
  3312. using (var package = new ExcelPackage(new FileInfo(filePath)))
  3313. {
  3314. ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
  3315. ExcelWorksheet worksheet = package.Workbook.Worksheets.First();
  3316. int rowCount = worksheet.Dimension.Rows;
  3317. int colCount = worksheet.Dimension.Columns;
  3318. // 获取标题
  3319. for (int col = 1; col <= colCount; col++)
  3320. {
  3321. dataTable.Columns.Add(worksheet.Cells[1, col].Value.ToString());
  3322. }
  3323. // 获取数据
  3324. for (int row = 2; row <= rowCount; row++)
  3325. {
  3326. DataRow dataRow = dataTable.NewRow();
  3327. for (int col = 1; col <= colCount; col++)
  3328. {
  3329. dataRow[col - 1] = worksheet.Cells[row, col].Value;
  3330. }
  3331. dataTable.Rows.Add(dataRow);
  3332. }
  3333. }
  3334. return dataTable;
  3335. }
  3336. #endregion
  3337. #endregion
  3338. #region 文件上传、删除
  3339. /// <summary>
  3340. /// region 文件上传 可以带参数
  3341. /// </summary>
  3342. /// <param name="file"></param>
  3343. /// <returns></returns>
  3344. [HttpPost]
  3345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3346. public async Task<IActionResult> UploadProject(IFormFile file)
  3347. {
  3348. //var TypeName = Request.Headers["TypeName"].ToString();
  3349. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3350. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3351. ////文件名称
  3352. //string projectFileName = file.FileName;
  3353. ////上传的文件的路径
  3354. //string filePath = $"{fileDir}/{projectFileName}";
  3355. //if (TypeName == "A")//A代表团组增减款项
  3356. //{
  3357. // filePath = fileDir + $@"\团组增减款项相关文件";
  3358. // if (!Directory.Exists(filePath))
  3359. // {
  3360. // Directory.CreateDirectory(filePath);
  3361. // }
  3362. // //上传的文件的路径
  3363. // filePath += $@"\{projectFileName}";
  3364. //}
  3365. //else if (TypeName == "B")//B代表商邀相关文件
  3366. //{
  3367. // //上传的文件的路径
  3368. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3369. // if (!Directory.Exists(filePath))
  3370. // {
  3371. // Directory.CreateDirectory(filePath);
  3372. // }
  3373. // //上传的文件的路径
  3374. // filePath = $@"\{projectFileName}";
  3375. //}
  3376. //try
  3377. //{
  3378. // using (FileStream fs = System.IO.File.Create(filePath))
  3379. // {
  3380. // file.CopyTo(fs);
  3381. // fs.Flush();
  3382. // }
  3383. //}
  3384. //catch (Exception ex)
  3385. //{
  3386. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3387. //}
  3388. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3389. try
  3390. {
  3391. var TypeName = Request.Headers["TypeName"].ToString();
  3392. if (file != null)
  3393. {
  3394. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3395. //文件名称
  3396. string projectFileName = file.FileName;
  3397. //上传的文件的路径
  3398. string filePath = $"{fileDir}/{projectFileName}";
  3399. if (TypeName == "A")//A代表团组增减款项
  3400. {
  3401. if (!Directory.Exists(fileDir))
  3402. {
  3403. Directory.CreateDirectory(fileDir);
  3404. }
  3405. //上传的文件的路径
  3406. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3407. }
  3408. else if (TypeName == "B")//B代表商邀相关文件
  3409. {
  3410. if (!Directory.Exists(fileDir))
  3411. {
  3412. Directory.CreateDirectory(fileDir);
  3413. }
  3414. //上传的文件的路径
  3415. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3416. }
  3417. using (FileStream fs = System.IO.File.Create(filePath))
  3418. {
  3419. file.CopyTo(fs);
  3420. fs.Flush();
  3421. }
  3422. return Ok(JsonView(true, "上传成功!", projectFileName));
  3423. }
  3424. else
  3425. {
  3426. return Ok(JsonView(false, "上传失败!"));
  3427. }
  3428. }
  3429. catch (Exception ex)
  3430. {
  3431. return Ok(JsonView(false, "程序错误!"));
  3432. }
  3433. }
  3434. /// <summary>
  3435. /// 删除指定文件
  3436. /// </summary>
  3437. /// <param name="dto"></param>
  3438. /// <returns></returns>
  3439. [HttpPost]
  3440. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3441. public async Task<IActionResult> DelFile(DelFileDto dto)
  3442. {
  3443. try
  3444. {
  3445. var TypeName = Request.Headers["TypeName"].ToString();
  3446. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3447. string filePath = "";
  3448. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3449. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3450. int id = 0;
  3451. if (TypeName == "A")
  3452. {
  3453. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3454. // 删除该文件
  3455. System.IO.File.Delete(filePath);
  3456. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3457. .Where(a => a.Id == dto.Id)
  3458. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3459. .ExecuteCommandAsync();
  3460. }
  3461. else if (TypeName == "B")
  3462. {
  3463. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3464. // 删除该文件
  3465. System.IO.File.Delete(filePath);
  3466. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3467. if (info != null)
  3468. {
  3469. string[] files = new string[] { };
  3470. if (!string.IsNullOrEmpty(info.Attachment))
  3471. {
  3472. try
  3473. {
  3474. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3475. }
  3476. catch (Exception)
  3477. {
  3478. files = new List<string>() { info.Attachment }.ToArray();
  3479. }
  3480. }
  3481. if (files.Length > 0)
  3482. {
  3483. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3484. string filePath2 = string.Empty;
  3485. if (files1.Length > 0)
  3486. {
  3487. filePath2 = JsonConvert.SerializeObject( files1);
  3488. }
  3489. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3490. .Where(a => a.Id == dto.Id)
  3491. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3492. .ExecuteCommandAsync();
  3493. }
  3494. }
  3495. }
  3496. if (id != 0)
  3497. {
  3498. return Ok(JsonView(true, "成功!"));
  3499. }
  3500. else
  3501. {
  3502. return Ok(JsonView(false, "失败!"));
  3503. }
  3504. }
  3505. catch (Exception ex)
  3506. {
  3507. return Ok(JsonView(false, "程序错误!"));
  3508. throw;
  3509. }
  3510. }
  3511. /// <summary>
  3512. /// 文件上传多个文件 可以带参数
  3513. /// </summary>
  3514. /// <param name="file"></param>
  3515. /// <returns></returns>
  3516. [HttpPost]
  3517. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3518. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3519. {
  3520. try
  3521. {
  3522. var TypeName = Request.Headers["TypeName"].ToString();
  3523. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3524. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3525. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3526. var filePahts = new List<string>();
  3527. foreach (var file in files)
  3528. {
  3529. //文件名称
  3530. string projectFileName = file.FileName;
  3531. //上传的文件的路径
  3532. string filePath = $"{fileDir}/{projectFileName}";
  3533. if (TypeName == "A")//A代表团组增减款项
  3534. {
  3535. if (!Directory.Exists(fileDir))
  3536. {
  3537. Directory.CreateDirectory(fileDir);
  3538. }
  3539. //上传的文件的路径
  3540. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3541. }
  3542. else if (TypeName == "B")//B代表商邀相关文件
  3543. {
  3544. if (!Directory.Exists(fileDir))
  3545. {
  3546. Directory.CreateDirectory(fileDir);
  3547. }
  3548. //上传的文件的路径
  3549. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3550. }
  3551. using (FileStream fs = System.IO.File.Create(filePath))
  3552. {
  3553. file.CopyTo(fs);
  3554. fs.Flush();
  3555. }
  3556. filePahts.Add(projectFileName);
  3557. }
  3558. return Ok(JsonView(true, "上传成功!", filePahts));
  3559. }
  3560. catch (Exception ex)
  3561. {
  3562. return Ok(JsonView(false, "程序错误!"));
  3563. }
  3564. }
  3565. #endregion
  3566. #region 商邀费用录入
  3567. /// <summary>
  3568. /// 根据团组Id查询商邀费用列表
  3569. /// </summary>
  3570. /// <param name="dto"></param>
  3571. /// <returns></returns>
  3572. [HttpPost]
  3573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3574. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3575. {
  3576. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3577. if (groupData.Code != 0)
  3578. {
  3579. return Ok(JsonView(false, groupData.Msg));
  3580. }
  3581. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3582. }
  3583. /// <summary>
  3584. /// 商邀费用列表
  3585. /// 下载文件
  3586. /// </summary>
  3587. /// <param name="dto"></param>
  3588. /// <returns></returns>
  3589. [HttpGet("{id}")]
  3590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3591. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3592. {
  3593. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3594. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3595. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3596. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3597. var filePaths = new List<string>();
  3598. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3599. try
  3600. {
  3601. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3602. }
  3603. catch (Exception ex)
  3604. {
  3605. filePaths.Add(info.Attachment);
  3606. }
  3607. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3608. for (int i = 0; i < filePaths.Count; i++)
  3609. {
  3610. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3611. }
  3612. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3613. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3614. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3615. {
  3616. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3617. {
  3618. foreach (string filePath in filePaths)
  3619. {
  3620. if (System.IO.File.Exists(filePath))
  3621. {
  3622. // 获取文件名
  3623. string fileName = Path.GetFileName(filePath);
  3624. // 将文件添加到ZIP归档中
  3625. zipArchive.CreateEntryFromFile(filePath, fileName);
  3626. }
  3627. }
  3628. }
  3629. }
  3630. return Ok(JsonView(new {url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3631. }
  3632. /// <summary>
  3633. /// 商邀费用 Info Page 基础数据源
  3634. /// </summary>
  3635. /// <param name="dto"></param>
  3636. /// <returns></returns>
  3637. [HttpPost]
  3638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3639. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3640. {
  3641. try
  3642. {
  3643. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3644. if (groupData.Code != 0)
  3645. {
  3646. return Ok(JsonView(false, groupData.Msg));
  3647. }
  3648. return Ok(JsonView(true, "操作成功", groupData.Data));
  3649. }
  3650. catch (Exception ex)
  3651. {
  3652. return Ok(JsonView(false, ex.Message));
  3653. throw;
  3654. }
  3655. }
  3656. /// <summary>
  3657. /// 根据商邀费用ID查询C表和商邀费用数据
  3658. /// </summary>
  3659. /// <param name="dto"></param>
  3660. /// <returns></returns>
  3661. [HttpPost]
  3662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3663. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3664. {
  3665. try
  3666. {
  3667. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3668. if (groupData.Code != 0)
  3669. {
  3670. return Ok(JsonView(false, groupData.Msg));
  3671. }
  3672. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3673. }
  3674. catch (Exception ex)
  3675. {
  3676. return Ok(JsonView(false, ex.Message));
  3677. throw;
  3678. }
  3679. }
  3680. /// <summary>
  3681. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3682. /// </summary>
  3683. /// <param name="dto"></param>
  3684. /// <returns></returns>
  3685. [HttpPost]
  3686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3687. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3688. {
  3689. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3690. if (groupData.Code != 0)
  3691. {
  3692. return Ok(JsonView(false, groupData.Msg));
  3693. }
  3694. #region 应用推送
  3695. try
  3696. {
  3697. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3698. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3699. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3700. }
  3701. catch (Exception ex)
  3702. {
  3703. }
  3704. #endregion
  3705. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3706. }
  3707. /// <summary>
  3708. /// 商邀删除
  3709. /// </summary>
  3710. /// <param name="dto"></param>
  3711. /// <returns></returns>
  3712. [HttpPost]
  3713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3714. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3715. {
  3716. try
  3717. {
  3718. _sqlSugar.BeginTran();
  3719. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3720. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3721. {
  3722. IsDel = 1,
  3723. DeleteUserId = dto.DeleteUserId,
  3724. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3725. })
  3726. .Where(it => it.Id == dto.Id)
  3727. .ExecuteCommand();
  3728. if (res1 > 0)
  3729. {
  3730. int _diId = 0;
  3731. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3732. if (_ioaInfo != null)
  3733. {
  3734. _diId = _ioaInfo.DiId;
  3735. }
  3736. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3737. .SetColumns(a => new Grp_CreditCardPayment()
  3738. {
  3739. IsDel = 1,
  3740. DeleteUserId = dto.DeleteUserId,
  3741. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3742. })
  3743. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3744. .ExecuteCommand();
  3745. if (res2 > 0)
  3746. {
  3747. _sqlSugar.CommitTran();
  3748. return Ok(JsonView(true, "删除成功!"));
  3749. }
  3750. }
  3751. _sqlSugar.RollbackTran();
  3752. return Ok(JsonView(false, "删除失败"));
  3753. }
  3754. catch (Exception ex)
  3755. {
  3756. _sqlSugar.RollbackTran();
  3757. return Ok(JsonView(false, ex.Message));
  3758. }
  3759. }
  3760. /// <summary>
  3761. /// 团组模块文件上传
  3762. /// </summary>
  3763. /// <param name="dto"></param>
  3764. /// <returns></returns>
  3765. [HttpPost]
  3766. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3767. {
  3768. var jw = JsonView(false);
  3769. long M = 1024 * 1024;
  3770. if (dto.Files == null || dto.Files.Count == 0)
  3771. {
  3772. jw.Msg = "无文件信息!";
  3773. return Ok(jw);
  3774. }
  3775. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3776. {
  3777. jw.Msg = "文件大小超过20M!";
  3778. return Ok(jw);
  3779. }
  3780. //var nameSp = dto.File.FileName.Split(".");
  3781. //if (nameSp.Length < 2)
  3782. //{
  3783. // jw.Msg = "拓展名称有误!";
  3784. // return Ok(jw);
  3785. //}
  3786. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3787. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3788. //{
  3789. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3790. // return Ok(jw);
  3791. //}
  3792. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3793. if (Ctable == null)
  3794. {
  3795. jw.Msg = "Ctable指向有误!";
  3796. return Ok(jw);
  3797. }
  3798. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3799. if (groupInfo == null)
  3800. {
  3801. jw.Msg = "团组信息不存在!";
  3802. return Ok(jw);
  3803. }
  3804. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3805. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3806. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3807. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3808. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3809. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3810. try
  3811. {
  3812. if (!Directory.Exists(fileBase))
  3813. {
  3814. Directory.CreateDirectory(fileBase);
  3815. }
  3816. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3817. foreach (var fileStream in dto.Files)
  3818. {
  3819. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3820. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3821. {
  3822. Cid = dto.Cid,
  3823. CreateTime = DateTime.Now,
  3824. CreateUserId = dto.Userid,
  3825. Ctable = dto.Ctable,
  3826. Diid = dto.Diid,
  3827. IsDel = 0,
  3828. FilePath = saveFilePath,
  3829. FileName = fileStream.FileName
  3830. };
  3831. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3832. {
  3833. fileStream.CopyTo(fs);
  3834. fs.Flush();
  3835. }
  3836. saveArr.Add(file);
  3837. }
  3838. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3839. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3840. jw = JsonView(true, "保存成功!", new
  3841. {
  3842. count = addResult,
  3843. filesName = saveArr.Select(x => x.FileName)
  3844. });
  3845. }
  3846. catch (Exception ex)
  3847. {
  3848. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3849. {
  3850. count = 0,
  3851. filesName = new string[0],
  3852. });
  3853. }
  3854. return Ok(jw);
  3855. }
  3856. /// <summary>
  3857. /// 查询各模块已保存文件
  3858. /// </summary>
  3859. /// <param name="dto"></param>
  3860. /// <returns></returns>
  3861. [HttpPost]
  3862. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3863. {
  3864. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3865. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3866. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3867. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3868. {
  3869. expression = Expressionable.Create<Grp_GroupModelFile>()
  3870. .And(x => visaIds.Contains(x.CreateUserId));
  3871. }
  3872. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3873. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3874. .Where(expression.ToExpression())
  3875. .ToList();
  3876. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3877. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3878. {
  3879. x.FileName,
  3880. x.Id,
  3881. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3882. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3883. })));
  3884. }
  3885. /// <summary>
  3886. /// 下载该团组下的所有文件
  3887. /// </summary>
  3888. /// <param name="dto"></param>
  3889. /// <returns></returns>
  3890. [HttpPost]
  3891. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3892. {
  3893. var jw = JsonView(false);
  3894. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3895. if (groupInfo == null)
  3896. {
  3897. jw.Msg = "团组信息不存在!";
  3898. return Ok(jw);
  3899. }
  3900. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3901. var isModule = Convert.ToBoolean(dto.isModule);
  3902. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3903. IOOperatorHelper io = new IOOperatorHelper();
  3904. if (isModule)
  3905. {
  3906. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3907. foreach (var moduleArr in moduleGroup)
  3908. {
  3909. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3910. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3911. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3912. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3913. foreach (var item in moduleArr)
  3914. {
  3915. if (System.IO.File.Exists(item.FilePath))
  3916. {
  3917. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3918. {
  3919. byte[] bytes = new byte[fileStream.Length];
  3920. fileStream.Read(bytes, 0, bytes.Length);
  3921. fileStream.Close();
  3922. Stream stream = new MemoryStream(bytes);
  3923. chiZips.Add(item.FileName, stream);
  3924. }
  3925. }
  3926. }
  3927. if (chiZips.Count > 0)
  3928. {
  3929. var byts = io.ConvertZipStream(chiZips);
  3930. Stream stream = new MemoryStream(byts);
  3931. Zips.Add(key.Name + "_.zip", stream);
  3932. }
  3933. }
  3934. }
  3935. else
  3936. {
  3937. foreach (var item in dbQuery)
  3938. {
  3939. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3940. {
  3941. byte[] bytes = new byte[fileStream.Length];
  3942. fileStream.Read(bytes, 0, bytes.Length);
  3943. fileStream.Close();
  3944. Stream stream = new MemoryStream(bytes);
  3945. while (Zips.Keys.Contains(item.FileName))
  3946. {
  3947. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3948. }
  3949. Zips.Add(item.FileName, stream);
  3950. }
  3951. }
  3952. }
  3953. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3954. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3955. if (Zips.Count > 0)
  3956. {
  3957. var byts = io.ConvertZipStream(Zips);
  3958. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3959. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  3960. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  3961. }
  3962. else
  3963. {
  3964. jw.Msg = "暂无生成文件!";
  3965. }
  3966. return Ok(jw);
  3967. }
  3968. /// <summary>
  3969. /// 下载该团组下此模块的所有文件
  3970. /// </summary>
  3971. /// <param name="dto"></param>
  3972. /// <returns></returns>
  3973. [HttpPost]
  3974. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  3975. {
  3976. var jw = JsonView(false);
  3977. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3978. if (groupInfo == null)
  3979. {
  3980. jw.Msg = "团组信息不存在!";
  3981. return Ok(jw);
  3982. }
  3983. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  3984. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  3985. && x.IsDel == 0);
  3986. if (key == null)
  3987. {
  3988. jw.Msg = "Ctable指向错误!";
  3989. return Ok(jw);
  3990. }
  3991. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3992. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3993. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3994. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3995. IOOperatorHelper io = new IOOperatorHelper();
  3996. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3997. foreach (var item in dbQuery)
  3998. {
  3999. if (System.IO.File.Exists(item.FilePath))
  4000. {
  4001. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4002. {
  4003. byte[] bytes = new byte[fileStream.Length];
  4004. fileStream.Read(bytes, 0, bytes.Length);
  4005. fileStream.Close();
  4006. Stream stream = new MemoryStream(bytes);
  4007. while (Zips.Keys.Contains(item.FileName))
  4008. {
  4009. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4010. }
  4011. Zips.Add(item.FileName, stream);
  4012. }
  4013. }
  4014. }
  4015. if (Zips.Count > 0)
  4016. {
  4017. var byts = io.ConvertZipStream(Zips);
  4018. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4019. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4020. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4021. }
  4022. else
  4023. {
  4024. jw.Msg = "暂无生成文件!";
  4025. }
  4026. return Ok(jw);
  4027. }
  4028. /// <summary>
  4029. /// 删除该团组下的指定文件
  4030. /// </summary>
  4031. /// <param name="dto"></param>
  4032. /// <returns></returns>
  4033. [HttpPost]
  4034. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4035. {
  4036. var jw = JsonView(false);
  4037. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4038. if (sing == null)
  4039. {
  4040. jw.Msg = "暂无";
  4041. return Ok(jw);
  4042. }
  4043. if (System.IO.File.Exists(sing.FilePath))
  4044. {
  4045. try
  4046. {
  4047. System.IO.File.Delete(sing.FilePath);
  4048. }
  4049. catch (Exception ex)
  4050. {
  4051. jw.Msg = "删除失败!" + ex.Message;
  4052. return Ok(jw);
  4053. }
  4054. }
  4055. sing.IsDel = 1;
  4056. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4057. sing.DeleteUserId = dto.UserId;
  4058. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4059. jw = JsonView(true, "删除成功!");
  4060. return Ok(jw);
  4061. }
  4062. #endregion
  4063. #region 团组英文资料
  4064. /// <summary>
  4065. /// 查询团组英文所有资料
  4066. /// </summary>
  4067. /// <param name="dto"></param>
  4068. /// <returns></returns>
  4069. [HttpPost]
  4070. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4071. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4072. {
  4073. try
  4074. {
  4075. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4076. if (groupData.Code != 0)
  4077. {
  4078. return Ok(JsonView(false, groupData.Msg));
  4079. }
  4080. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4081. }
  4082. catch (Exception ex)
  4083. {
  4084. return Ok(JsonView(false, "程序错误!"));
  4085. throw;
  4086. }
  4087. }
  4088. /// <summary>
  4089. /// 团组英文资料操作(Status:1.新增,2.修改)
  4090. /// </summary>
  4091. /// <param name="dto"></param>
  4092. /// <returns></returns>
  4093. [HttpPost]
  4094. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4095. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4096. {
  4097. try
  4098. {
  4099. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4100. if (groupData.Code != 0)
  4101. {
  4102. return Ok(JsonView(false, groupData.Msg));
  4103. }
  4104. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4105. }
  4106. catch (Exception ex)
  4107. {
  4108. return Ok(JsonView(false, "程序错误!"));
  4109. throw;
  4110. }
  4111. }
  4112. /// <summary>
  4113. /// 团组英文资料Id查询数据
  4114. /// </summary>
  4115. /// <param name="dto"></param>
  4116. /// <returns></returns>
  4117. [HttpPost]
  4118. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4119. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4120. {
  4121. try
  4122. {
  4123. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4124. if (_DelegationEnData != null)
  4125. {
  4126. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4127. }
  4128. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4129. }
  4130. catch (Exception ex)
  4131. {
  4132. return Ok(JsonView(false, "程序错误!"));
  4133. throw;
  4134. }
  4135. }
  4136. /// <summary>
  4137. /// 团组英文资料删除
  4138. /// </summary>
  4139. /// <param name="dto"></param>
  4140. /// <returns></returns>
  4141. [HttpPost]
  4142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4143. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4144. {
  4145. try
  4146. {
  4147. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4148. if (!res)
  4149. {
  4150. return Ok(JsonView(false, "删除失败"));
  4151. }
  4152. return Ok(JsonView(true, "删除成功!"));
  4153. }
  4154. catch (Exception ex)
  4155. {
  4156. return Ok(JsonView(false, "程序错误!"));
  4157. throw;
  4158. }
  4159. }
  4160. #endregion
  4161. #region 导出邀请函
  4162. /// <summary>
  4163. /// 导出邀请函页面初始化
  4164. /// </summary>
  4165. /// <param name="dto"></param>
  4166. /// <returns></returns>
  4167. [HttpPost]
  4168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4169. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4170. {
  4171. try
  4172. {
  4173. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4174. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4175. if (dto.DiId == 0)
  4176. {
  4177. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4178. }
  4179. else
  4180. {
  4181. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4182. }
  4183. return Ok(JsonView(true, "查询成功!", new
  4184. {
  4185. deleClient = crm_Deles,
  4186. delegations = grp_Delegations
  4187. }));
  4188. }
  4189. catch (Exception ex)
  4190. {
  4191. return Ok(JsonView(false, "程序错误!"));
  4192. throw;
  4193. }
  4194. }
  4195. /// <summary>
  4196. /// 导出邀请函
  4197. /// </summary>
  4198. /// <param name="dto"></param>
  4199. /// <returns></returns>
  4200. [HttpPost]
  4201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4202. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4203. {
  4204. #region 参数验证
  4205. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4206. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4207. #endregion
  4208. try
  4209. {
  4210. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4211. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4212. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4213. From Grp_TourClientList tcl
  4214. Left Join
  4215. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4216. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4217. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4218. From Crm_DeleClient dc
  4219. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4220. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4221. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4222. Where dc.IsDel = 0) temp
  4223. On temp.DcId =tcl.ClientId
  4224. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4225. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4226. List<string> texts = new List<string>();
  4227. if (datas.Count != 0)
  4228. {
  4229. foreach (TourClientListDetailsView item in datas)
  4230. {
  4231. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4232. {
  4233. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4234. }
  4235. else
  4236. {
  4237. string name = item.LastName + item.FirstName;
  4238. texts.Add(name);
  4239. }
  4240. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4241. {
  4242. if (!transDic.ContainsKey(item.Job))
  4243. {
  4244. texts.Add(item.Job);
  4245. }
  4246. }
  4247. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4248. {
  4249. texts.Add(item.CompanyFullName);
  4250. }
  4251. }
  4252. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4253. if (transData.Count > 0)
  4254. {
  4255. foreach (TranslateResult item in transData)
  4256. {
  4257. if (!transDic.ContainsKey(item.Query))
  4258. {
  4259. transDic.Add(item.Query, item.Translation);
  4260. }
  4261. }
  4262. }
  4263. List<GuestList> list = new List<GuestList>();
  4264. foreach (TourClientListDetailsView dele in datas)
  4265. {
  4266. GuestList guestList = new GuestList();
  4267. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4268. {
  4269. guestList.Name = dele.Pinyin;
  4270. }
  4271. else
  4272. {
  4273. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4274. guestList.Name = Name;
  4275. }
  4276. if (dele.Sex == 0)
  4277. {
  4278. guestList.Sex = "Male";
  4279. }
  4280. else if (dele.Sex == 1)
  4281. {
  4282. guestList.Sex = "Female";
  4283. }
  4284. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4285. if (!string.IsNullOrEmpty(dele.Job))
  4286. {
  4287. guestList.Job = dele.Job;
  4288. }
  4289. list.Add(guestList);
  4290. }
  4291. //载入模板
  4292. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4293. DocumentBuilder builder = new DocumentBuilder(doc);
  4294. //获取word里所有表格
  4295. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4296. //获取所填表格的序数
  4297. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4298. var rowStart = tableOne.Rows[0]; //获取第1行
  4299. //循环赋值
  4300. for (int i = 0; i < list.Count; i++)
  4301. {
  4302. builder.MoveToCell(0, i + 1, 0, 0);
  4303. builder.Write(list[i].Name.ToString());
  4304. builder.MoveToCell(0, i + 1, 1, 0);
  4305. builder.Write(list[i].Sex.ToString());
  4306. builder.MoveToCell(0, i + 1, 2, 0);
  4307. builder.Write(list[i].DOB.ToString());
  4308. builder.MoveToCell(0, i + 1, 3, 0);
  4309. builder.Write(list[i].Job.ToString());
  4310. }
  4311. //删除多余行
  4312. while (tableOne.Rows.Count > list.Count + 1)
  4313. {
  4314. tableOne.Rows.RemoveAt(list.Count + 1);
  4315. }
  4316. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4317. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4318. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4319. doc.Save(filePath);
  4320. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4321. return Ok(JsonView(true, "操作成功!", Url));
  4322. }
  4323. else
  4324. {
  4325. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4326. }
  4327. }
  4328. catch (Exception ex)
  4329. {
  4330. return Ok(JsonView(false, ex.Message));
  4331. throw;
  4332. }
  4333. }
  4334. #endregion
  4335. #region 团组经理模块 出入境费用
  4336. ///// <summary>
  4337. ///// 团组模块 - 出入境费用
  4338. ///// </summary>
  4339. ///// <returns></returns>
  4340. //[HttpPost]
  4341. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4342. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  4343. //{
  4344. // try
  4345. // {
  4346. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  4347. // if (data.Code != 0)
  4348. // {
  4349. // return Ok(JsonView(false, data.Msg));
  4350. // }
  4351. // return Ok(JsonView(true, "查询成功!"));
  4352. // }
  4353. // catch (Exception ex)
  4354. // {
  4355. // return Ok(JsonView(false, ex.Message));
  4356. // throw;
  4357. // }
  4358. //}
  4359. /// <summary>
  4360. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4361. /// </summary>
  4362. /// <returns></returns>
  4363. [HttpPost]
  4364. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4365. public async Task<IActionResult> SetDayAndCostAreaChange()
  4366. {
  4367. try
  4368. {
  4369. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4370. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4371. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4372. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4373. foreach (var item in unite) //处理交集数据
  4374. {
  4375. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4376. }
  4377. foreach (var item in merge) //处理差集数据
  4378. {
  4379. int nationalTravelFeeId = 0;
  4380. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4381. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4382. else
  4383. {
  4384. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4385. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4386. }
  4387. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4388. }
  4389. //只更新dayAndCost 的 nationalTravelFeeId;
  4390. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4391. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4392. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4393. }
  4394. catch (Exception ex)
  4395. {
  4396. return Ok(JsonView(false, ex.Message));
  4397. throw;
  4398. }
  4399. }
  4400. /// <summary>
  4401. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4402. /// </summary>
  4403. /// <returns></returns>
  4404. [HttpPost]
  4405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4406. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4407. {
  4408. try
  4409. {
  4410. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4411. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4412. //SetDataInfoView
  4413. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4414. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4415. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4416. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4417. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4418. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4419. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4420. //默认币种显示
  4421. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4422. {
  4423. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4424. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4425. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4426. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4427. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4428. };
  4429. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4430. if (_currencyRate.Count > 0)
  4431. {
  4432. foreach (var item in _currencyInfos)
  4433. {
  4434. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4435. if (rateInfo != null)
  4436. {
  4437. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4438. rate1 *= 1.035M;
  4439. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4440. }
  4441. }
  4442. }
  4443. return Ok(JsonView(true, "查询成功!", new
  4444. {
  4445. GroupNameData = groupNameData.Data,
  4446. CurrencyData = _CurrencyData,
  4447. WordTypeData = _WordTypeData,
  4448. ExcelTypeData = _ExcelTypeData,
  4449. CurrencyInit = _currencyInfos
  4450. }));
  4451. }
  4452. catch (Exception ex)
  4453. {
  4454. return Ok(JsonView(false, ex.Message));
  4455. throw;
  4456. }
  4457. }
  4458. /// <summary>
  4459. /// 团组模块 - 出入境费用
  4460. /// 实时汇率 tips
  4461. /// 签证费用 tips
  4462. /// </summary>
  4463. /// <returns></returns>
  4464. [HttpPost]
  4465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4466. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4467. {
  4468. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4469. //默认币种显示
  4470. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4471. {
  4472. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4473. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4474. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4475. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4476. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4477. };
  4478. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4479. List<dynamic> reteInfos = new List<dynamic>();
  4480. if (_currencyRate.Count > 0)
  4481. {
  4482. foreach (var item in _currencyInfos)
  4483. {
  4484. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4485. if (rateInfo != null)
  4486. {
  4487. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4488. decimal rate1 = item.Rate;
  4489. rate1 *= 1.03M;
  4490. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4491. reteInfos.Add(new
  4492. {
  4493. currCode = item.CurrencyCode,
  4494. currName = item.CurrencyName,
  4495. rate = rate2,
  4496. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4497. });
  4498. }
  4499. }
  4500. }
  4501. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4502. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4503. return Ok(JsonView(true, "查询成功!", new
  4504. {
  4505. //GroupNameData = groupNameData.Data,
  4506. visaData = visaData.Data,
  4507. airData = airData.Data,
  4508. reteInfos = reteInfos
  4509. }));
  4510. }
  4511. /// <summary>
  4512. /// 团组模块 - 出入境费用 - Info
  4513. /// </summary>
  4514. /// <returns></returns>
  4515. [HttpPost]
  4516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4517. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4518. {
  4519. try
  4520. {
  4521. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  4522. if (data.Code != 0)
  4523. {
  4524. return Ok(JsonView(false, data.Msg));
  4525. }
  4526. return Ok(JsonView(true, "查询成功!", data.Data));
  4527. }
  4528. catch (Exception ex)
  4529. {
  4530. return Ok(JsonView(false, ex.Message));
  4531. }
  4532. }
  4533. /// <summary>
  4534. /// 团组模块 - 出入境费用 - Add And Update
  4535. /// </summary>
  4536. /// <returns></returns>
  4537. [HttpPost]
  4538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4539. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4540. {
  4541. try
  4542. {
  4543. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4544. if (data.Code != 0)
  4545. {
  4546. return Ok(JsonView(false, data.Msg));
  4547. }
  4548. //生成默认文件pdf并且通知人员
  4549. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4550. {
  4551. DiId = dto.DiId,
  4552. ExportType = 1,
  4553. SubTypeId = 1005
  4554. }, "pdf");
  4555. //发送通知
  4556. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4557. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4558. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4559. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4560. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4561. //汇率信息记录
  4562. await GeneralMethod.RateRecordSave(dto.UserId,sign,"出入境费用");
  4563. return Ok(JsonView(true, data.Msg, data.Data));
  4564. }
  4565. catch (Exception ex)
  4566. {
  4567. return Ok(JsonView(false, ex.Message));
  4568. }
  4569. }
  4570. /// <summary>
  4571. /// 团组模块 - 出入境费用 - Confirm 费用
  4572. /// </summary>
  4573. /// <returns></returns>
  4574. [HttpPost]
  4575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4576. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4577. {
  4578. //TODO:测试完毕需把对应的用户ID更改
  4579. //1、数据表添加字段
  4580. //2、更改字段接口()
  4581. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4582. //3、确认成功 给财务发送消息
  4583. if (_view.Code == 200)
  4584. {
  4585. if (dto.Type == 1)
  4586. {
  4587. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4588. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4589. }
  4590. }
  4591. return Ok(_view);
  4592. }
  4593. /// <summary>
  4594. /// 团组模块 - 出入境费用 - File downlaod
  4595. /// </summary>
  4596. /// <param name="dto"></param>
  4597. /// <returns></returns>
  4598. [HttpPost]
  4599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4600. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4601. {
  4602. try
  4603. {
  4604. if (dto.DiId < 1)
  4605. {
  4606. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4607. }
  4608. if (dto.ExportType < 1)
  4609. {
  4610. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  4611. }
  4612. if (dto.SubTypeId < 1)
  4613. {
  4614. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  4615. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4616. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4617. 3 团组成员名单 1 团组成员名单"));
  4618. }
  4619. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4620. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4621. if (_EnterExitCosts == null)
  4622. {
  4623. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  4624. }
  4625. //数据源
  4626. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4627. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4628. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4629. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4630. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4631. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4632. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4633. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4634. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4635. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4636. .Select((tcl, dc, cc) => new
  4637. {
  4638. Name = dc.LastName + dc.FirstName,
  4639. Sex = dc.Sex,
  4640. Birthday = dc.BirthDay,
  4641. Company = cc.CompanyFullName,
  4642. Job = dc.Job
  4643. })
  4644. .ToList();
  4645. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4646. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4647. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4648. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4649. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4650. if (dto.ExportType == 1) //明细表
  4651. {
  4652. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4653. {
  4654. //获取模板
  4655. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4656. //载入模板
  4657. Document doc = new Document(tempPath);
  4658. DocumentBuilder builder = new DocumentBuilder(doc);
  4659. //利用键值对存放数据
  4660. Dictionary<string, string> dic = new Dictionary<string, string>();
  4661. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4662. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4663. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4664. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4665. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4666. //境内费用(其他费用)
  4667. if (_EnterExitCosts.ChoiceOne == 1)
  4668. {
  4669. string row1_1 = "";
  4670. if (_EnterExitCosts.Visa > 0)
  4671. {
  4672. //insidePayTotal += _EnterExitCosts.Visa;
  4673. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4674. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4675. {
  4676. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4677. }
  4678. }
  4679. string row1_2 = "";
  4680. if (_EnterExitCosts.YiMiao > 0)
  4681. {
  4682. //insidePayTotal += _EnterExitCosts.YiMiao;
  4683. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4684. }
  4685. if (_EnterExitCosts.HeSuan > 0)
  4686. {
  4687. //insidePayTotal += _EnterExitCosts.HeSuan;
  4688. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4689. }
  4690. if (_EnterExitCosts.Service > 0)
  4691. {
  4692. //insidePayTotal += _EnterExitCosts.Service;
  4693. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4694. }
  4695. string row1_3 = "";
  4696. if (_EnterExitCosts.Safe > 0)
  4697. {
  4698. //insidePayTotal += _EnterExitCosts.Safe;
  4699. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4700. }
  4701. if (_EnterExitCosts.Ticket > 0)
  4702. {
  4703. //insidePayTotal += _EnterExitCosts.Ticket;
  4704. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4705. }
  4706. string row1 = "";
  4707. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4708. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4709. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4710. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4711. dic.Add("Row1Str", row1);
  4712. }
  4713. string airTotalStr = string.Empty,
  4714. airPriceStr = string.Empty;
  4715. //经济舱
  4716. if (_EnterExitCosts.SumJJC == 1)
  4717. {
  4718. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4719. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4720. }
  4721. //公务舱
  4722. if (_EnterExitCosts.SumGWC == 1)
  4723. {
  4724. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4725. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4726. }
  4727. //头等舱
  4728. if (_EnterExitCosts.SumTDC == 1)
  4729. {
  4730. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4731. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4732. }
  4733. dic.Add("AirTotalStr", airTotalStr);
  4734. dic.Add("AirPriceStr", airPriceStr);
  4735. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4736. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4737. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4738. int table1Row = 0,
  4739. table2Row = 0,
  4740. table3Row = 0,
  4741. table4Row = 0;
  4742. //住宿费
  4743. if (_EnterExitCosts.ChoiceThree == 1)
  4744. {
  4745. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4746. table1Row = dac1.Count;
  4747. #region 填充word表格内容
  4748. for (int i = 0; i < dac1.Count; i++)
  4749. {
  4750. Grp_DayAndCost dac = dac1[i];
  4751. if (dac == null) continue;
  4752. builder.MoveToCell(0, i, 0, 0);
  4753. builder.Write("第" + dac.Days.ToString() + "晚:");
  4754. builder.MoveToCell(0, i, 1, 0);
  4755. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4756. //builder.Write(dac.Place == null ? "" : dac.Place);
  4757. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4758. builder.MoveToCell(0, i, 2, 0);
  4759. builder.Write("费用标准:");
  4760. string curr = "";
  4761. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4762. if (currData != null)
  4763. {
  4764. curr = currData.Name;
  4765. }
  4766. builder.MoveToCell(0, i, 3, 0);
  4767. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4768. builder.MoveToCell(0, i, 4, 0);
  4769. builder.Write("费用小计:");
  4770. builder.MoveToCell(0, i, 5, 0);
  4771. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4772. }
  4773. #endregion
  4774. }
  4775. else dic.Add("SubZS", "0.00");
  4776. //删除多余行
  4777. while (table1.Rows.Count > table1Row)
  4778. {
  4779. table1.Rows.RemoveAt(table1Row);
  4780. }
  4781. //伙食费
  4782. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4783. if (_EnterExitCosts.ChoiceFour == 1)
  4784. {
  4785. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4786. table2Row = dac2.Count;
  4787. #region 填充word表格内容
  4788. for (int i = 0; i < dac2.Count; i++)
  4789. {
  4790. Grp_DayAndCost dac = dac2[i];
  4791. if (dac == null) continue;
  4792. builder.MoveToCell(1, i, 0, 0);
  4793. builder.Write("第" + dac.Days.ToString() + "天:");
  4794. builder.MoveToCell(1, i, 1, 0);
  4795. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4796. builder.MoveToCell(1, i, 2, 0);
  4797. builder.Write("费用标准:");
  4798. string curr = "";
  4799. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4800. if (currData != null)
  4801. {
  4802. curr = currData.Name;
  4803. }
  4804. builder.MoveToCell(1, i, 3, 0);
  4805. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4806. builder.MoveToCell(1, i, 4, 0);
  4807. builder.Write("费用小计:");
  4808. builder.MoveToCell(1, i, 5, 0);
  4809. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4810. }
  4811. #endregion
  4812. }
  4813. else dic.Add("SubHS", "0.00");
  4814. //删除多余行
  4815. while (table2.Rows.Count > table2Row)
  4816. {
  4817. table2.Rows.RemoveAt(table2Row);
  4818. }
  4819. //公杂费
  4820. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4821. if (_EnterExitCosts.ChoiceFive == 1)
  4822. {
  4823. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4824. table3Row = dac3.Count;
  4825. #region 填充word表格内容
  4826. for (int i = 0; i < dac3.Count; i++)
  4827. {
  4828. Grp_DayAndCost dac = dac3[i];
  4829. if (dac == null) continue;
  4830. builder.MoveToCell(2, i, 0, 0);
  4831. builder.Write("第" + dac.Days.ToString() + "天:");
  4832. builder.MoveToCell(2, i, 1, 0);
  4833. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4834. builder.MoveToCell(2, i, 2, 0);
  4835. builder.Write("费用标准:");
  4836. string curr = "";
  4837. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4838. if (currData != null)
  4839. {
  4840. curr = currData.Name;
  4841. }
  4842. builder.MoveToCell(2, i, 3, 0);
  4843. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4844. builder.MoveToCell(2, i, 4, 0);
  4845. builder.Write("费用小计:");
  4846. builder.MoveToCell(2, i, 5, 0);
  4847. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4848. }
  4849. //删除多余行
  4850. while (table3.Rows.Count > table3Row)
  4851. {
  4852. table3.Rows.RemoveAt(table3Row);
  4853. }
  4854. #endregion
  4855. }
  4856. else dic.Add("SubGZF", "0.00");
  4857. //删除多余行
  4858. while (table3.Rows.Count > table3Row)
  4859. {
  4860. table3.Rows.RemoveAt(table3Row);
  4861. }
  4862. //培训费
  4863. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4864. if (_EnterExitCosts.ChoiceSix == 1)
  4865. {
  4866. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4867. dic.Add("SubPX", pxStr);
  4868. table4Row = dac4.Count;
  4869. #region 填充word表格内容
  4870. for (int i = 0; i < dac4.Count; i++)
  4871. {
  4872. Grp_DayAndCost dac = dac4[i];
  4873. if (dac == null) continue;
  4874. builder.MoveToCell(3, i, 0, 0);
  4875. builder.Write("第" + dac.Days.ToString() + "天:");
  4876. builder.MoveToCell(3, i, 1, 0);
  4877. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4878. builder.MoveToCell(3, i, 2, 0);
  4879. builder.Write("费用标准:");
  4880. string curr = "";
  4881. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4882. if (currData != null)
  4883. {
  4884. curr = currData.Name;
  4885. }
  4886. builder.MoveToCell(3, i, 3, 0);
  4887. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4888. builder.MoveToCell(3, i, 4, 0);
  4889. builder.Write("费用小计:");
  4890. builder.MoveToCell(3, i, 5, 0);
  4891. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4892. }
  4893. #endregion
  4894. }
  4895. //else dic.Add("SubPX","0.00");
  4896. //删除多余行
  4897. while (table4.Rows.Count > table4Row)
  4898. {
  4899. table4.Rows.RemoveAt(table4Row);
  4900. }
  4901. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
  4902. decimal subJJC = 0.00M,
  4903. subGWC = 0.00M,
  4904. subTDC = 0.00M;
  4905. //经济舱
  4906. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  4907. //公务舱
  4908. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  4909. //头等舱
  4910. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  4911. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4912. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4913. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  4914. #region 填充word模板书签内容
  4915. foreach (var key in dic.Keys)
  4916. {
  4917. builder.MoveToBookmark(key);
  4918. builder.Write(dic[key]);
  4919. }
  4920. #endregion
  4921. //文件名
  4922. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  4923. AsposeHelper.removewatermark_v2180();
  4924. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4925. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4926. return Ok(JsonView(true, "成功", new { Url = url }));
  4927. }
  4928. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4929. {
  4930. //获取模板
  4931. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4932. //载入模板
  4933. Document doc = new Document(tempPath);
  4934. DocumentBuilder builder = new DocumentBuilder(doc);
  4935. Dictionary<string, string> dic = new Dictionary<string, string>();
  4936. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4937. {
  4938. List<string> list = new List<string>();
  4939. try
  4940. {
  4941. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4942. foreach (var item in spilitArr)
  4943. {
  4944. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4945. var depCode = spDotandEmpty[2].Substring(0, 3);
  4946. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4947. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4948. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4949. list.Add(depName);
  4950. list.Add(arrName);
  4951. }
  4952. list = list.Distinct().ToList();
  4953. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4954. }
  4955. catch (Exception)
  4956. {
  4957. dic.Add("ReturnCode", "行程录入不正确!");
  4958. }
  4959. }
  4960. else
  4961. {
  4962. dic.Add("ReturnCode", "未录入行程!");
  4963. }
  4964. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4965. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4966. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4967. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4968. {
  4969. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4970. dic.Add("Day", sp.Days.ToString());
  4971. }
  4972. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4973. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4974. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4975. //dic.Add("Names", Names);
  4976. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4977. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4978. decimal dac1totalPrice = 0.00M;
  4979. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  4980. foreach (var dac in dac1)
  4981. {
  4982. if (dac.SubTotal == 0.00M)
  4983. {
  4984. continue;
  4985. }
  4986. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4987. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4988. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4989. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4990. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4991. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4992. builder.Write(currency);//币种
  4993. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4994. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4995. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4996. builder.Write("");//人数
  4997. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4998. builder.Write("");//天数
  4999. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5000. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5001. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5002. decimal rate = 0.00M;
  5003. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5004. builder.Write(rate.ToString("#0.0000"));//汇率
  5005. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5006. decimal rbmPrice = dac.SubTotal;
  5007. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5008. accommodationStartIndex++;
  5009. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5010. }
  5011. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5012. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5013. {
  5014. table1.Rows.RemoveAt(i - 1);
  5015. foodandotherStartIndex--;
  5016. }
  5017. if (dac2.Count == dac3.Count)//国家 币种 金额
  5018. {
  5019. for (int i = 0; i < dac2.Count; i++)
  5020. {
  5021. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5022. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5023. }
  5024. }
  5025. decimal dac2totalPrice = 0.00M;
  5026. foreach (var dac in dac2)
  5027. {
  5028. if (dac.SubTotal == 0)
  5029. {
  5030. continue;
  5031. }
  5032. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5033. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5034. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5035. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5036. builder.Write(currency);//币种
  5037. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5038. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5039. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5040. builder.Write("");//人数
  5041. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5042. builder.Write("");//天数
  5043. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5044. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5045. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5046. decimal rate = 0.00M;
  5047. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5048. builder.Write(rate.ToString("#0.0000"));//汇率
  5049. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5050. decimal rbmPrice = dac.SubTotal;
  5051. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5052. foodandotherStartIndex++;
  5053. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5054. }
  5055. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5056. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5057. {
  5058. table1.Rows.RemoveAt(i - 1);
  5059. }
  5060. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5061. string otherFeeStr = "";
  5062. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5063. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5064. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5065. if (otherFeeStr.Length > 0)
  5066. {
  5067. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5068. otherFeeStr = $"({otherFeeStr})";
  5069. dic.Add("OtherFeeStr", otherFeeStr);
  5070. }
  5071. //总计
  5072. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5073. //国际旅费
  5074. string outsideAir = string.Empty;
  5075. string allPriceAir = string.Empty;
  5076. if (_EnterExitCosts.SumJJC == 1)
  5077. {
  5078. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5079. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5080. }
  5081. if (_EnterExitCosts.SumGWC == 1)
  5082. {
  5083. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5084. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5085. }
  5086. if (_EnterExitCosts.SumTDC == 1)
  5087. {
  5088. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5089. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5090. }
  5091. dic.Add("InTravelPrice", $"({outsideAir})");
  5092. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5093. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5094. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5095. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5096. foreach (var key in dic.Keys)
  5097. {
  5098. builder.MoveToBookmark(key);
  5099. builder.Write(dic[key]);
  5100. }
  5101. //模板文件名
  5102. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5103. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5104. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5105. return Ok(JsonView(true, "成功", new { Url = url }));
  5106. }
  5107. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5108. {
  5109. //获取模板
  5110. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5111. //载入模板
  5112. WorkbookDesigner designer = new WorkbookDesigner();
  5113. designer.Workbook = new Workbook(tempPath);
  5114. Dictionary<string, string> dic = new Dictionary<string, string>();
  5115. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5116. {
  5117. List<string> list = new List<string>();
  5118. try
  5119. {
  5120. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5121. foreach (var item in spilitArr)
  5122. {
  5123. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5124. var depCode = spDotandEmpty[2].Substring(0, 3);
  5125. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5126. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5127. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5128. list.Add(depName);
  5129. list.Add(arrName);
  5130. }
  5131. list = list.Distinct().ToList();
  5132. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5133. }
  5134. catch (Exception)
  5135. {
  5136. dic.Add("ReturnCode", "行程录入不正确!");
  5137. }
  5138. }
  5139. else
  5140. {
  5141. dic.Add("ReturnCode", "未录入行程!");
  5142. }
  5143. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5144. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5145. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5146. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5147. {
  5148. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5149. dic.Add("Day", sp.Days.ToString());
  5150. }
  5151. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5152. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5153. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5154. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5155. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5156. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5157. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5158. designer.SetDataSource("Name", Names);
  5159. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5160. designer.SetDataSource("Day", dic["Day"] + "天");
  5161. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5162. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5163. int startIndex = 10;
  5164. const int startIndexcopy = 10;
  5165. if (dac2.Count == dac3.Count)//国家 币种 金额
  5166. {
  5167. for (int i = 0; i < dac2.Count; i++)
  5168. {
  5169. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5170. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5171. }
  5172. }
  5173. DataTable dtdac1 = new DataTable();
  5174. List<string> place = new List<string>();
  5175. dtdac1.Columns.AddRange(new DataColumn[] {
  5176. new DataColumn(){ ColumnName = "city"},
  5177. new DataColumn(){ ColumnName = "curr"},
  5178. new DataColumn(){ ColumnName = "criterion"},
  5179. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5180. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5181. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5182. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5183. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5184. });
  5185. DataTable dtdac2 = new DataTable();
  5186. dtdac2.Columns.AddRange(new DataColumn[] {
  5187. new DataColumn(){ ColumnName = "city"},
  5188. new DataColumn(){ ColumnName = "curr"},
  5189. new DataColumn(){ ColumnName = "criterion"},
  5190. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5191. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5192. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5193. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5194. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5195. });
  5196. dtdac1.TableName = "tb1";
  5197. dtdac2.TableName = "tb2";
  5198. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5199. foreach (var item in dac1)
  5200. {
  5201. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5202. if (place.Contains(item.Place))
  5203. {
  5204. continue;
  5205. }
  5206. DataRow row = dtdac1.NewRow();
  5207. row["city"] = item.Place;
  5208. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5209. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5210. row["curr"] = currency;
  5211. row["rate"] = rate.ToString("#0.0000");
  5212. row["criterion"] = item.Cost.ToString("#0.00");
  5213. row["number"] = 1;
  5214. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5215. //row["costRMB"] = rbmPrice;
  5216. dtdac1.Rows.Add(row);
  5217. place.Add(item.Place);
  5218. }
  5219. place = new List<string>();
  5220. foreach (var item in dac2)
  5221. {
  5222. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5223. if (place.Contains(item.Place))
  5224. {
  5225. continue;
  5226. }
  5227. DataRow row = dtdac2.NewRow();
  5228. row["city"] = item.Place;
  5229. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5230. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5231. row["curr"] = currency;
  5232. row["rate"] = rate.ToString("#0.0000");
  5233. row["criterion"] = item.Cost.ToString("#0.00");
  5234. row["number"] = 1;
  5235. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5236. //row["cost"] = item.SubTotal;
  5237. //row["costRMB"] = rbmPrice;
  5238. dtdac2.Rows.Add(row);
  5239. place.Add(item.Place);
  5240. //dac2totalPrice += rbmPrice;
  5241. }
  5242. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5243. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5244. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5245. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5246. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5247. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5248. string cell4Str1 = string.Empty;
  5249. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5250. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5251. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5252. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5253. string cellStr = $" 5.其他费用(";
  5254. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5255. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5256. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5257. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5258. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5259. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5260. if (cellStr.Length > 8)
  5261. {
  5262. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5263. }
  5264. cellStr += ")";
  5265. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  5266. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5267. decimal pxFee = dac4.Sum(it => it.Cost);
  5268. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5269. string celllastStr1 = "";
  5270. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5271. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5272. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5273. celllastStr1 += $",国际旅费 元";
  5274. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5275. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5276. designer.SetDataSource("cell4Str", cell4Str);
  5277. designer.SetDataSource("cellStr", cellStr);
  5278. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  5279. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5280. designer.SetDataSource("celllastStr", celllastStr);
  5281. Workbook wb = designer.Workbook;
  5282. var sheet = wb.Worksheets[0];
  5283. //绑定datatable数据集
  5284. designer.SetDataSource(dtdac1);
  5285. designer.SetDataSource(dtdac2);
  5286. designer.Process();
  5287. var rowStart = dtdac1.Rows.Count;
  5288. while (rowStart > 0)
  5289. {
  5290. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5291. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5292. startIndex++;
  5293. rowStart--;
  5294. }
  5295. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5296. startIndex += 1; //总计行
  5297. rowStart = dtdac2.Rows.Count;
  5298. while (rowStart > 0)
  5299. {
  5300. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5301. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5302. startIndex++;
  5303. rowStart--;
  5304. }
  5305. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5306. wb.CalculateFormula(true);
  5307. //模板文件名
  5308. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5309. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5310. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5311. return Ok(JsonView(true, "成功", new { Url = url }));
  5312. }
  5313. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5314. {
  5315. //获取模板
  5316. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5317. //载入模板
  5318. Document doc = new Document(tempPath);
  5319. DocumentBuilder builder = new DocumentBuilder(doc);
  5320. Dictionary<string, string> dic = new Dictionary<string, string>();
  5321. dic.Add("GroupName", _DelegationInfo.TeamName);
  5322. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5323. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5324. string missionLeaderJob = "";//负责人job
  5325. int groupNumber = 0; //团人数
  5326. if (DeleClientList.Count > 0)
  5327. {
  5328. missionLeader = DeleClientList[0]?.Name ?? "";
  5329. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5330. }
  5331. dic.Add("MissionLeader", missionLeader); //团负责人
  5332. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5333. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5334. #region MyRegion
  5335. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5336. //{
  5337. // List<string> list = new List<string>();
  5338. // try
  5339. // {
  5340. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5341. // foreach (var item in spilitArr)
  5342. // {
  5343. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5344. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5345. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5346. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5347. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5348. // list.Add(depName);
  5349. // list.Add(arrName);
  5350. // }
  5351. // list = list.Distinct().ToList();
  5352. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5353. // }
  5354. // catch (Exception)
  5355. // {
  5356. // dic.Add("ReturnCode", "行程录入不正确!");
  5357. // }
  5358. //}
  5359. //else
  5360. //{
  5361. // dic.Add("ReturnCode", "未录入行程!");
  5362. //}
  5363. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5364. dic.Add("ReturnCode", string.Join("、", countrys));
  5365. #endregion
  5366. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5367. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5368. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5369. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5370. //{
  5371. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5372. // dic.Add("Day", sp.Days.ToString());
  5373. //}
  5374. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5375. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5376. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5377. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5378. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5379. //培训人员名单
  5380. int cultivateRowIndex = 7;
  5381. foreach (var item in DeleClientList)
  5382. {
  5383. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5384. builder.Write(item.Name);
  5385. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5386. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5387. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5388. string birthDay = "";
  5389. if (item.Birthday != null)
  5390. {
  5391. DateTime dt = Convert.ToDateTime(item.Birthday);
  5392. birthDay = $"{dt.Year}.{dt.Month}";
  5393. }
  5394. builder.Write(birthDay);
  5395. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5396. builder.Write(item.Company);
  5397. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5398. builder.Write(item.Job);
  5399. cultivateRowIndex++;
  5400. }
  5401. //删除多余行
  5402. //cultivateRowIndex -= 2;
  5403. int delRows = 10 + 7 - cultivateRowIndex;
  5404. if (delRows > 0)
  5405. {
  5406. for (int i = 0; i < delRows; i++)
  5407. {
  5408. table1.Rows.RemoveAt(cultivateRowIndex);
  5409. //cultivateRowIndex++;
  5410. }
  5411. }
  5412. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5413. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5414. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5415. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5416. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5417. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5418. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5419. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5420. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5421. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5422. //其他费用
  5423. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  5424. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5425. //其他费用合计
  5426. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5427. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5428. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5429. //公务舱合计
  5430. //国际旅费
  5431. string outsideJJ = "";
  5432. string allPriceJJ = "";
  5433. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5434. {
  5435. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5436. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5437. }
  5438. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5439. {
  5440. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5441. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5442. }
  5443. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5444. {
  5445. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5446. dic.Add("AirFeeTotal", airFeeTotalStr);
  5447. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5448. dic.Add("FeeTotal", feeTotalStr);
  5449. }
  5450. foreach (var key in dic.Keys)
  5451. {
  5452. builder.MoveToBookmark(key);
  5453. builder.Write(dic[key]);
  5454. }
  5455. //模板文件名
  5456. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5457. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5458. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5459. return Ok(JsonView(true, "成功", new { Url = url }));
  5460. }
  5461. }
  5462. else if (dto.ExportType == 2) //表格
  5463. {
  5464. //利用键值对存放数据
  5465. Dictionary<string, string> dic = new Dictionary<string, string>();
  5466. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5467. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5468. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5469. dic.Add("Day", sp.Days.ToString());
  5470. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5471. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5472. {
  5473. //获取模板
  5474. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5475. //载入模板
  5476. Document doc = new Document(tempPath);
  5477. DocumentBuilder builder = new DocumentBuilder(doc);
  5478. dic.Add("TeamName", _DelegationInfo.TeamName);
  5479. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5480. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5481. string missionLeaderName = "",
  5482. missionLeaderJob = "";
  5483. if (DeleClientList.Count > 0)
  5484. {
  5485. missionLeaderName = DeleClientList[0].Name;
  5486. missionLeaderJob = DeleClientList[0].Job;
  5487. }
  5488. dic.Add("MissionLeaderName", missionLeaderName);
  5489. dic.Add("MissionLeaderJob", missionLeaderJob);
  5490. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5491. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5492. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5493. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5494. int rowCount = 10;//总人数行
  5495. int startRowIndex = 7; //起始行
  5496. for (int i = 0; i < DeleClientList.Count; i++)
  5497. {
  5498. builder.MoveToCell(0, startRowIndex, 0, 0);
  5499. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5500. builder.MoveToCell(0, startRowIndex, 1, 0);
  5501. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5502. builder.Write(sex);//性别
  5503. builder.MoveToCell(0, startRowIndex, 2, 0);
  5504. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5505. builder.MoveToCell(0, startRowIndex, 3, 0);
  5506. builder.Write(DeleClientList[i].Company);//工作单位
  5507. builder.MoveToCell(0, startRowIndex, 4, 0);
  5508. builder.Write(DeleClientList[i].Job);//职务及级别
  5509. builder.MoveToCell(0, startRowIndex, 5, 0);
  5510. builder.Write("");//人员属性
  5511. builder.MoveToCell(0, startRowIndex, 6, 0);
  5512. builder.Write("");//上次出国时间
  5513. startRowIndex++;
  5514. }
  5515. int nullRow = rowCount - DeleClientList.Count;//空行
  5516. for (int i = 0; i < nullRow; i++)
  5517. {
  5518. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5519. }
  5520. foreach (var key in dic.Keys)
  5521. {
  5522. builder.MoveToBookmark(key);
  5523. builder.Write(dic[key]);
  5524. }
  5525. //模板文件名
  5526. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5527. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5528. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5529. return Ok(JsonView(true, "成功", new { Url = url }));
  5530. }
  5531. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5532. {
  5533. //获取模板
  5534. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5535. //载入模板
  5536. Document doc = new Document(tempPath);
  5537. DocumentBuilder builder = new DocumentBuilder(doc);
  5538. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5539. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5540. dic.Add("Names", Names);
  5541. int accommodationRows = 12, foodandotherRows = 12;
  5542. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5543. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5544. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5545. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5546. int accommodationStartIndex = 6;
  5547. decimal dac1totalPrice = 0.00M;
  5548. foreach (var dac in dac1)
  5549. {
  5550. if (dac.SubTotal == 0)
  5551. {
  5552. continue;
  5553. }
  5554. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5555. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5556. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5557. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5558. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5559. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5560. builder.Write(currency);//币种
  5561. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5562. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5563. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5564. builder.Write("");//人数
  5565. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5566. builder.Write("");//天数
  5567. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5568. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5569. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5570. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5571. builder.Write(rate.ToString("#0.0000"));//汇率
  5572. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5573. decimal rbmPrice = rate * dac.SubTotal;
  5574. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5575. accommodationStartIndex++;
  5576. dac1totalPrice += rbmPrice;
  5577. }
  5578. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5579. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5580. builder.Write("小计");
  5581. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5582. builder.Write(dac1totalPrice.ToString("#0.00"));
  5583. accommodationStartIndex++;
  5584. int nullRow = accommodationRows - dac1.Count;
  5585. //删除空行
  5586. //if (nullRow > 0)
  5587. //{
  5588. // int rowIndex = accommodationStartIndex;
  5589. // for (int i = 0; i < nullRow; i++)
  5590. // {
  5591. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5592. // row.Remove();
  5593. // rowIndex++;
  5594. // }
  5595. //}
  5596. if (dac2.Count == dac3.Count)//国家 币种 金额
  5597. {
  5598. for (int i = 0; i < dac2.Count; i++)
  5599. {
  5600. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5601. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5602. }
  5603. }
  5604. int foodandotherStartIndex = 19;//
  5605. decimal dac2totalPrice = 0.00M;
  5606. foreach (var dac in dac2)
  5607. {
  5608. if (dac.SubTotal == 0)
  5609. {
  5610. continue;
  5611. }
  5612. //foodandotherStartIndex = 12;
  5613. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5614. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5615. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5616. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5617. builder.Write(currency);//币种
  5618. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5619. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5620. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5621. builder.Write("");//人数
  5622. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5623. builder.Write("");//天数
  5624. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5625. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5626. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5627. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5628. builder.Write(rate.ToString("#0.0000"));//汇率
  5629. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5630. decimal rbmPrice = rate * dac.SubTotal;
  5631. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5632. foodandotherStartIndex++;
  5633. dac2totalPrice += rbmPrice;
  5634. }
  5635. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5636. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5637. //删除空行
  5638. //if (dac2.Count < foodandotherRows)
  5639. //{
  5640. // while (table2.Rows.Count > dac2.Count)
  5641. // {
  5642. // table2.Rows.RemoveAt(dac2.Count);
  5643. // }
  5644. //}
  5645. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5646. string otherFeeStr = "";
  5647. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5648. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5649. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5650. if (otherFeeStr.Length > 0)
  5651. {
  5652. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5653. otherFeeStr = $"({otherFeeStr})";
  5654. dic.Add("OtherFeeStr", otherFeeStr);
  5655. }
  5656. foreach (var key in dic.Keys)
  5657. {
  5658. builder.MoveToBookmark(key);
  5659. builder.Write(dic[key]);
  5660. }
  5661. //模板文件名
  5662. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5663. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5664. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5665. return Ok(JsonView(true, "成功", new { Url = url }));
  5666. }
  5667. }
  5668. else if (dto.ExportType == 3)
  5669. {
  5670. if (dto.SubTypeId == 1) //团组成员名单
  5671. {
  5672. if (DeleClientList.Count < 1)
  5673. {
  5674. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  5675. }
  5676. //获取模板
  5677. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5678. //载入模板
  5679. Document doc = new Document(tempPath);
  5680. DocumentBuilder builder = new DocumentBuilder(doc);
  5681. //获取word里所有表格
  5682. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5683. //获取所填表格的序数
  5684. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5685. var rowStart = tableOne.Rows[0]; //获取第1行
  5686. //循环赋值
  5687. for (int i = 0; i < DeleClientList.Count; i++)
  5688. {
  5689. builder.MoveToCell(0, i + 1, 0, 0);
  5690. builder.Write(DeleClientList[i].Name);
  5691. builder.MoveToCell(0, i + 1, 1, 0);
  5692. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5693. builder.Write(sex);
  5694. builder.MoveToCell(0, i + 1, 2, 0);
  5695. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5696. builder.MoveToCell(0, i + 1, 3, 0);
  5697. builder.Write(DeleClientList[i].Company);
  5698. builder.MoveToCell(0, i + 1, 4, 0);
  5699. builder.Write(DeleClientList[i].Job);
  5700. }
  5701. //删除多余行
  5702. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5703. {
  5704. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5705. }
  5706. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5707. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5708. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5709. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5710. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5711. return Ok(JsonView(true, "成功", new { Url = url }));
  5712. }
  5713. }
  5714. return Ok(JsonView(false, "操作失败!"));
  5715. }
  5716. catch (Exception ex)
  5717. {
  5718. return Ok(JsonView(false, ex.Message));
  5719. }
  5720. }
  5721. /// <summary>
  5722. /// 获取三公费用标准city
  5723. /// </summary>
  5724. /// <param name="placeData"></param>
  5725. /// <param name="nationalTravelFeeId"></param>
  5726. /// <returns></returns>
  5727. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5728. {
  5729. string _city = string.Empty;
  5730. if (placeData.Count < 1) return _city;
  5731. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5732. if (data == null) return _city;
  5733. string country = data.Country;
  5734. string city = data.City;
  5735. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5736. else _city = city;
  5737. return _city;
  5738. }
  5739. /// <summary>
  5740. /// 团组模块 - 出入境费用 - 明细表导出
  5741. /// </summary>
  5742. /// <returns></returns>
  5743. [HttpPost]
  5744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5745. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5746. {
  5747. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5748. if (data.Code != 0)
  5749. {
  5750. return Ok(JsonView(false, data.Msg));
  5751. }
  5752. return Ok(JsonView(true, data.Msg, data.Data));
  5753. }
  5754. /// <summary>
  5755. /// 团组模块 - 出入境费用 - 一键清空
  5756. /// </summary>
  5757. /// <returns></returns>
  5758. [HttpPost]
  5759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5760. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5761. {
  5762. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5763. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5764. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5765. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5766. if (_view.Code == 0)
  5767. {
  5768. return Ok(JsonView(true, "操作成功"));
  5769. }
  5770. return Ok(JsonView(false, "操作失败"));
  5771. }
  5772. /// <summary>
  5773. /// 团组模块 - 出入境费用 - 子项删除
  5774. /// </summary>
  5775. /// <returns></returns>
  5776. [HttpPost]
  5777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5778. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5779. {
  5780. try
  5781. {
  5782. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5783. if (data.Code != 0)
  5784. {
  5785. return Ok(JsonView(false, data.Msg));
  5786. }
  5787. return Ok(JsonView(true, "操作成功!", data.Data));
  5788. }
  5789. catch (Exception ex)
  5790. {
  5791. return Ok(JsonView(false, ex.Message));
  5792. }
  5793. }
  5794. /// <summary>
  5795. /// 团组模块 - 出入境国家费用标准 List
  5796. /// </summary>
  5797. /// <returns></returns>
  5798. [HttpPost]
  5799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5800. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5801. {
  5802. try
  5803. {
  5804. Stopwatch sw = new Stopwatch();
  5805. sw.Start();
  5806. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5807. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5808. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5809. Where gntf.Isdel = 0");
  5810. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5811. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5812. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  5813. //foreach (var item in nationalTravel)
  5814. //{
  5815. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  5816. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  5817. // if (otherData != null)
  5818. // {
  5819. // cityData.Remove(otherData);
  5820. // cityData.Add(otherData);
  5821. // }
  5822. // nationalTravelFeeData1.Add(new
  5823. // {
  5824. // Country = item.Country,
  5825. // CityData = cityData
  5826. // });
  5827. //}
  5828. sw.Stop();
  5829. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  5830. }
  5831. catch (Exception ex)
  5832. {
  5833. return Ok(JsonView(false, ex.Message));
  5834. throw;
  5835. }
  5836. }
  5837. /// <summary>
  5838. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  5839. /// </summary>
  5840. /// <returns></returns>
  5841. [HttpPost]
  5842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5843. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  5844. {
  5845. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  5846. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  5847. List<string> countryData = new List<string>();
  5848. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  5849. countryData = countryData.Distinct().ToList();
  5850. List<dynamic> dataSource = new List<dynamic>();
  5851. foreach (var item in countryData)
  5852. {
  5853. List<string> cityData1 = new List<string>();
  5854. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  5855. var countryData2 = new
  5856. {
  5857. CountryName = item,
  5858. CityData = cityData1
  5859. };
  5860. dataSource.Add(countryData2);
  5861. }
  5862. return Ok(JsonView(true, "查询成功!", dataSource));
  5863. }
  5864. /// <summary>
  5865. /// 团组模块 - 出入境国家费用标准 Page List
  5866. /// </summary>
  5867. /// <returns></returns>
  5868. [HttpPost]
  5869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5870. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  5871. {
  5872. int portId = dto.PortType;
  5873. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5874. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  5875. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  5876. string whereSql = string.Empty;
  5877. if (!string.IsNullOrEmpty(dto.Country))
  5878. {
  5879. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  5880. }
  5881. if (!string.IsNullOrEmpty(dto.City))
  5882. {
  5883. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  5884. }
  5885. string pageSql = string.Format(@"Select * From (
  5886. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  5887. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  5888. From Grp_NationalTravelFee gntf
  5889. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5890. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5891. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  5892. RefAsync<int> total = 0;
  5893. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  5894. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  5895. }
  5896. /// <summary>
  5897. /// 团组模块 - 出入境国家费用标准 根据城市查询
  5898. /// </summary>
  5899. /// <returns></returns>
  5900. [HttpPost]
  5901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5902. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  5903. {
  5904. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  5905. int portId = dto.PortType;
  5906. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5907. string whereSql = string.Empty;
  5908. if (!string.IsNullOrEmpty(dto.Country))
  5909. {
  5910. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  5911. }
  5912. if (!string.IsNullOrEmpty(dto.City))
  5913. {
  5914. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  5915. }
  5916. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  5917. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  5918. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  5919. From Grp_NationalTravelFee gntf
  5920. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5921. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5922. Where gntf.Isdel = 0 {0} ", whereSql);
  5923. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  5924. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  5925. }
  5926. /// <summary>
  5927. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  5928. /// </summary>
  5929. /// <returns></returns>
  5930. [HttpPost]
  5931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5932. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  5933. {
  5934. try
  5935. {
  5936. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  5937. if (data.Code != 0)
  5938. {
  5939. return Ok(JsonView(false, data.Msg));
  5940. }
  5941. return Ok(JsonView(true, "操作成功!", data.Data));
  5942. }
  5943. catch (Exception ex)
  5944. {
  5945. return Ok(JsonView(false, ex.Message));
  5946. }
  5947. }
  5948. /// <summary>
  5949. /// 团组模块 - 出入境国家费用标准 - Del
  5950. /// </summary>
  5951. /// <returns></returns>
  5952. [HttpPost]
  5953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5954. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  5955. {
  5956. try
  5957. {
  5958. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  5959. {
  5960. Id = dto.Id,
  5961. DeleteUserId = dto.DeleteUserId,
  5962. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5963. IsDel = 1
  5964. };
  5965. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  5966. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  5967. .WhereColumns(it => new { it.Id })
  5968. .ExecuteCommandAsync();
  5969. if (delStatus <= 0)
  5970. {
  5971. return Ok(JsonView(false, "删除失败!"));
  5972. }
  5973. return Ok(JsonView(true, "操作成功!"));
  5974. }
  5975. catch (Exception ex)
  5976. {
  5977. return Ok(JsonView(false, ex.Message));
  5978. }
  5979. }
  5980. /// <summary>
  5981. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  5982. /// 注:Get 请求Headers 加 Token
  5983. /// </summary>
  5984. /// <param name="groupId"></param>
  5985. /// <returns></returns>
  5986. [HttpGet("{groupId}")]
  5987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5988. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  5989. {
  5990. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5991. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  5992. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  5993. data.ForEach(x =>
  5994. {
  5995. x.CreateUserId = _currUserInfo.UserId;
  5996. });
  5997. if (data.Count > 0)
  5998. {
  5999. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6000. if (add > 0)
  6001. {
  6002. return Ok(JsonView(true, "操作成功!"));
  6003. }
  6004. }
  6005. return Ok(JsonView(false, "未操作!"));
  6006. }
  6007. #endregion
  6008. #region 签证费用录入
  6009. /// <summary>
  6010. /// 根据diid查询签证费用列表
  6011. /// </summary>
  6012. /// <param name="dto"></param>
  6013. /// <returns></returns>
  6014. [HttpPost]
  6015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6016. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  6017. {
  6018. try
  6019. {
  6020. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  6021. if (groupData.Code != 0)
  6022. {
  6023. return Ok(JsonView(false, groupData.Msg));
  6024. }
  6025. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6026. }
  6027. catch (Exception ex)
  6028. {
  6029. return Ok(JsonView(false, ex.Message));
  6030. }
  6031. }
  6032. /// <summary>
  6033. /// 根据签证费用Id查询单条数据及c表数据
  6034. /// </summary>
  6035. /// <param name="dto"></param>
  6036. /// <returns></returns>
  6037. [HttpPost]
  6038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6039. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  6040. {
  6041. try
  6042. {
  6043. Result groupData = await _visaPriceRep.PostVisaById(dto);
  6044. if (groupData.Code != 0)
  6045. {
  6046. return Ok(JsonView(false, groupData.Msg));
  6047. }
  6048. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6049. }
  6050. catch (Exception ex)
  6051. {
  6052. return Ok(JsonView(false, ex.Message));
  6053. }
  6054. }
  6055. /// <summary>
  6056. /// 签证费用删除
  6057. /// </summary>
  6058. /// <param name="dto"></param>
  6059. /// <returns></returns>
  6060. [HttpPost]
  6061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6062. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  6063. {
  6064. _sqlSugar.BeginTran();
  6065. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  6066. if (!res)
  6067. {
  6068. _sqlSugar.RollbackTran();
  6069. return Ok(JsonView(false, "删除失败"));
  6070. }
  6071. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  6072. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  6073. .SetColumns(a => new Grp_CreditCardPayment()
  6074. {
  6075. IsDel = 1,
  6076. DeleteUserId = dto.DeleteUserId,
  6077. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6078. })
  6079. .ExecuteCommand();
  6080. if (resSub < 1)
  6081. {
  6082. _sqlSugar.RollbackTran();
  6083. return Ok(JsonView(false, "删除失败"));
  6084. }
  6085. _sqlSugar.CommitTran();
  6086. return Ok(JsonView(true, "删除成功!"));
  6087. }
  6088. /// <summary>
  6089. /// 签证费用录入下拉框初始化
  6090. /// </summary>
  6091. /// <returns></returns>
  6092. [HttpPost]
  6093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6094. public async Task<IActionResult> VisaPriceAddSelect()
  6095. {
  6096. //支付方式
  6097. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  6098. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  6099. //币种
  6100. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  6101. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  6102. //乘客类型
  6103. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  6104. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  6105. //卡类型
  6106. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  6107. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  6108. var data = new
  6109. {
  6110. Payment = _Payment,
  6111. CurrencyList = _CurrencyList,
  6112. PassengerType = _PassengerType,
  6113. BankCard = _BankCard
  6114. };
  6115. return Ok(JsonView(true, "查询成功!", data));
  6116. }
  6117. /// <summary>
  6118. /// 签证费用录入操作(Status:1.新增,2.修改)
  6119. /// </summary>
  6120. /// <param name="dto"></param>
  6121. /// <returns></returns>
  6122. [HttpPost]
  6123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6124. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  6125. {
  6126. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  6127. if (groupData.Code != 0)
  6128. {
  6129. return Ok(JsonView(false, groupData.Msg));
  6130. }
  6131. #region 应用推送
  6132. try
  6133. {
  6134. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6135. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6136. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6137. }
  6138. catch (Exception ex)
  6139. {
  6140. }
  6141. #endregion
  6142. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6143. }
  6144. #endregion
  6145. #region 签证提成录入
  6146. /// <summary>
  6147. /// 签证提成录入
  6148. /// 基础数据
  6149. /// </summary>
  6150. /// <param name="_dto"></param>
  6151. /// <returns></returns>
  6152. [HttpGet]
  6153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6154. public async Task<IActionResult> VisaCommissionInit()
  6155. {
  6156. return Ok(await _visaCommissionRep.Init());
  6157. }
  6158. /// <summary>
  6159. /// 签证提成录入
  6160. /// Item
  6161. /// </summary>
  6162. /// <param name="_dto"></param>
  6163. /// <returns></returns>
  6164. [HttpPost]
  6165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6166. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  6167. {
  6168. var validator = new VisaCommissionItemDtoValidator();
  6169. var validatorRes = await validator.ValidateAsync(_dto);
  6170. if (!validatorRes.IsValid)
  6171. {
  6172. StringBuilder sb = new StringBuilder();
  6173. foreach (var item in validatorRes.Errors)
  6174. {
  6175. sb.AppendLine(item.ErrorMessage);
  6176. }
  6177. return Ok(JsonView(false, sb.ToString()));
  6178. }
  6179. return Ok(await _visaCommissionRep.Item(_dto));
  6180. }
  6181. /// <summary>
  6182. /// 签证提成录入
  6183. /// Save
  6184. /// </summary>
  6185. /// <param name="_dto"></param>
  6186. /// <returns></returns>
  6187. [HttpPost]
  6188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6189. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  6190. {
  6191. //参数验证
  6192. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  6193. foreach (var item in _dto.Items)
  6194. {
  6195. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  6196. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  6197. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  6198. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  6199. }
  6200. return Ok(await _visaCommissionRep.Save(_dto));
  6201. }
  6202. /// <summary>
  6203. /// 签证提成录入
  6204. /// Create
  6205. /// </summary>
  6206. /// <param name="_dto"></param>
  6207. /// <returns></returns>
  6208. [HttpPost]
  6209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6210. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  6211. {
  6212. var validator = new VisaCommissionCreateDtoValidator();
  6213. var validatorRes = await validator.ValidateAsync(_dto);
  6214. if (!validatorRes.IsValid)
  6215. {
  6216. StringBuilder sb = new StringBuilder();
  6217. foreach (var item in validatorRes.Errors)
  6218. {
  6219. sb.AppendLine(item.ErrorMessage);
  6220. }
  6221. return Ok(JsonView(false, sb.ToString()));
  6222. }
  6223. return Ok(await _visaCommissionRep.Create(_dto));
  6224. }
  6225. /// <summary>
  6226. /// 签证提成录入
  6227. /// Put(编辑)
  6228. /// </summary>
  6229. /// <param name="id"></param>
  6230. /// <param name="_dto"></param>
  6231. /// <returns></returns>
  6232. [HttpPut]
  6233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6234. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  6235. {
  6236. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6237. var validator = new VisaCommissionCreateDtoValidator();
  6238. var validatorRes = await validator.ValidateAsync(_dto);
  6239. if (!validatorRes.IsValid)
  6240. {
  6241. StringBuilder sb = new StringBuilder();
  6242. foreach (var item in validatorRes.Errors)
  6243. {
  6244. sb.AppendLine(item.ErrorMessage);
  6245. }
  6246. return Ok(JsonView(false, sb.ToString()));
  6247. }
  6248. return Ok(await _visaCommissionRep.Edit(id, _dto));
  6249. }
  6250. /// <summary>
  6251. /// 签证提成录入
  6252. /// Del
  6253. /// </summary>
  6254. /// <param name="id"></param>
  6255. /// <param name="currUserId"></param>
  6256. /// <returns></returns>
  6257. [HttpPost]
  6258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6259. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  6260. {
  6261. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6262. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  6263. return Ok(await _visaCommissionRep.Del(id, currUserId));
  6264. }
  6265. #endregion
  6266. #region op费用录入
  6267. /// <summary>
  6268. /// 根据diid查询op费用列表
  6269. /// </summary>
  6270. /// <param name="dto"></param>
  6271. /// <returns></returns>
  6272. [HttpPost]
  6273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6274. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  6275. {
  6276. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  6277. if (groupData.Code != 0)
  6278. {
  6279. return Ok(JsonView(false, groupData.Msg));
  6280. }
  6281. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6282. }
  6283. /// <summary>
  6284. /// 根据op费用Id查询单条数据及c表数据
  6285. /// </summary>
  6286. /// <param name="dto"></param>
  6287. /// <returns></returns>
  6288. [HttpPost]
  6289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6290. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  6291. {
  6292. try
  6293. {
  6294. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  6295. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  6296. var data = new
  6297. {
  6298. CarTouristGuideGround = _groupData,
  6299. CreditCardPayment = _creditCardPayment
  6300. };
  6301. return Ok(JsonView(true, "查询成功!", data));
  6302. }
  6303. catch (Exception ex)
  6304. {
  6305. return Ok(JsonView(false, "程序错误!"));
  6306. }
  6307. }
  6308. /// <summary>
  6309. /// op费用删除
  6310. /// </summary>
  6311. /// <param name="dto"></param>
  6312. /// <returns></returns>
  6313. [HttpPost]
  6314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6315. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  6316. {
  6317. try
  6318. {
  6319. _sqlSugar.BeginTran();
  6320. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  6321. if (!res)
  6322. {
  6323. return Ok(JsonView(false, "删除失败"));
  6324. }
  6325. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  6326. {
  6327. IsDel = 1,
  6328. DeleteUserId = dto.DeleteUserId,
  6329. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6330. }).ExecuteCommandAsync();
  6331. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  6332. {
  6333. IsDel = 1,
  6334. DeleteUserId = dto.DeleteUserId,
  6335. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6336. }).ExecuteCommandAsync();
  6337. #region 删除超支相关数据
  6338. //删除导入的超支数据
  6339. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  6340. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  6341. {
  6342. IsDel = 1,
  6343. DeleteUserId = dto.DeleteUserId,
  6344. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6345. }).ExecuteCommand();
  6346. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  6347. {
  6348. IsDel = 1,
  6349. DeleteUserId = dto.DeleteUserId,
  6350. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6351. }).ExecuteCommand();
  6352. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  6353. {
  6354. IsDel = 1,
  6355. DeleteUserId = dto.DeleteUserId,
  6356. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6357. }).ExecuteCommand();
  6358. #endregion
  6359. _sqlSugar.CommitTran();
  6360. return Ok(JsonView(true, "删除成功!"));
  6361. }
  6362. catch (Exception ex)
  6363. {
  6364. _sqlSugar.RollbackTran();
  6365. return Ok(JsonView(false, "程序错误!" + ex.Message));
  6366. }
  6367. }
  6368. /// <summary>
  6369. /// op费用录入操作(Status:1.新增,2.修改)
  6370. /// </summary>
  6371. /// <param name="dto"></param>
  6372. /// <returns></returns>
  6373. [HttpPost]
  6374. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6375. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  6376. {
  6377. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  6378. if (groupData.Code != 0)
  6379. {
  6380. return Ok(JsonView(false, groupData.Msg));
  6381. }
  6382. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6383. }
  6384. /// <summary>
  6385. /// 填写费用详细页面初始化绑定
  6386. /// </summary>
  6387. /// <param name="dto"></param>
  6388. /// <returns></returns>
  6389. [HttpPost]
  6390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6391. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  6392. {
  6393. try
  6394. {
  6395. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  6396. if (groupData.Code != 0)
  6397. {
  6398. return Ok(JsonView(false, groupData.Msg));
  6399. }
  6400. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6401. }
  6402. catch (Exception ex)
  6403. {
  6404. return Ok(JsonView(false, ex.Message));
  6405. }
  6406. }
  6407. /// <summary>
  6408. /// 根据op费用Id查询详细数据
  6409. /// </summary>
  6410. /// <param name="dto"></param>
  6411. /// <returns></returns>
  6412. [HttpPost]
  6413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6414. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  6415. {
  6416. try
  6417. {
  6418. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  6419. if (groupData.Code != 0)
  6420. {
  6421. return Ok(JsonView(false, groupData.Msg));
  6422. }
  6423. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6424. }
  6425. catch (Exception ex)
  6426. {
  6427. return Ok(JsonView(false, ex.Message));
  6428. }
  6429. }
  6430. /// <summary>
  6431. /// OP费用录入填写详情
  6432. /// </summary>
  6433. /// <param name="dto"></param>
  6434. /// <returns></returns>
  6435. [HttpPost]
  6436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6437. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  6438. {
  6439. try
  6440. {
  6441. #region 参数校验
  6442. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  6443. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  6444. if (di == null) return Ok(JsonView(false, "团组错误!"));
  6445. #endregion
  6446. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  6447. if (groupData.Code != 0)
  6448. {
  6449. return Ok(JsonView(false, groupData.Msg));
  6450. }
  6451. //自动审核
  6452. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  6453. #region 应用推送
  6454. try
  6455. {
  6456. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6457. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6458. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6459. }
  6460. catch (Exception ex)
  6461. {
  6462. }
  6463. #endregion
  6464. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6465. }
  6466. catch (Exception ex)
  6467. {
  6468. return Ok(JsonView(false, ex.Message));
  6469. }
  6470. }
  6471. /// <summary>
  6472. /// 获取三公详细所有城市
  6473. /// </summary>
  6474. /// <returns></returns>
  6475. [HttpGet]
  6476. public IActionResult OpCarCityResult()
  6477. {
  6478. var jw = JsonView(false);
  6479. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  6480. {
  6481. x.Id,
  6482. x.Country,
  6483. x.City,
  6484. }).ToList();
  6485. if (data.Count > 0)
  6486. {
  6487. jw = JsonView(true, "获取成功!", data);
  6488. }
  6489. else
  6490. {
  6491. jw.Msg = "城市数据为空!";
  6492. jw.Data = new string[0];
  6493. }
  6494. return Ok(jw);
  6495. }
  6496. /// <summary>
  6497. /// 导出地接费用明细
  6498. /// </summary>
  6499. /// <param name="dto"></param>
  6500. /// <returns></returns>
  6501. [HttpPost]
  6502. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  6503. {
  6504. var jw = JsonView(false);
  6505. if (dto.Diid < 1)
  6506. {
  6507. jw.Msg = "请输入正确的diid!";
  6508. return Ok(jw);
  6509. }
  6510. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6511. if (group == null)
  6512. {
  6513. jw.Msg = "未找到团组信息!";
  6514. return Ok(jw);
  6515. }
  6516. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  6517. if (localGuideArr.Count == 0)
  6518. {
  6519. jw.Msg = "该团组暂无地接信息!";
  6520. return Ok(jw);
  6521. }
  6522. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  6523. var overspendSoure = new Dictionary<int, int>
  6524. {
  6525. { 91, 982 }, //车
  6526. { 92 , 1059} ,//导游
  6527. { 994 , 1073}, //翻译
  6528. { 988 , 1074 }, //早餐
  6529. { 93 , 1075 }, //午餐
  6530. { 989 , 1076 }, //晚餐
  6531. };
  6532. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  6533. foreach (var groupArr in localGroup)
  6534. {
  6535. var keyValue = groupArr.Key;
  6536. if (int.TryParse(keyValue, out int cityid))
  6537. {
  6538. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  6539. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  6540. }
  6541. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  6542. foreach (var item in groupArr)
  6543. {
  6544. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  6545. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  6546. new Grp_CarTouristGuideGroundReservationsContentExtend
  6547. {
  6548. Count = a.Count,
  6549. CreateTime = a.CreateTime,
  6550. CreateUserId = a.CreateUserId,
  6551. CTGGRId = a.CTGGRId,
  6552. Currency = a.Currency,
  6553. DatePrice = a.DatePrice,
  6554. DeleteTime = a.DeleteTime,
  6555. DeleteUserId = a.DeleteUserId,
  6556. DiId = a.DiId,
  6557. Id = a.Id,
  6558. IsDel = a.IsDel,
  6559. Price = a.Price,
  6560. PriceContent = a.PriceContent,
  6561. Remark = a.Remark,
  6562. SId = a.SId,
  6563. SidName = b.Name,
  6564. Units = a.Units,
  6565. }
  6566. ).ToList();
  6567. if (content.Count > 0)
  6568. {
  6569. contentArr.Add(content);
  6570. }
  6571. }
  6572. //open excel
  6573. //set excel
  6574. //save excel
  6575. try
  6576. {
  6577. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  6578. IWorkbook workbook;
  6579. if (Path.GetExtension(filePath).ToLower() == ".xls")
  6580. {
  6581. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6582. }
  6583. else
  6584. {
  6585. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6586. }
  6587. ISheet sheet = workbook.GetSheetAt(0);
  6588. var rowStartIndex = 2;
  6589. var clounmCount = 10;
  6590. var initStyleRow = sheet.GetRow(2);
  6591. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  6592. //var overspendArrDetail =
  6593. var existsId = new List<CarCompare>();
  6594. var lastElem = arr.Last();
  6595. var thisSid = -1;
  6596. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  6597. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  6598. {
  6599. Name = "未知币种!",
  6600. Remark = "未知币种!",
  6601. };
  6602. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  6603. Action cloneRowFn = () =>
  6604. {
  6605. rowStartIndex++;
  6606. var cloneRow = sheet.CreateRow(rowStartIndex);
  6607. // 复制样式
  6608. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  6609. {
  6610. ICell sourceCell = initStyleRow.GetCell(i);
  6611. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  6612. // 确保单元格存在样式
  6613. if (sourceCell.CellStyle != null)
  6614. {
  6615. targetCell.CellStyle = sourceCell.CellStyle;
  6616. }
  6617. }
  6618. };
  6619. var mergeRow = () =>
  6620. {
  6621. for (int i = 2; i < sheet.LastRowNum; i++)
  6622. {
  6623. var row = sheet.GetRow(i);
  6624. var cellFirst = row.GetCell(0);
  6625. var thisIndex = i + 1;
  6626. while (thisIndex < sheet.LastRowNum)
  6627. {
  6628. var nextRow = sheet.GetRow(thisIndex);
  6629. var nextCellFirst = nextRow.GetCell(0);
  6630. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  6631. {
  6632. thisIndex++;
  6633. }
  6634. else
  6635. {
  6636. break;
  6637. }
  6638. }
  6639. thisIndex--;
  6640. if (thisIndex != i)
  6641. {
  6642. //合并row
  6643. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6644. i, // 起始行索引(0-based)
  6645. thisIndex, // 结束行索引(0-based)
  6646. 0, // 起始列索引(0-based)
  6647. 0 // 结束列索引(0-based)
  6648. );
  6649. sheet.AddMergedRegion(cellRangeAddress);
  6650. i = thisIndex;
  6651. }
  6652. }
  6653. };
  6654. var chaoshiNumber = 0;
  6655. var totalNumber = 0.00M;
  6656. string lastStr = "";
  6657. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  6658. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  6659. {
  6660. b.IsAuditGM,
  6661. x.Id,
  6662. x.Area,
  6663. b.PayPercentage,
  6664. b.PayMoney,
  6665. }).ToList();
  6666. string yesPayment = "", noPayment = "";
  6667. foreach (var item in queryCarArrByCityAndDiid)
  6668. {
  6669. if (item.IsAuditGM == 1)
  6670. {
  6671. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6672. }
  6673. else
  6674. {
  6675. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6676. }
  6677. }
  6678. lastStr = yesPayment + noPayment;
  6679. foreach (var item in arr)
  6680. {
  6681. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  6682. {
  6683. if (thisSid != item.SId)
  6684. {
  6685. if (thisSid == -1)
  6686. {
  6687. thisSid = item.SId;
  6688. }
  6689. else
  6690. {
  6691. //合并小计行
  6692. //创建合并区域的实例
  6693. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6694. rowStartIndex, // 起始行索引(0-based)
  6695. rowStartIndex, // 结束行索引(0-based)
  6696. 0, // 起始列索引(0-based)
  6697. 3 // 结束列索引(0-based)
  6698. );
  6699. sheet.AddMergedRegion(cellRangeAddress);
  6700. var CellStyle = workbook.CreateCellStyle();
  6701. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6702. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6703. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6704. for (int i = 0; i <= clounmCount; i++)
  6705. {
  6706. if (i > 6)
  6707. {
  6708. var CellStyle1 = workbook.CreateCellStyle();
  6709. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6710. IFont Font = workbook.CreateFont(); // 创建字体
  6711. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6712. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6713. CellStyle1.SetFont(Font);
  6714. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6715. }
  6716. else
  6717. {
  6718. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6719. }
  6720. }
  6721. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6722. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6723. //超时合计
  6724. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6725. //超时数
  6726. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6727. //超时合计费用
  6728. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6729. thisSid = item.SId;
  6730. cloneRowFn();
  6731. chaoshiNumber = 0;
  6732. totalNumber = 0;
  6733. }
  6734. }
  6735. IRow row = sheet.GetRow(rowStartIndex);
  6736. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6737. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6738. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6739. if (isOpenOverspendSoure)
  6740. {
  6741. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6742. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6743. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6744. }
  6745. for (int i = 0; i <= clounmCount; i++)
  6746. {
  6747. var cell = row.GetCell(i);
  6748. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6749. if (cell == null)
  6750. {
  6751. cell = row.CreateCell(i);
  6752. }
  6753. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6754. fontRed.CloneStyleFrom(cell.CellStyle);
  6755. IFont Font = workbook.CreateFont(); // 创建字体
  6756. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6757. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6758. fontRed.SetFont(Font);
  6759. byte[] rgb = new byte[3] { 255, 242, 204 };
  6760. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6761. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6762. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6763. if (workbook is XSSFWorkbook)
  6764. {
  6765. BackgroundColor255_242_204.FillForegroundColor = 0;
  6766. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6767. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6768. }
  6769. else
  6770. {
  6771. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6772. }
  6773. if (i == 1 || i > 6)
  6774. {
  6775. if (i > 6)
  6776. {
  6777. fontRed.FillForegroundColor = 0;
  6778. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6779. fontRed.FillPattern = FillPattern.SolidForeground;
  6780. }
  6781. cell.CellStyle = fontRed;
  6782. }
  6783. if (i > 2 && i < 7)
  6784. {
  6785. cell.CellStyle = BackgroundColor255_242_204;
  6786. }
  6787. cell.SetCellValue(setCellValue); //写入单元格
  6788. }
  6789. if (overspendSoure.ContainsKey(thisSid))
  6790. {
  6791. var overspendId = overspendSoure[thisSid];
  6792. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6793. }
  6794. cloneRowFn();
  6795. existsId.Add(new CarCompare
  6796. {
  6797. DataPrice = item.DatePrice.ObjToDate(),
  6798. Sid = item.SId
  6799. });
  6800. }
  6801. if (item.Equals(lastElem))
  6802. {
  6803. //合并小计行
  6804. //创建合并区域的实例
  6805. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6806. rowStartIndex, // 起始行索引(0-based)
  6807. rowStartIndex, // 结束行索引(0-based)
  6808. 0, // 起始列索引(0-based)
  6809. 3 // 结束列索引(0-based)
  6810. );
  6811. sheet.AddMergedRegion(cellRangeAddress);
  6812. var CellStyle = workbook.CreateCellStyle();
  6813. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6814. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6815. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6816. for (int i = 0; i <= clounmCount; i++)
  6817. {
  6818. if (i > 6)
  6819. {
  6820. var CellStyle1 = workbook.CreateCellStyle();
  6821. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6822. IFont Font = workbook.CreateFont(); // 创建字体
  6823. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6824. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6825. CellStyle1.SetFont(Font);
  6826. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6827. }
  6828. else
  6829. {
  6830. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6831. }
  6832. }
  6833. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6834. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6835. //超时合计
  6836. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6837. //超时数
  6838. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6839. //超时合计费用
  6840. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6841. cloneRowFn();
  6842. // 创建合并区域的实例
  6843. cellRangeAddress = new CellRangeAddress(
  6844. rowStartIndex, // 起始行索引(0-based)
  6845. rowStartIndex, // 结束行索引(0-based)
  6846. 0, // 起始列索引(0-based)
  6847. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  6848. );
  6849. // 添加合并区域
  6850. sheet.AddMergedRegion(cellRangeAddress);
  6851. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  6852. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  6853. }
  6854. }
  6855. mergeRow();
  6856. // 保存修改后的Excel文件到新文件
  6857. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  6858. // new FileStream(newFilePath, FileMode.CreateNew)
  6859. using (var stream = new MemoryStream())
  6860. {
  6861. workbook.Write(stream, true);
  6862. stream.Flush();
  6863. stream.Seek(0, SeekOrigin.Begin);
  6864. MemoryStream memoryStream = new MemoryStream();
  6865. stream.CopyTo(memoryStream);
  6866. memoryStream.Seek(0, SeekOrigin.Begin);
  6867. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  6868. }
  6869. workbook.Close();
  6870. workbook.Dispose();
  6871. }
  6872. catch (Exception ex)
  6873. {
  6874. jw.Msg = "出现异常!" + ex.Message;
  6875. return Ok(jw);
  6876. }
  6877. }
  6878. if (Zips.Count > 0)
  6879. {
  6880. IOOperatorHelper io = new IOOperatorHelper();
  6881. var byts = io.ConvertZipStream(Zips);
  6882. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  6883. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  6884. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  6885. }
  6886. else
  6887. {
  6888. jw.Msg = "暂无生成文件!";
  6889. }
  6890. return Ok(jw);
  6891. }
  6892. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  6893. {
  6894. string outStr = string.Empty;
  6895. switch (i)
  6896. {
  6897. case 0:
  6898. outStr = arr[0].SidName;
  6899. break;
  6900. case 1:
  6901. outStr = arr[0].DataPriceStr;
  6902. break;
  6903. case 2:
  6904. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  6905. break;
  6906. case 4:
  6907. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  6908. break;
  6909. case 7:
  6910. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6911. {
  6912. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  6913. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  6914. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  6915. }
  6916. break;
  6917. case 8:
  6918. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6919. {
  6920. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  6921. }
  6922. break;
  6923. case 9:
  6924. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6925. {
  6926. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  6927. }
  6928. break;
  6929. case 10:
  6930. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6931. {
  6932. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  6933. }
  6934. break;
  6935. }
  6936. return outStr;
  6937. }
  6938. #region OP行程单
  6939. /// <summary>
  6940. /// OP行程单初始化
  6941. /// </summary>
  6942. /// <param name="dto"></param>
  6943. /// <returns></returns>
  6944. [HttpPost]
  6945. public IActionResult InitOpTravel(InitOpTravelDto dto)
  6946. {
  6947. var jw = JsonView(false);
  6948. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  6949. var group = groupList.First();
  6950. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  6951. if (group == null)
  6952. {
  6953. jw.Msg = "暂无团组!";
  6954. return Ok(jw);
  6955. }
  6956. group = groupList.Find(x => x.Id == diid);
  6957. if (group == null)
  6958. {
  6959. jw.Msg = "请输入正确的团组ID!";
  6960. return Ok(jw);
  6961. }
  6962. string city = string.Empty;
  6963. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  6964. if (blackCode.Count > 0)
  6965. {
  6966. var black = blackCode.First();
  6967. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  6968. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  6969. if (blackSp.Length > 0)
  6970. {
  6971. try
  6972. {
  6973. var cityArrCode = new List<string>(20);
  6974. foreach (var item in blackSp)
  6975. {
  6976. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  6977. var IndexSelect = itemSp[2];
  6978. var cityArrCodeLength = cityArrCode.Count - 1;
  6979. var startCity = IndexSelect.Substring(0, 3);
  6980. if (cityArrCodeLength > 0)
  6981. {
  6982. var arrEndCity = cityArrCode[cityArrCodeLength];
  6983. if (arrEndCity != startCity)
  6984. {
  6985. cityArrCode.Add(startCity.ToUpper());
  6986. }
  6987. }
  6988. else
  6989. {
  6990. cityArrCode.Add(startCity.ToUpper());
  6991. }
  6992. var endCity = IndexSelect.Substring(3, 3);
  6993. cityArrCode.Add(endCity.ToUpper());
  6994. }
  6995. var cityThree = string.Empty;
  6996. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  6997. cityThree = cityThree.TrimEnd(',');
  6998. if (string.IsNullOrWhiteSpace(cityThree))
  6999. {
  7000. throw new
  7001. Exception("error");
  7002. }
  7003. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  7004. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  7005. foreach (var item in cityArrCode)
  7006. {
  7007. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  7008. if (find != null)
  7009. {
  7010. city += find.City + "/";
  7011. }
  7012. else
  7013. {
  7014. city += item + "三字码未收入/";
  7015. }
  7016. }
  7017. city = city.TrimEnd('/');
  7018. }
  7019. catch (Exception e)
  7020. {
  7021. city = "黑屏代码格式不正确!";
  7022. }
  7023. }
  7024. }
  7025. else
  7026. {
  7027. city = "未录入黑屏代码";
  7028. }
  7029. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  7030. {
  7031. Date = x.Date,
  7032. Days = x.Days,
  7033. Diffgroup = x.Diffgroup,
  7034. Diid = x.Diid,
  7035. Traffic_First = x.Traffic_First,
  7036. Traffic_Second = x.Traffic_Second,
  7037. Trip = x.Trip,
  7038. WeekDay = x.WeekDay,
  7039. Id = x.Id
  7040. }).ToList();
  7041. jw.Data = new
  7042. {
  7043. groupList = groupList.Select(x => new
  7044. {
  7045. x.Id,
  7046. x.TeamName,
  7047. x.TourCode
  7048. }).ToList(),
  7049. groupInfo = new
  7050. {
  7051. group.VisitDays,
  7052. group.TourCode,
  7053. group.VisitPNumber,
  7054. group.TeamName,
  7055. city
  7056. },
  7057. OpTravelList
  7058. };
  7059. jw.Code = 200;
  7060. jw.Msg = "操作成功!";
  7061. return Ok(jw);
  7062. }
  7063. /// <summary>
  7064. /// 删除团组行程单
  7065. /// </summary>
  7066. /// <returns></returns>
  7067. [HttpPost]
  7068. public IActionResult DelTravel(DelOpTravelDto dto)
  7069. {
  7070. var jw = JsonView(false);
  7071. if (dto.UserId <= 0 || dto.Diid <= 0)
  7072. {
  7073. jw.Msg = "请输入正确的参数!";
  7074. return Ok(jw);
  7075. }
  7076. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  7077. .SetColumns(x => new Grp_TravelList
  7078. {
  7079. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7080. DeleteUserId = dto.UserId,
  7081. IsDel = 1,
  7082. }).ExecuteCommand();
  7083. jw = JsonView(true);
  7084. return Ok(jw);
  7085. }
  7086. /// <summary>
  7087. /// 行程单保存
  7088. /// </summary>
  7089. /// <returns></returns>
  7090. [HttpPost]
  7091. public IActionResult TravelSave(TravelSaveDto dto)
  7092. {
  7093. var jw = JsonView(false);
  7094. if (dto.Arr.Count > 0)
  7095. {
  7096. try
  7097. {
  7098. _sqlSugar.BeginTran();
  7099. foreach (var item in dto.Arr)
  7100. {
  7101. if (item.Id == 0)
  7102. {
  7103. throw new Exception("请传入正确的Id");
  7104. }
  7105. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  7106. .SetColumns(x => new Grp_TravelList
  7107. {
  7108. Trip = item.Trip
  7109. }).ExecuteCommand();
  7110. }
  7111. _sqlSugar.CommitTran();
  7112. jw = JsonView(true);
  7113. }
  7114. catch (Exception ex)
  7115. {
  7116. _sqlSugar.RollbackTran();
  7117. jw.Msg = "程序异常!" + ex.Message;
  7118. }
  7119. }
  7120. else
  7121. {
  7122. jw.Msg = "请传入正确的参数!";
  7123. }
  7124. return Ok(jw);
  7125. }
  7126. /// <summary>
  7127. /// 导出行程单
  7128. /// </summary>
  7129. /// <param name="dto"></param>
  7130. /// <returns></returns>
  7131. [HttpPost]
  7132. public IActionResult ExportTravel(ExportTravelDto dto)
  7133. {
  7134. var jw = JsonView(false);
  7135. jw.Data = "";
  7136. int diid = 0;
  7137. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  7138. if (Find == null)
  7139. {
  7140. jw.Msg = "请选择正确的团组!";
  7141. return Ok(jw);
  7142. }
  7143. else
  7144. {
  7145. diid = Find.Id;
  7146. }
  7147. //数据源
  7148. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  7149. DataTable dtBlack = null;
  7150. try
  7151. {
  7152. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  7153. }
  7154. catch (Exception)
  7155. {
  7156. jw.Msg = "机票黑屏代码有误!";
  7157. return Ok(jw);
  7158. }
  7159. string CityStr = string.Empty;
  7160. if (dtBlack.Rows.Count == 0)
  7161. {
  7162. jw.Msg = "机票黑屏代码有误!";
  7163. return Ok(jw);
  7164. }
  7165. else
  7166. {
  7167. foreach (DataRow row in dtBlack.Rows)
  7168. {
  7169. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  7170. {
  7171. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  7172. return Ok(jw);
  7173. }
  7174. }
  7175. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  7176. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  7177. }
  7178. //创建数据源Table
  7179. DataTable dtSource = new DataTable();
  7180. dtSource.Columns.Add("Days", typeof(string));
  7181. dtSource.Columns.Add("Date", typeof(string));
  7182. dtSource.Columns.Add("Week", typeof(string));
  7183. dtSource.Columns.Add("Traffic", typeof(string));
  7184. dtSource.Columns.Add("Trip", typeof(string));
  7185. //获取数据,放到datatable
  7186. foreach (var item in _travelList)
  7187. {
  7188. DataRow dr = dtSource.NewRow();
  7189. dr["Days"] = item.Days;
  7190. dr["Date"] = item.Date;
  7191. dr["Week"] = item.WeekDay;
  7192. dr["Traffic"] = item.Traffic_First
  7193. + "\r\n"
  7194. + item.Traffic_Second;
  7195. dr["Trip"] = item.Trip;
  7196. dtSource.Rows.Add(dr);
  7197. }
  7198. Dictionary<string, string> dic = new Dictionary<string, string>();
  7199. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  7200. dic.Add("City", CityStr);
  7201. dic.Add("Days", Find.VisitDays.ToString());
  7202. dic.Add("DeleCode", Find.TourCode);
  7203. dic.Add("Pnum", Find.VisitPNumber.ToString());
  7204. //模板路径
  7205. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  7206. //载入模板
  7207. Document doc = null;
  7208. DocumentBuilder builder = null;
  7209. try
  7210. {
  7211. //载入模板
  7212. doc = new Document(tempPath);
  7213. builder = new DocumentBuilder(doc);
  7214. }
  7215. catch (Exception)
  7216. {
  7217. jw.Msg = "模板位置不存在!";
  7218. return Ok(jw);
  7219. }
  7220. foreach (var key in dic.Keys)
  7221. {
  7222. Bookmark bookmark = doc.Range.Bookmarks[key];
  7223. if (bookmark != null)
  7224. {
  7225. builder.MoveToBookmark(key);
  7226. builder.Write(dic[key]);
  7227. }
  7228. }
  7229. //获取word里所有表格
  7230. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7231. //获取所填表格的序数
  7232. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7233. try
  7234. {
  7235. //循环赋值
  7236. for (int i = 0; i < dtSource.Rows.Count; i++)
  7237. {
  7238. builder.MoveToCell(0, i + 1, 0, 0);
  7239. builder.Write(dtSource.Rows[i]["Days"].ToString());
  7240. builder.MoveToCell(0, i + 1, 1, 0);
  7241. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  7242. builder.MoveToCell(0, i + 1, 2, 0);
  7243. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  7244. var trip = dtSource.Rows[i]["Trip"].ToString();
  7245. builder.MoveToCell(0, i + 1, 3, 0);
  7246. builder.Write(trip);
  7247. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  7248. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7249. // 获取特定索引的段落
  7250. Paragraph paragraph = (Paragraph)paragraphs[0];
  7251. Run run = paragraph.Runs[0];
  7252. Aspose.Words.Font font = run.Font;
  7253. font.Name = "黑体";
  7254. //设置双休红色
  7255. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  7256. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7257. paragraph = (Paragraph)paragraphs[1];
  7258. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  7259. {
  7260. run = paragraph.Runs[0];
  7261. font = run.Font;
  7262. font.Color = Color.Red;
  7263. }
  7264. }
  7265. }
  7266. catch (Exception ex)
  7267. {
  7268. }
  7269. //删除多余行
  7270. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  7271. {
  7272. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  7273. }
  7274. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  7275. if (!Directory.Exists(savePath))
  7276. {
  7277. try
  7278. {
  7279. Directory.CreateDirectory(savePath);
  7280. }
  7281. catch
  7282. {
  7283. }
  7284. }
  7285. string path = savePath + Find.TeamName + "出访日程";
  7286. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  7287. try
  7288. {
  7289. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  7290. string postfix = ".docx";
  7291. if (dto.IsPDF == 1)
  7292. {
  7293. saveFormat = Aspose.Words.SaveFormat.Pdf;
  7294. postfix = ".pdf";
  7295. }
  7296. doc.Save(path + postfix, saveFormat);
  7297. jw = JsonView(true, "导出成功", ftpPath + postfix);
  7298. }
  7299. catch (Exception)
  7300. {
  7301. jw = JsonView(false);
  7302. }
  7303. return Ok(jw);
  7304. }
  7305. /// <summary>
  7306. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  7307. /// </summary>
  7308. /// <param name="num"></param>
  7309. /// <returns></returns>
  7310. string GetNum(string num)
  7311. {
  7312. string str = "";
  7313. switch (num)
  7314. {
  7315. case "1":
  7316. str = "一";
  7317. break;
  7318. case "2":
  7319. str = "二";
  7320. break;
  7321. case "3":
  7322. str = "三";
  7323. break;
  7324. case "4":
  7325. str = "四";
  7326. break;
  7327. case "5":
  7328. str = "五";
  7329. break;
  7330. case "6":
  7331. str = "六";
  7332. break;
  7333. case "7":
  7334. str = "七";
  7335. break;
  7336. case "8":
  7337. str = "八";
  7338. break;
  7339. case "9":
  7340. str = "九";
  7341. break;
  7342. case "10":
  7343. str = "十";
  7344. break;
  7345. case "11":
  7346. str = "十一";
  7347. break;
  7348. case "12":
  7349. str = "十二";
  7350. break;
  7351. case "一":
  7352. str = "1";
  7353. break;
  7354. case "二":
  7355. str = "2";
  7356. break;
  7357. case "三":
  7358. str = "3";
  7359. break;
  7360. case "四":
  7361. str = "4";
  7362. break;
  7363. case "五":
  7364. str = "5";
  7365. break;
  7366. case "六":
  7367. str = "6";
  7368. break;
  7369. case "七":
  7370. str = "7";
  7371. break;
  7372. case "八":
  7373. str = "8";
  7374. break;
  7375. case "九":
  7376. str = "9";
  7377. break;
  7378. case "十":
  7379. str = "10";
  7380. break;
  7381. case "十一":
  7382. str = "11";
  7383. break;
  7384. case "十二":
  7385. str = "12";
  7386. break;
  7387. }
  7388. return str;
  7389. }
  7390. #endregion
  7391. #endregion
  7392. #region 团组成本
  7393. /// <summary>
  7394. /// 团组成本数据初始化
  7395. /// </summary>
  7396. /// <param name="dto"></param>
  7397. /// <returns></returns>
  7398. [HttpPost]
  7399. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  7400. {
  7401. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  7402. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  7403. WHEN COUNT(*) >= 0 THEN 'True'
  7404. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  7405. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  7406. ").ToList(); //团组列表
  7407. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  7408. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  7409. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  7410. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  7411. if (groupinfoValue != null)
  7412. {
  7413. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  7414. var spArr = new string[1] { countryArr };
  7415. if (countryArr.Contains("|"))
  7416. {
  7417. spArr = countryArr.Split("|");
  7418. }
  7419. else if (countryArr.Contains("、"))
  7420. {
  7421. spArr = countryArr.Split("、");
  7422. }
  7423. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  7424. {
  7425. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  7426. if (dbQueryCountry != null)
  7427. {
  7428. visaCountryInfoArr.Add(dbQueryCountry);
  7429. }
  7430. }
  7431. }
  7432. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  7433. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  7434. var create = _GroupCostRepository.
  7435. CreateGroupCostByBlackCode(dto.Diid);
  7436. if (groupCost.Count == 0 && create.Code == 0)
  7437. {
  7438. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  7439. }
  7440. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  7441. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  7442. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  7443. groupCostMap = groupCostMap.Select(x =>
  7444. {
  7445. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  7446. {
  7447. x.Date = dataForamt.ToString("yyyy-MM-dd");
  7448. }
  7449. return x;
  7450. }).ToList();
  7451. //GroupCostParameter.Add(new
  7452. // Grp_GroupCostParameter());
  7453. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  7454. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  7455. return Ok(JsonView(new
  7456. {
  7457. groupList,
  7458. groupInfo,
  7459. groupChecks,
  7460. groupCost = groupCostMap,
  7461. hotelNumber,
  7462. GroupCostParameter = GroupCostParameterMap,
  7463. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  7464. {
  7465. x.VisaCountry,
  7466. x.VisaPrice,
  7467. x.Id,
  7468. }).ToList(),
  7469. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  7470. blackCodeIsTrue = create.Code == 0 ? true : false,
  7471. hotelIsTrue = hotelIsTrue,
  7472. }));
  7473. }
  7474. /// <summary>
  7475. /// 团组成本信息保存
  7476. /// </summary>
  7477. /// <param name="dto"></param>
  7478. /// <returns></returns>
  7479. [HttpPost]
  7480. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  7481. {
  7482. if (dto.Diid <= 0 || dto.Userid <= 0)
  7483. {
  7484. return Ok(JsonView(false));
  7485. }
  7486. JsonView jw = null;
  7487. bool isTrue = false;
  7488. #region 复制团组成本
  7489. //if (dto.Diid == 2581)
  7490. //{
  7491. // dto.Diid = 2599;
  7492. // dto.CheckBoxs.ForEach(x =>
  7493. // {
  7494. // x.Diid = 2599;
  7495. // });
  7496. // dto.GroupCosts.ForEach(x =>
  7497. // {
  7498. // x.Diid = 2599;
  7499. // });
  7500. // dto.CostTypeHotelNumbers.ForEach(x =>
  7501. // {
  7502. // x.Diid = 2599;
  7503. // });
  7504. // dto.GroupCostParameters.ForEach(x =>
  7505. // {
  7506. // x.DiId = 2599;
  7507. // });
  7508. //}
  7509. #endregion
  7510. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  7511. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  7512. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  7513. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  7514. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  7515. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  7516. try
  7517. {
  7518. _sqlSugar.BeginTran();
  7519. isTrue = await _GroupCostRepository.
  7520. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  7521. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  7522. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  7523. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  7524. _sqlSugar.CommitTran();
  7525. jw = JsonView(true, "保存成功!", isTrue);
  7526. }
  7527. catch (Exception)
  7528. {
  7529. _sqlSugar.RollbackTran();
  7530. jw = JsonView(false);
  7531. }
  7532. return Ok(jw);
  7533. }
  7534. /// <summary>
  7535. /// 司兼导数据
  7536. /// </summary>
  7537. /// <param name="dto"></param>
  7538. /// <returns></returns>
  7539. [HttpPost]
  7540. public IActionResult GetCarGuides(CarGuidesDto dto)
  7541. {
  7542. JsonView jw = null;
  7543. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  7544. jw = JsonView(true, "获取成功!", Data);
  7545. return Ok(jw);
  7546. }
  7547. /// <summary>
  7548. /// 导游数据
  7549. /// </summary>
  7550. /// <param name="dto"></param>
  7551. /// <returns></returns>
  7552. [HttpPost]
  7553. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  7554. {
  7555. JsonView jw = null;
  7556. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  7557. // 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
  7558. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  7559. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  7560. jw = JsonView(true, "获取成功!", Data);
  7561. return Ok(jw);
  7562. }
  7563. /// <summary>
  7564. /// 成本车数据
  7565. /// </summary>
  7566. /// <param name="dto"></param>
  7567. /// <returns></returns>
  7568. [HttpPost]
  7569. public IActionResult GetCarInfo(CarGuidesDto dto)
  7570. {
  7571. JsonView jw = null;
  7572. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  7573. jw = JsonView(true, "获取成功!", Data);
  7574. return Ok(jw);
  7575. }
  7576. /// <summary>
  7577. /// 景点数据
  7578. /// </summary>
  7579. /// <param name="dto"></param>
  7580. /// <returns></returns>
  7581. [HttpPost]
  7582. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  7583. {
  7584. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  7585. return Ok(JsonView(true, "获取成功!", Data));
  7586. }
  7587. /// <summary>
  7588. /// 成本通知
  7589. /// </summary>
  7590. /// <param name="dto"></param>
  7591. /// <returns></returns>
  7592. [HttpPost]
  7593. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  7594. {
  7595. if (dto.Diid < 0)
  7596. {
  7597. return Ok(JsonView(false));
  7598. }
  7599. JsonView jw = null;
  7600. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  7601. if (GroupCostParameter != null)
  7602. {
  7603. int IsShare = 0;
  7604. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  7605. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  7606. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  7607. string msg = string.Empty;
  7608. if (isTrue)
  7609. {
  7610. if (IsShare == 0)
  7611. {
  7612. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  7613. }
  7614. else
  7615. {
  7616. #region 企微通知对应岗位用户
  7617. try
  7618. {
  7619. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  7620. }
  7621. catch (Exception ex)
  7622. {
  7623. }
  7624. #endregion
  7625. msg = "通知成功,其他模块操作人员可见此成本信息!";
  7626. }
  7627. jw = JsonView(isTrue, msg, new { IsShare });
  7628. }
  7629. else
  7630. {
  7631. msg = "修改失败!";
  7632. jw = JsonView(isTrue, msg);
  7633. }
  7634. }
  7635. else
  7636. {
  7637. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  7638. }
  7639. return Ok(jw);
  7640. }
  7641. /// <summary>
  7642. /// 导出报价单
  7643. /// </summary>
  7644. /// <param name="dto"></param>
  7645. /// <returns></returns>
  7646. [HttpPost]
  7647. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  7648. {
  7649. if (dto.Diid == 0)
  7650. {
  7651. return Ok(JsonView(false, "请传递团组id"));
  7652. }
  7653. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7654. if (deleInfo.Code != 0)
  7655. {
  7656. return Ok(JsonView(false, "团组信息查询失败!"));
  7657. }
  7658. var di = deleInfo.Data as DelegationInfoWebView;
  7659. if (di != null)
  7660. {
  7661. di.TeamName = di.TeamName.Replace("|", "、");
  7662. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  7663. //文件名
  7664. string strFileName = di.TeamName + "-收款账单.doc";
  7665. //获取模板
  7666. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  7667. //载入模板
  7668. Document doc = new Document(tmppath);
  7669. decimal TotalPrice = 0.00M;
  7670. string itemStr = string.Empty;
  7671. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  7672. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7673. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7674. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7675. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7676. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7677. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7678. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7679. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7680. foreach (var cost in groupCostType)
  7681. {
  7682. var List = cost.ToList();
  7683. if (cost.Key == "A")
  7684. {
  7685. foreach (var ListItem in List)
  7686. {
  7687. if (ListItem.number > 0)
  7688. {
  7689. if (ListItem.code.Contains("TBR"))
  7690. {
  7691. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7692. }
  7693. else
  7694. {
  7695. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7696. }
  7697. TotalPrice += (ListItem.number * ListItem.price);
  7698. }
  7699. }
  7700. }
  7701. else
  7702. {
  7703. itemStr = itemStr.Insert(0, "A段\r\n");
  7704. itemStr += "B段\r\n";
  7705. foreach (var ListItem in List)
  7706. {
  7707. if (ListItem.number > 0)
  7708. {
  7709. if (ListItem.code.Contains("TBR"))
  7710. {
  7711. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7712. }
  7713. else
  7714. {
  7715. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7716. }
  7717. TotalPrice += (ListItem.number * ListItem.price);
  7718. }
  7719. }
  7720. }
  7721. }
  7722. #region 替换Word模板书签内容
  7723. Dictionary<string, string> marks = new Dictionary<string, string>();
  7724. marks.Add("To", di.ClientUnit);//付款方
  7725. marks.Add("ToTel", di.TellPhone);//付款方电话
  7726. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7727. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7728. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7729. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7730. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7731. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7732. marks.Add("PayItemContent", itemStr);//详细信息
  7733. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7734. #endregion
  7735. ////注
  7736. //if (doc.Range.Bookmarks["Attention"] != null)
  7737. //{
  7738. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7739. // mark.Text = frList[0].Attention;
  7740. //}
  7741. foreach (var item in marks.Keys)
  7742. {
  7743. if (doc.Range.Bookmarks[item] != null)
  7744. {
  7745. Bookmark mark = doc.Range.Bookmarks[item];
  7746. mark.Text = marks[item];
  7747. }
  7748. }
  7749. byte[] bytes = null;
  7750. using (MemoryStream stream = new MemoryStream())
  7751. {
  7752. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7753. bytes = stream.ToArray();
  7754. }
  7755. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7756. return Ok(JsonView(true, "", new
  7757. {
  7758. Data = bytes,
  7759. strFileName,
  7760. }));
  7761. }
  7762. else
  7763. {
  7764. return Ok(JsonView(false, "团组信息不存在!"));
  7765. }
  7766. }
  7767. /// <summary>
  7768. /// 导出团组成本
  7769. /// </summary>
  7770. /// <param name="dto"></param>
  7771. /// <returns></returns>
  7772. [HttpPost]
  7773. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7774. {
  7775. var jw = JsonView(false);
  7776. if (dto.Diid == 0)
  7777. {
  7778. return Ok(JsonView(false, "请传递团组id"));
  7779. }
  7780. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7781. if (deleInfo.Code != 0)
  7782. {
  7783. return Ok(JsonView(false, "团组信息查询失败!"));
  7784. }
  7785. var di = deleInfo.Data as DelegationInfoWebView;
  7786. if (di == null)
  7787. {
  7788. return Ok(JsonView(false, "团组信息查询失败!"));
  7789. }
  7790. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7791. WorkbookDesigner designer = new WorkbookDesigner();
  7792. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7793. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7794. for (int i = 0; i < List_GC.Count; i++)
  7795. {
  7796. GroupCost_Excel gc = new GroupCost_Excel();
  7797. gc.Id = List_GC[i].Id;
  7798. gc.Diid = List_GC[i].Diid.ToString();
  7799. gc.DAY = List_GC[i].DAY;
  7800. string week = "";
  7801. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7802. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7803. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7804. gc.ITIN = List_GC[i].ITIN;
  7805. gc.CarType = List_GC[i].CarType;
  7806. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7807. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7808. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7809. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7810. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7811. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7812. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7813. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7814. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7815. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7816. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7817. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7818. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7819. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7820. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7821. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7822. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7823. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7824. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7825. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7826. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7827. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7828. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7829. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7830. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7831. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7832. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7833. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7834. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7835. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7836. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7837. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7838. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7839. List_GC1.Add(gc);
  7840. }
  7841. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7842. dt.TableName = "TB";
  7843. //报表标题等不用dt的值
  7844. designer.SetDataSource("TeamName", dto.title.TeamName);
  7845. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7846. designer.SetDataSource("Tax", dto.title.Tax);
  7847. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7848. designer.SetDataSource("Currency", dto.title.Currency);
  7849. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7850. designer.SetDataSource("Rate", dto.title.Rate);
  7851. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7852. var Aparams = hotels.Find(x => x.Type == "Default");
  7853. if (Aparams == null)
  7854. {
  7855. return Ok(jw);
  7856. }
  7857. //酒店数量
  7858. var txtSGRNumber = Aparams.SGR.ToString();
  7859. var txtTBRNumber = Aparams.TBR.ToString();
  7860. var txtJSESNumber = Aparams.JSES.ToString();
  7861. var txtSUITENumbe = Aparams.SUITE.ToString();
  7862. if (dto.costType == "B")
  7863. {
  7864. Aparams = hotels.Find(x => x.Type == "A");
  7865. var Bparams = hotels.Find(x => x.Type == "B");
  7866. if (Aparams == null || Bparams == null)
  7867. {
  7868. return Ok(jw);
  7869. }
  7870. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7871. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7872. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7873. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7874. }
  7875. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7876. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7877. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7878. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7879. var ws = designer.Workbook.Worksheets[0];
  7880. int Row = List_GC.Count;
  7881. int startIndex = 11;
  7882. int HideRows = 0;
  7883. List<int> hideRowsList = new List<int>();
  7884. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7885. #region A段left数据
  7886. var left = dto.leftInfo.Find(x => x.Type == "A");
  7887. if (left == null)
  7888. {
  7889. return Ok(jw);
  7890. }
  7891. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7892. if (leftBindData != null)
  7893. {
  7894. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7895. designer.SetDataSource("VisaRS", leftBindData.rs);
  7896. designer.SetDataSource("VisaXS", leftBindData.xs);
  7897. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7898. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7899. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7900. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7901. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7902. }
  7903. else
  7904. {
  7905. hideRowsList.Add(Row + startIndex + HideRows);
  7906. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7907. }
  7908. HideRows += 2;
  7909. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7910. if (leftBindData != null)
  7911. {
  7912. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7913. designer.SetDataSource("BXRS", leftBindData.rs);
  7914. designer.SetDataSource("BXXS", leftBindData.xs);
  7915. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7916. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7917. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7918. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7919. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7920. }
  7921. else
  7922. {
  7923. hideRowsList.Add(Row + startIndex + HideRows);
  7924. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7925. }
  7926. HideRows += 2;
  7927. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7928. if (leftBindData != null)
  7929. {
  7930. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7931. designer.SetDataSource("HSRS", leftBindData.rs);
  7932. designer.SetDataSource("HSXS", leftBindData.xs);
  7933. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7934. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7935. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7936. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7937. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7938. }
  7939. else
  7940. {
  7941. hideRowsList.Add(Row + startIndex + HideRows);
  7942. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7943. }
  7944. HideRows += 2;
  7945. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7946. if (leftBindData != null)
  7947. {
  7948. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7949. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7950. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7951. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7952. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7953. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7954. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7955. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7956. }
  7957. else
  7958. {
  7959. hideRowsList.Add(Row + startIndex + HideRows);
  7960. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7961. }
  7962. HideRows += 2;
  7963. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7964. if (leftBindData != null)
  7965. {
  7966. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7967. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7968. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7969. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7970. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7971. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7972. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7973. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7974. }
  7975. else
  7976. {
  7977. hideRowsList.Add(Row + startIndex + HideRows);
  7978. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7979. }
  7980. HideRows += 2;
  7981. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7982. if (leftBindData != null)
  7983. {
  7984. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  7985. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  7986. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  7987. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7988. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7989. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7990. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7991. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7992. }
  7993. else
  7994. {
  7995. hideRowsList.Add(Row + startIndex + HideRows);
  7996. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7997. }
  7998. HideRows += 2;
  7999. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8000. if (leftBindData != null)
  8001. {
  8002. ////TBR
  8003. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  8004. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  8005. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  8006. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8007. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8008. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8009. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8010. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8011. }
  8012. else
  8013. {
  8014. hideRowsList.Add(Row + startIndex + HideRows);
  8015. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8016. }
  8017. HideRows += 2;
  8018. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8019. if (leftBindData != null)
  8020. {
  8021. ////SGR
  8022. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  8023. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  8024. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  8025. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8026. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8027. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8028. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8029. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8030. }
  8031. else
  8032. {
  8033. hideRowsList.Add(Row + startIndex + HideRows);
  8034. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8035. }
  8036. HideRows += 2;
  8037. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8038. if (leftBindData != null)
  8039. {
  8040. ////JS/ES
  8041. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  8042. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  8043. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  8044. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8045. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8046. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8047. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8048. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8049. }
  8050. else
  8051. {
  8052. hideRowsList.Add(Row + startIndex + HideRows);
  8053. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8054. }
  8055. HideRows += 2;
  8056. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8057. if (leftBindData != null)
  8058. {
  8059. ////SUITE
  8060. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  8061. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  8062. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  8063. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8064. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8065. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8066. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8067. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8068. }
  8069. else
  8070. {
  8071. hideRowsList.Add(Row + startIndex + HideRows);
  8072. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8073. }
  8074. HideRows += 2;
  8075. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8076. if (leftBindData != null)
  8077. {
  8078. designer.SetDataSource("DJDRCB", leftBindData.cb);
  8079. designer.SetDataSource("DJRS", leftBindData.rs);
  8080. designer.SetDataSource("DJXS", leftBindData.xs);
  8081. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8082. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8083. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8084. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8085. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8086. }
  8087. else
  8088. {
  8089. hideRowsList.Add(Row + startIndex + HideRows);
  8090. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8091. }
  8092. HideRows += 2;
  8093. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8094. if (leftBindData != null)
  8095. {
  8096. designer.SetDataSource("HCPCB", leftBindData.cb);
  8097. designer.SetDataSource("HCPRS", leftBindData.rs);
  8098. designer.SetDataSource("HCPXS", leftBindData.xs);
  8099. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8100. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8101. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8102. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8103. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8104. }
  8105. else
  8106. {
  8107. hideRowsList.Add(Row + startIndex + HideRows);
  8108. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8109. }
  8110. HideRows += 2;
  8111. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8112. if (leftBindData != null)
  8113. {
  8114. designer.SetDataSource("CPCB", leftBindData.cb);
  8115. designer.SetDataSource("CPRS", leftBindData.rs);
  8116. designer.SetDataSource("CPXS", leftBindData.xs);
  8117. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8118. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8119. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8120. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8121. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8122. }
  8123. else
  8124. {
  8125. hideRowsList.Add(Row + startIndex + HideRows);
  8126. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8127. }
  8128. HideRows += 2;
  8129. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8130. if (leftBindData != null)
  8131. {
  8132. designer.SetDataSource("GWDRCD", leftBindData.cb);
  8133. designer.SetDataSource("GWRS", leftBindData.rs);
  8134. designer.SetDataSource("GWXS", leftBindData.xs);
  8135. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8136. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8137. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8138. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8139. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8140. }
  8141. else
  8142. {
  8143. hideRowsList.Add(Row + startIndex + HideRows);
  8144. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8145. }
  8146. HideRows += 2;
  8147. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8148. if (leftBindData != null)
  8149. {
  8150. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  8151. designer.SetDataSource("LYJRS", leftBindData.rs);
  8152. designer.SetDataSource("LYJXS", leftBindData.xs);
  8153. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8154. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8155. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8156. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8157. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8158. }
  8159. else
  8160. {
  8161. hideRowsList.Add(Row + startIndex + HideRows);
  8162. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8163. }
  8164. #endregion
  8165. #region A段Right信息
  8166. var right = dto.rightInfo.Find(x => x.Type == "A");
  8167. if (right == null)
  8168. {
  8169. return Ok(jw);
  8170. }
  8171. HideRows += 4;
  8172. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8173. if (rightBindData != null)
  8174. {
  8175. //经济舱 + 双人间 TBR
  8176. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  8177. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  8178. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8179. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  8180. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8181. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8182. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8183. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8184. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8185. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8186. }
  8187. else
  8188. {
  8189. hideRowsList.Add(Row + startIndex + HideRows);
  8190. }
  8191. HideRows += 2;
  8192. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8193. if (rightBindData != null)
  8194. {
  8195. //经济舱 + 单人间 SGR
  8196. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  8197. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  8198. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8199. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  8200. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8201. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8202. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8203. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8204. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8205. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8206. }
  8207. else
  8208. {
  8209. hideRowsList.Add(Row + startIndex + HideRows);
  8210. }
  8211. HideRows += 2;
  8212. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8213. if (rightBindData != null)
  8214. {
  8215. //公务舱 + 单人间 SGR
  8216. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  8217. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  8218. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8219. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  8220. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8221. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8222. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8223. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8224. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8225. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8226. }
  8227. else
  8228. {
  8229. hideRowsList.Add(Row + startIndex + HideRows);
  8230. }
  8231. HideRows += 2;
  8232. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8233. if (rightBindData != null)
  8234. {
  8235. //公务舱 + 小套房 JSES
  8236. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  8237. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  8238. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8239. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  8240. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8241. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8242. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8243. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8244. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8245. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8246. }
  8247. else
  8248. {
  8249. hideRowsList.Add(Row + startIndex + HideRows);
  8250. }
  8251. HideRows += 2;
  8252. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8253. if (rightBindData != null)
  8254. {
  8255. //公务舱 + 小套房 JSES
  8256. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  8257. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  8258. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8259. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  8260. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8261. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8262. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8263. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8264. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8265. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8266. }
  8267. else
  8268. {
  8269. hideRowsList.Add(Row + startIndex + HideRows);
  8270. }
  8271. HideRows += 2;
  8272. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8273. if (rightBindData != null)
  8274. {
  8275. //经济舱 + 大套房
  8276. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  8277. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  8278. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8279. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  8280. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8281. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8282. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8283. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8284. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8285. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8286. }
  8287. else
  8288. {
  8289. hideRowsList.Add(Row + startIndex + HideRows);
  8290. }
  8291. HideRows += 2;
  8292. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8293. if (rightBindData != null)
  8294. {
  8295. //头等舱 + 小套房 JSES
  8296. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  8297. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  8298. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8299. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  8300. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8301. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8302. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8303. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8304. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8305. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8306. }
  8307. else
  8308. {
  8309. hideRowsList.Add(Row + startIndex + HideRows);
  8310. }
  8311. HideRows += 2;
  8312. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8313. if (rightBindData != null)
  8314. {
  8315. //头等舱 + 大套房
  8316. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  8317. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  8318. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8319. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  8320. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8321. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8322. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8323. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8324. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8325. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8326. }
  8327. else
  8328. {
  8329. hideRowsList.Add(Row + startIndex + HideRows);
  8330. }
  8331. #endregion
  8332. #region B段标题清空
  8333. designer.SetDataSource("CostBDRCB", "");
  8334. designer.SetDataSource("CostBRS", "");
  8335. designer.SetDataSource("CostBXS", "");
  8336. designer.SetDataSource("CostBZCB", "");
  8337. designer.SetDataSource("CostBDRBJ", "");
  8338. designer.SetDataSource("CostBZBJ", "");
  8339. designer.SetDataSource("CostBDRLR", "");
  8340. designer.SetDataSource("CostBZLR", "");
  8341. designer.SetDataSource("CostBDRCBOM", "");
  8342. designer.SetDataSource("CostBRSOM", "");
  8343. designer.SetDataSource("CostBZCBOM", "");
  8344. designer.SetDataSource("CostBDRBJOM", "");
  8345. designer.SetDataSource("CostBZBJOM", "");
  8346. designer.SetDataSource("CostBDRLROM", "");
  8347. designer.SetDataSource("CostBZLROM", "");
  8348. #endregion
  8349. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  8350. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  8351. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  8352. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  8353. designer.SetDataSource("DJName", "地接(CNY)");
  8354. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  8355. designer.SetDataSource("CPName", "地接-船票(CNY)");
  8356. designer.SetDataSource("GWName", "公务(CNY)");
  8357. designer.SetDataSource("YQHName", "邀请函(CNY)");
  8358. designer.SetDataSource("LYJName", "零用金(CNY)");
  8359. designer.SetDataSource("HSName", "核酸检测(CNY)");
  8360. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  8361. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  8362. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  8363. designer.SetDataSource("BXName", "保险(CNY)");
  8364. designer.SetDataSource("VisaName", "签证(CNY)");
  8365. #region B段基本数据
  8366. if (dto.costType == "B")
  8367. {
  8368. left = dto.leftInfo.Find(x => x.Type == "B");
  8369. if (left == null)
  8370. {
  8371. return Ok(jw);
  8372. }
  8373. #region B段left数据
  8374. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  8375. if (leftBindData != null)
  8376. {
  8377. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  8378. designer.SetDataSource("BHSRS", leftBindData.rs);
  8379. designer.SetDataSource("BHSXS", leftBindData.xs);
  8380. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8381. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8382. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8383. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8384. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8385. }
  8386. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8387. if (leftBindData != null)
  8388. {
  8389. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  8390. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  8391. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  8392. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8393. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8394. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8395. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8396. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8397. }
  8398. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8399. if (leftBindData != null)
  8400. {
  8401. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  8402. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  8403. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  8404. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8405. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8406. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8407. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8408. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8409. }
  8410. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8411. if (leftBindData != null)
  8412. {
  8413. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  8414. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  8415. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  8416. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8417. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8418. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8419. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8420. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8421. }
  8422. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8423. if (leftBindData != null)
  8424. {
  8425. designer.SetDataSource("BHCPCB", leftBindData.cb);
  8426. designer.SetDataSource("BHCPRS", leftBindData.rs);
  8427. designer.SetDataSource("BHCPXS", leftBindData.xs);
  8428. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8429. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8430. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8431. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8432. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8433. }
  8434. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8435. if (leftBindData != null)
  8436. {
  8437. designer.SetDataSource("BCPCB", leftBindData.cb);
  8438. designer.SetDataSource("BCPRS", leftBindData.rs);
  8439. designer.SetDataSource("BCPXS", leftBindData.xs);
  8440. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8441. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8442. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8443. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8444. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8445. }
  8446. //TBR
  8447. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8448. if (leftBindData != null)
  8449. {
  8450. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  8451. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  8452. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  8453. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8454. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8455. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8456. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8457. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8458. }
  8459. //SGR
  8460. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8461. if (leftBindData != null)
  8462. {
  8463. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  8464. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  8465. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  8466. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8467. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8468. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8469. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8470. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8471. }
  8472. //JS/ES
  8473. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8474. if (leftBindData != null)
  8475. {
  8476. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  8477. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  8478. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  8479. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8480. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8481. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8482. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8483. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8484. }
  8485. //SUITE
  8486. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8487. if (leftBindData != null)
  8488. {
  8489. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  8490. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  8491. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  8492. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8493. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8494. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8495. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8496. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8497. }
  8498. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8499. if (leftBindData != null)
  8500. {
  8501. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  8502. designer.SetDataSource("BDJRS", leftBindData.rs);
  8503. designer.SetDataSource("BDJXS", leftBindData.xs);
  8504. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8505. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8506. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8507. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8508. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8509. }
  8510. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8511. if (leftBindData != null)
  8512. {
  8513. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  8514. designer.SetDataSource("BGWRS", leftBindData.rs);
  8515. designer.SetDataSource("BGWXS", leftBindData.xs);
  8516. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8517. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8518. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8519. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8520. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8521. }
  8522. #region 优化方案
  8523. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  8524. //excelBind.Add("零用金", new {
  8525. //cb="",
  8526. //rs="",
  8527. //xs ="",
  8528. //zcb = "",
  8529. //});
  8530. #endregion
  8531. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8532. if (leftBindData != null)
  8533. {
  8534. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  8535. designer.SetDataSource("BLYJRS", leftBindData.rs);
  8536. designer.SetDataSource("BLYJXS", leftBindData.xs);
  8537. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8538. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8539. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8540. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8541. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8542. }
  8543. #endregion
  8544. #region B段Right信息
  8545. right = dto.rightInfo.Find(x => x.Type == "B");
  8546. if (right == null)
  8547. {
  8548. return Ok(jw);
  8549. }
  8550. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8551. if (rightBindData != null)
  8552. {
  8553. //经济舱 + 双人间 TBR
  8554. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  8555. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  8556. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8557. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  8558. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8559. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8560. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8561. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8562. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8563. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8564. }
  8565. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8566. if (rightBindData != null)
  8567. {
  8568. //经济舱 + 单人间 SGR
  8569. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  8570. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  8571. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8572. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  8573. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8574. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8575. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8576. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8577. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8578. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8579. }
  8580. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8581. if (rightBindData != null)
  8582. {
  8583. //公务舱 + 单人间 SGR
  8584. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  8585. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  8586. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8587. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  8588. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8589. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8590. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8591. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8592. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8593. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8594. }
  8595. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8596. if (rightBindData != null)
  8597. {
  8598. //公务舱 + 小套房 JSES
  8599. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  8600. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  8601. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8602. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  8603. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8604. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8605. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8606. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8607. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8608. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8609. }
  8610. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8611. if (rightBindData != null)
  8612. {
  8613. //公务舱 + 小套房 JSES
  8614. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  8615. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  8616. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8617. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  8618. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8619. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8620. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8621. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8622. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8623. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8624. }
  8625. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8626. if (rightBindData != null)
  8627. {
  8628. //经济舱 + 大套房
  8629. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  8630. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  8631. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8632. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  8633. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8634. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8635. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8636. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8637. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8638. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8639. }
  8640. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8641. if (rightBindData != null)
  8642. {
  8643. //头等舱 + 小套房 JSES
  8644. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  8645. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  8646. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8647. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  8648. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8649. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8650. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8651. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8652. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8653. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8654. }
  8655. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8656. if (rightBindData != null)
  8657. {
  8658. //头等舱 + 大套房
  8659. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  8660. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  8661. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8662. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  8663. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8664. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8665. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8666. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8667. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8668. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8669. }
  8670. #endregion
  8671. #region 标题
  8672. designer.SetDataSource("CostBDRCB", "单人成本");
  8673. designer.SetDataSource("CostBRS", "人数");
  8674. designer.SetDataSource("CostBXS", "系数");
  8675. designer.SetDataSource("CostBZCB", "总成本");
  8676. designer.SetDataSource("CostBDRBJ", "单人报价");
  8677. designer.SetDataSource("CostBZBJ", "总报价");
  8678. designer.SetDataSource("CostBDRLR", "单人利润");
  8679. designer.SetDataSource("CostBZLR", "总利润");
  8680. designer.SetDataSource("CostBDRCBOM", "单人成本");
  8681. designer.SetDataSource("CostBRSOM", "人数");
  8682. designer.SetDataSource("CostBZCBOM", "总成本");
  8683. designer.SetDataSource("CostBDRBJOM", "单人报价");
  8684. designer.SetDataSource("CostBZBJOM", "总报价");
  8685. designer.SetDataSource("CostBDRLROM", "单人利润");
  8686. designer.SetDataSource("CostBZLROM", "总利润");
  8687. #endregion
  8688. }
  8689. #endregion
  8690. designer.SetDataSource("TzZCB2", TzZCB2);
  8691. designer.SetDataSource("TzZBJ2", TzZBJ2);
  8692. designer.SetDataSource("TzZLR2", TzZLR2);
  8693. string[] dataSourceKeys = new string[]
  8694. {
  8695. "VF",
  8696. "TGS",
  8697. "TGOF",
  8698. "TGM",
  8699. "TGA",
  8700. "TGTF",
  8701. "TGEF",
  8702. "CFM",
  8703. "CFOF",
  8704. "B",
  8705. "L",
  8706. "D",
  8707. "TBR",
  8708. "SGR",
  8709. "JSES",
  8710. "Suite",
  8711. "TV",
  8712. "1L",
  8713. "IF",
  8714. "EF",
  8715. "BRF",
  8716. "TE",
  8717. "TGT",
  8718. "DRVT",
  8719. "PC",
  8720. "TLF",
  8721. "ECT"
  8722. };
  8723. foreach (var item in dataSourceKeys)
  8724. {
  8725. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8726. if (find != null)
  8727. {
  8728. designer.SetDataSource(item, find.text);
  8729. }
  8730. else
  8731. {
  8732. designer.SetDataSource(item, 0);
  8733. }
  8734. }
  8735. designer.SetDataSource(dt);
  8736. //根据数据源处理生成报表内容
  8737. designer.Process();
  8738. designer.Workbook.Worksheets[0].Name = "清单";
  8739. Worksheet sheet = designer.Workbook.Worksheets[0];
  8740. foreach (var Rowindex in hideRowsList)
  8741. {
  8742. ws.Cells.HideRows(Rowindex, 2);
  8743. }
  8744. byte[] bytes = null;
  8745. string strFileName = di.TeamName + "-团组-成本.xls";
  8746. using (MemoryStream stream = new MemoryStream())
  8747. {
  8748. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8749. bytes = stream.ToArray();
  8750. }
  8751. return Ok(JsonView(true, "", new
  8752. {
  8753. Data = bytes,
  8754. strFileName,
  8755. }));
  8756. }
  8757. /// <summary>
  8758. /// 导出客户报表
  8759. /// </summary>
  8760. /// <returns></returns>
  8761. [HttpPost]
  8762. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8763. {
  8764. var jw = JsonView(false);
  8765. if (dto.Diid == 0)
  8766. {
  8767. return Ok(JsonView(false, "请传递团组id"));
  8768. }
  8769. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8770. if (deleInfo.Code != 0)
  8771. {
  8772. return Ok(JsonView(false, "团组信息查询失败!"));
  8773. }
  8774. var di = deleInfo.Data as DelegationInfoWebView;
  8775. if (di == null)
  8776. {
  8777. return Ok(JsonView(false, "团组信息查询失败!"));
  8778. }
  8779. //文件名
  8780. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8781. //获取模板
  8782. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8783. //载入模板
  8784. Document doc = new Document(tmppath);
  8785. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8786. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8787. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8788. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8789. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8790. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8791. if (AParameter == null)
  8792. {
  8793. return Ok(JsonView(false, "系数不存在!"));
  8794. }
  8795. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8796. , TzAirDesc, TzZCost;
  8797. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8798. = TzAirDesc = TzZCost = string.Empty;
  8799. TzNumber = AParameter.CostTypenumber.ToString();
  8800. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8801. CarGuides1 = dto.CarGuides1;
  8802. Meal = dto.Meal;
  8803. SubsidizedMeals = dto.SubsidizedMeals;
  8804. NightRepair = dto.NightRepair;
  8805. AttractionsTickets = dto.AttractionsTickets;
  8806. MiscellaneousFees = dto.MiscellaneousFees;
  8807. ATip = dto.ATip;
  8808. TzHotelDesc = "";
  8809. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8810. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8811. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8812. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8813. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8814. TzAirDesc = "";
  8815. TzZCost = dto.TzZCost;
  8816. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8817. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8818. var index = 1;
  8819. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8820. foreach (var item in TzHotelDescArr)
  8821. {
  8822. if (AinfoArr != null)
  8823. {
  8824. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8825. if (Ainfo != null)
  8826. {
  8827. if (int.Parse(Ainfo.rs) <= 0)
  8828. {
  8829. continue;
  8830. }
  8831. var hotelText = string.Empty;
  8832. switch (item)
  8833. {
  8834. case "SGR":
  8835. hotelText = "单人间";
  8836. break;
  8837. case "JSES":
  8838. hotelText = "小套房";
  8839. break;
  8840. case "SUITE":
  8841. hotelText = "套房";
  8842. break;
  8843. case "TBR":
  8844. hotelText = "双人间";
  8845. break;
  8846. }
  8847. if (item != "TBR")
  8848. {
  8849. 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";
  8850. }
  8851. else
  8852. {
  8853. 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";
  8854. }
  8855. index++;
  8856. }
  8857. }
  8858. }
  8859. index = 1;
  8860. foreach (var item in TzAirDescArr)
  8861. {
  8862. if (AinfoArr != null)
  8863. {
  8864. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8865. if (Ainfo != null)
  8866. {
  8867. if (int.Parse(Ainfo.rs) <= 0)
  8868. {
  8869. continue;
  8870. }
  8871. 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";
  8872. index++;
  8873. }
  8874. }
  8875. }
  8876. if (dto.costType == "B")
  8877. {
  8878. if (BParameter == null)
  8879. {
  8880. return Ok(JsonView(false, "B段系数不存在!"));
  8881. }
  8882. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8883. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8884. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8885. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8886. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8887. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8888. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8889. foreach (var item in TzHotelDescArr)
  8890. {
  8891. if (AinfoArr != null)
  8892. {
  8893. TzHotelDesc += "B段信息 \r\n";
  8894. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8895. if (Ainfo != null)
  8896. {
  8897. if (int.Parse(Ainfo.rs) <= 0)
  8898. {
  8899. continue;
  8900. }
  8901. var hotelText = string.Empty;
  8902. switch (item)
  8903. {
  8904. case "SGR":
  8905. hotelText = "单人间";
  8906. break;
  8907. case "JSES":
  8908. hotelText = "小套房";
  8909. break;
  8910. case "SUITE":
  8911. hotelText = "套房";
  8912. break;
  8913. case "TBR":
  8914. hotelText = "双人间";
  8915. break;
  8916. }
  8917. if (item != "TBR")
  8918. {
  8919. 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";
  8920. }
  8921. else
  8922. {
  8923. 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";
  8924. }
  8925. index++;
  8926. }
  8927. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8928. }
  8929. }
  8930. index = 1;
  8931. foreach (var item in TzAirDescArr)
  8932. {
  8933. if (AinfoArr != null)
  8934. {
  8935. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8936. if (Ainfo != null)
  8937. {
  8938. if (int.Parse(Ainfo.rs) <= 0)
  8939. {
  8940. continue;
  8941. }
  8942. 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";
  8943. index++;
  8944. }
  8945. }
  8946. }
  8947. }
  8948. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8949. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8950. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8951. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8952. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8953. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8954. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8955. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8956. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8957. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8958. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8959. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8960. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8961. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8962. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8963. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8964. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8965. DickeyValue.Add("TzZCost", TzZCost);
  8966. foreach (var key in DickeyValue.Keys)
  8967. {
  8968. if (doc.Range.Bookmarks[key] != null)
  8969. {
  8970. Bookmark mark = doc.Range.Bookmarks[key];
  8971. mark.Text = DickeyValue[key];
  8972. }
  8973. }
  8974. byte[] bytes = null;
  8975. string strFileName = di.TeamName + "-客户报价.doc";
  8976. using (MemoryStream stream = new MemoryStream())
  8977. {
  8978. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8979. bytes = stream.ToArray();
  8980. }
  8981. return Ok(JsonView(true, "", new
  8982. {
  8983. Data = bytes,
  8984. strFileName,
  8985. }));
  8986. }
  8987. /// <summary>
  8988. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8989. /// </summary>
  8990. /// <param name="dto"></param>
  8991. /// <returns></returns>
  8992. [HttpPost]
  8993. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8994. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8995. {
  8996. try
  8997. {
  8998. #region 参数验证
  8999. if (dto.DiId < 0)
  9000. {
  9001. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  9002. }
  9003. List<int> cTableIds = new List<int>() {
  9004. 76 ,//酒店预订
  9005. 77 ,//行程
  9006. 79 ,//车/导游地接
  9007. 80 ,//签证
  9008. 81 ,//邀请/公务活
  9009. 82 ,//团组客户保险
  9010. 85 ,//机票预订
  9011. 98 ,//其他款项
  9012. 285 ,//收款退还
  9013. 751 ,//酒店早餐
  9014. 1015 // 超支费用
  9015. };
  9016. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  9017. {
  9018. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  9019. }
  9020. #endregion
  9021. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  9022. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  9023. if (_GroupCostParameters.Count <= 0)
  9024. {
  9025. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  9026. }
  9027. if (_GroupCostParameters[0].IsShare == 0)
  9028. {
  9029. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  9030. }
  9031. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9032. //处理date为空问题
  9033. if (_GroupCosts.Count > 0)
  9034. {
  9035. for (int i = 0; i < _GroupCosts.Count; i++)
  9036. {
  9037. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  9038. {
  9039. if (i > 0)
  9040. {
  9041. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  9042. }
  9043. }
  9044. }
  9045. }
  9046. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  9047. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  9048. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  9049. string currCode = "";
  9050. #region currCode 验证
  9051. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  9052. if (isInt)
  9053. {
  9054. var currData = currDatas.Find(it => it.Id == intCurrency);
  9055. if (currData != null)
  9056. {
  9057. currCode = currData.Name;
  9058. }
  9059. }
  9060. else
  9061. {
  9062. currCode = _GroupCostParameters[0].Currency.Trim();
  9063. }
  9064. #endregion
  9065. //op,酒店单段模式存储
  9066. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  9067. {
  9068. CurrencyCode = currCode,
  9069. Rate = _GroupCostParameters[0].Rate,
  9070. CostType = _GroupCostParameters[0].CostType,
  9071. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  9072. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  9073. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  9074. };
  9075. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  9076. if (_GroupCostParameters.Count == 2)
  9077. {
  9078. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  9079. }
  9080. foreach (var item in _GroupCostParameters)
  9081. {
  9082. decimal _rate = 1;
  9083. decimal _rate1 = item.Rate;
  9084. decimal _scale = 1;
  9085. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  9086. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  9087. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  9088. //if (userInfo != null)
  9089. //{
  9090. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  9091. // {
  9092. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  9093. // {
  9094. // _scale = 1.00M;
  9095. // }
  9096. // }
  9097. //}
  9098. #endregion
  9099. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  9100. {
  9101. CurrencyCode = currCode,
  9102. Rate = _rate1,
  9103. CostType = item.CostType,
  9104. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  9105. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  9106. CostTypeNumber = item.CostTypenumber
  9107. };
  9108. if (_GroupCostParameters.Count > 1)
  9109. {
  9110. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  9111. }
  9112. else
  9113. {
  9114. modulePromptInfo.CostTypeNumber = item.LYJRS;
  9115. }
  9116. if (dto.CTable == 79)//
  9117. {
  9118. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  9119. modulePromptInfo.TotalCost = item.DJCB;
  9120. }
  9121. List<string> costTypes = new List<string>() { "A", "B" };
  9122. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  9123. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  9124. if (_GroupCostsDuplicates.Count() == 1)
  9125. {
  9126. _GroupCostsTypeData = _GroupCosts;
  9127. }
  9128. else
  9129. {
  9130. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  9131. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  9132. }
  9133. /*
  9134. * 76 酒店预订
  9135. * 77 行程
  9136. * 79 车/导游地接
  9137. * 80 签证
  9138. * 81 邀请/公务活动
  9139. * 82 团组客户保险
  9140. * 85 机票预订
  9141. * 98 其他款项
  9142. * 285 收款退还
  9143. * 751 酒店早餐
  9144. * 1015 超支费用
  9145. */
  9146. switch (dto.CTable)
  9147. {
  9148. case 76: // 酒店预订
  9149. _ModuleSubPromptInfo.AddRange(
  9150. _GroupCostsTypeData.Select(it => new
  9151. {
  9152. it.DAY,
  9153. it.Date,
  9154. it.ACCON,
  9155. it.ITIN,
  9156. it.SGR,
  9157. it.TBR,
  9158. it.JS_ES,
  9159. it.Suite
  9160. })
  9161. );
  9162. break;
  9163. case 79: // 车/导游地接
  9164. _ModuleSubPromptInfo.AddRange(
  9165. _GroupCostsTypeData.Select(it => new
  9166. {
  9167. Date = it.Date, //日期
  9168. CarFee = it.CarCost * _rate * _scale, //车费用
  9169. CarType = it.CarType, //车型
  9170. DriverFee = it.CFS * _rate * _scale, //司机工资
  9171. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  9172. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  9173. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  9174. GuideFee = it.TGS * _rate * _scale, //导游费用
  9175. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  9176. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  9177. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  9178. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  9179. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  9180. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  9181. Breakfast = it.B * _rate * _scale, //早餐费
  9182. Lunch = it.L * _rate * _scale, //午餐费
  9183. Dinner = it.D * _rate * _scale, //晚餐费
  9184. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  9185. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  9186. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  9187. TicketFee = it.EF * _rate * _scale, //门票费
  9188. TicketRemark = it.EFR, //门票费描述
  9189. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  9190. TravelSupplies = it.TE * _rate * _scale, //出行物资
  9191. SpentCash = it.PC * _rate * _scale, //零用金
  9192. LeadersFee = it.TLF * _rate * _scale, //领队费
  9193. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  9194. })
  9195. );
  9196. break;
  9197. case 85: // 机票
  9198. List<dynamic> datas = new List<dynamic>();
  9199. datas.Add(
  9200. new
  9201. {
  9202. AirType = "经济舱",
  9203. AirNum = item.JJCRS,
  9204. AirDRCB = item.JJCCB,
  9205. AirZCB = (item.JJCRS * item.JJCCB)
  9206. }
  9207. );
  9208. datas.Add(
  9209. new
  9210. {
  9211. AirType = "公务舱",
  9212. AirNum = item.GWCRS,
  9213. AirDRCB = item.GWCCB,
  9214. AirZCB = (item.GWCRS * item.GWCCB)
  9215. }
  9216. );
  9217. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9218. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  9219. modulePromptInfo.Data = new
  9220. {
  9221. airFeeData = datas,
  9222. airInitData = initDatas
  9223. };
  9224. _ModulePromptInfos.Add(modulePromptInfo);
  9225. break;
  9226. default:
  9227. break;
  9228. }
  9229. }
  9230. if (dto.CTable != 85)
  9231. {
  9232. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  9233. _ModulePromptInfos.Add(_ModulePromptInfo);
  9234. }
  9235. _view.ModulePromptInfos = _ModulePromptInfos;
  9236. return Ok(JsonView(true, "操作成功!", _view));
  9237. }
  9238. catch (Exception ex)
  9239. {
  9240. return Ok(JsonView(false, ex.Message));
  9241. }
  9242. }
  9243. /// <summary>
  9244. /// 根据黑屏代码重新生成行程
  9245. /// </summary>
  9246. /// <param name="dto"></param>
  9247. /// <returns></returns>
  9248. [HttpPost]
  9249. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  9250. {
  9251. var jw = JsonView(false);
  9252. var Create = _GroupCostRepository.
  9253. CreateGroupCostByBlackCode(dto.Diid);
  9254. jw.Msg = Create.Msg;
  9255. if (Create.Code == 0)
  9256. {
  9257. jw.Code = 200;
  9258. jw.Data = new
  9259. {
  9260. groupCost = Create.Data,
  9261. blackCodeIsTrue = true
  9262. };
  9263. }
  9264. else
  9265. {
  9266. jw.Code = 400;
  9267. jw.Data = new
  9268. {
  9269. groupCost = Create.Data,
  9270. blackCodeIsTrue = false,
  9271. };
  9272. }
  9273. return Ok(jw);
  9274. }
  9275. /// <summary>
  9276. /// 成本获取OP历史车费用
  9277. /// </summary>
  9278. /// <param name="dto"></param>
  9279. /// <returns></returns>
  9280. [HttpPost]
  9281. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  9282. {
  9283. var jw = JsonView(false);
  9284. try
  9285. {
  9286. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  9287. //获取现有所有车的数据
  9288. if (!dto.Param.IsNullOrWhiteSpace())
  9289. {
  9290. string sql = $@"
  9291. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  9292. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  9293. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  9294. 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
  9295. AND gctggr.ServiceEndTime is not NULL
  9296. ORDER by gctggrc.id DESC
  9297. ";
  9298. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  9299. var numeberResult = await Task.Run(() =>
  9300. {
  9301. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  9302. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  9303. return numberArr;
  9304. });
  9305. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  9306. foreach (var item in numeberResult)
  9307. {
  9308. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  9309. {
  9310. Country = "数据异常!",
  9311. City = string.Empty,
  9312. };
  9313. item.Area = find.Country + " " + find.City;
  9314. }
  9315. dbResult.AddRange(numeberResult);
  9316. if (dto.Param.Contains("、"))
  9317. {
  9318. var sp = dto.Param.Split("、");
  9319. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9320. .Where(x =>
  9321. {
  9322. return System.Array.Exists(sp, e =>
  9323. {
  9324. bool where = false;
  9325. if (x.Area != null)
  9326. {
  9327. where = x.Area.Contains(e);
  9328. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9329. {
  9330. return false;
  9331. }
  9332. }
  9333. if (x.PriceName != null && !where)
  9334. {
  9335. where = x.PriceName.Contains(e);
  9336. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9337. {
  9338. return false;
  9339. }
  9340. }
  9341. return where;
  9342. });
  9343. }).ToList();
  9344. }
  9345. else
  9346. {
  9347. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9348. .Where(x =>
  9349. {
  9350. bool where = false;
  9351. if (x.Area != null)
  9352. {
  9353. where = x.Area.Contains(dto.Param);
  9354. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9355. {
  9356. return false;
  9357. }
  9358. }
  9359. if (x.PriceName != null && !where)
  9360. {
  9361. where = x.PriceName.Contains(dto.Param);
  9362. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9363. {
  9364. return false;
  9365. }
  9366. }
  9367. return where;
  9368. }
  9369. )
  9370. .ToList();
  9371. }
  9372. }
  9373. var view = dbResult.Select(x =>
  9374. {
  9375. decimal dp = 0.00M;
  9376. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  9377. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  9378. if (string.IsNullOrWhiteSpace(x.DatePrice))
  9379. {
  9380. if (startB && endB)
  9381. {
  9382. var timesp = endD.Subtract(startD);
  9383. if ((timesp.Days + 1) != 0)
  9384. {
  9385. dp = x.Price / (timesp.Days + 1);
  9386. }
  9387. }
  9388. }
  9389. else
  9390. {
  9391. dp = x.Price;
  9392. }
  9393. return new
  9394. {
  9395. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  9396. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  9397. x.Area,
  9398. x.id,
  9399. price = x.Price.ToString("F2"),
  9400. x.PriceName,
  9401. x.PriceContent,
  9402. x.TeamName,
  9403. x.DatePrice,
  9404. dayPrice = dp.ToString("F2"),
  9405. };
  9406. }).OrderByDescending(x => x.id).ToList();
  9407. jw = JsonView(true, "获取成功!", view);
  9408. }
  9409. catch (Exception e)
  9410. {
  9411. jw = JsonView(false, e.Message);
  9412. }
  9413. return Ok(jw);
  9414. }
  9415. #endregion
  9416. #region 酒店预订 新 雷怡 2023-12-28 17:45
  9417. /// <summary>
  9418. /// 酒店预订
  9419. /// 酒店费用列表 根据团组Id查询
  9420. /// </summary>
  9421. /// <param name="_dto"></param>
  9422. /// <returns></returns>
  9423. [HttpPost]
  9424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9425. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  9426. {
  9427. #region 参数验证
  9428. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9429. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9430. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9431. #region 团组操作权限验证 76 酒店预定模块
  9432. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9433. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9434. #endregion
  9435. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9436. #region 页面操作权限验证
  9437. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9438. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9439. #endregion
  9440. #endregion
  9441. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  9442. }
  9443. /// <summary>
  9444. /// 酒店预订
  9445. /// 基础数据
  9446. /// </summary>
  9447. /// <param name="_dto"></param>
  9448. /// <returns></returns>
  9449. [HttpPost]
  9450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9451. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  9452. {
  9453. #region 参数验证
  9454. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9455. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9456. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9457. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9458. #region 页面操作权限验证
  9459. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9460. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9461. #endregion
  9462. #region 团组操作权限验证 76 酒店预定模块
  9463. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9464. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9465. #endregion
  9466. #endregion
  9467. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  9468. }
  9469. /// <summary>
  9470. /// 酒店预订
  9471. /// 创建 入住卷号码
  9472. /// </summary>
  9473. /// <param name="_dto"></param>
  9474. /// <returns></returns>
  9475. [HttpPost]
  9476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9477. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  9478. {
  9479. #region 参数验证
  9480. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9481. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9482. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9483. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9484. #region 页面操作权限验证
  9485. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9486. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9487. #endregion
  9488. #region 团组操作权限验证 76 酒店预定模块
  9489. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9490. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9491. #endregion
  9492. #endregion
  9493. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  9494. if (data.Code != 0)
  9495. {
  9496. return Ok(JsonView(false, data.Msg));
  9497. }
  9498. return Ok(JsonView(true, data.Msg, data.Data));
  9499. }
  9500. /// <summary>
  9501. /// 酒店预订
  9502. /// 详情
  9503. /// </summary>
  9504. /// <param name="_dto"></param>
  9505. /// <returns></returns>
  9506. [HttpPost]
  9507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9508. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  9509. {
  9510. #region 参数验证
  9511. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  9512. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9513. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  9514. #region 团组操作权限验证 76 酒店预定模块
  9515. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9516. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9517. #endregion
  9518. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9519. #region 页面操作权限验证
  9520. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9521. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9522. #endregion
  9523. #endregion
  9524. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  9525. }
  9526. /// <summary>
  9527. /// 酒店预订
  9528. /// Add Or Edit
  9529. /// </summary>
  9530. /// <param name="_dto"></param>
  9531. /// <returns></returns>
  9532. [HttpPost]
  9533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9534. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  9535. {
  9536. #region 参数验证
  9537. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9538. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9539. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9540. #region 团组操作权限验证 76 酒店预定模块
  9541. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9542. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9543. #endregion
  9544. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9545. #region 页面操作权限验证
  9546. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9547. if (_dto.Id == 0) // Add
  9548. {
  9549. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9550. }
  9551. else if (_dto.Id > 1) // Edit
  9552. {
  9553. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9554. }
  9555. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  9556. #endregion
  9557. #endregion
  9558. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  9559. if (_view.Code != 200)
  9560. {
  9561. return Ok(_view);
  9562. }
  9563. #region 应用推送
  9564. try
  9565. {
  9566. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9567. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9568. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9569. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9570. //自动审核
  9571. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  9572. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  9573. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  9574. }
  9575. catch (Exception ex)
  9576. {
  9577. }
  9578. #endregion
  9579. return Ok(_view);
  9580. }
  9581. /// <summary>
  9582. /// 酒店自动审核测试
  9583. /// Add Or Edit
  9584. /// </summary>
  9585. /// <param name="_dto"></param>
  9586. /// <returns></returns>
  9587. [HttpPost]
  9588. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9589. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  9590. {
  9591. #region 应用推送
  9592. try
  9593. {
  9594. //自动审核
  9595. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  9596. }
  9597. catch (Exception ex)
  9598. {
  9599. return Ok(JsonView(false, "操作失败"));
  9600. }
  9601. #endregion
  9602. return Ok(JsonView(false, "操作成功"));
  9603. }
  9604. /// <summary>
  9605. /// 酒店预订
  9606. /// Del
  9607. /// </summary>
  9608. /// <param name="_dto"></param>
  9609. /// <returns></returns>
  9610. [HttpPost]
  9611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9612. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  9613. {
  9614. #region 参数验证
  9615. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9616. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9617. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9618. #region 团组操作权限验证 76 酒店预定模块
  9619. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9620. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9621. #endregion
  9622. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9623. #region 页面操作权限验证
  9624. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9625. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9626. #endregion
  9627. #endregion
  9628. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  9629. }
  9630. /// <summary>
  9631. /// 酒店预订
  9632. /// 生成VOUCHER
  9633. /// 2024.05.06 之前版本
  9634. /// </summary>
  9635. /// <param name="_dto"></param>
  9636. /// <returns></returns>
  9637. [HttpPost]
  9638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9639. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  9640. {
  9641. try
  9642. {
  9643. #region 参数验证
  9644. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9645. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9646. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9647. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  9648. #region 团组操作权限验证 76 酒店预定模块
  9649. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9650. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9651. #endregion
  9652. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9653. #region 页面操作权限验证
  9654. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9655. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9656. #endregion
  9657. #endregion
  9658. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  9659. //判断数据是否完整
  9660. if (hr != null)
  9661. {
  9662. if (!string.IsNullOrEmpty(hr.DetermineNo))
  9663. {
  9664. string strFileName = "HotelStatement/";
  9665. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9666. if (dele != null)
  9667. strFileName += dele.TourCode;
  9668. //载入模板
  9669. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  9670. Document doc = new Document(sss);
  9671. DocumentBuilder builder = new DocumentBuilder(doc);
  9672. #region 替换Word模板书签内容
  9673. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9674. //入住卷预定号码
  9675. if (doc.Range.Bookmarks["VNO"] != null)
  9676. {
  9677. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9678. mark.Text = hr.CheckNumber;
  9679. }
  9680. //酒店时间
  9681. if (doc.Range.Bookmarks["Date"] != null)
  9682. {
  9683. Bookmark mark = doc.Range.Bookmarks["Date"];
  9684. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9685. }
  9686. //团号
  9687. if (doc.Range.Bookmarks["TNo"] != null)
  9688. {
  9689. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9690. mark.Text = dele.TourCode;
  9691. }
  9692. //预定号码
  9693. if (doc.Range.Bookmarks["BookingId"] != null)
  9694. {
  9695. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9696. mark.Text = hr.ReservationsNo;
  9697. }
  9698. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9699. {
  9700. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9701. mark.Text = hr.DetermineNo;
  9702. }
  9703. //酒店城市
  9704. if (doc.Range.Bookmarks["City"] != null)
  9705. {
  9706. Bookmark mark = doc.Range.Bookmarks["City"];
  9707. mark.Text = hr.City;
  9708. }
  9709. //酒店名称
  9710. if (doc.Range.Bookmarks["HName"] != null)
  9711. {
  9712. Bookmark mark = doc.Range.Bookmarks["HName"];
  9713. mark.Text = hr.HotelName;
  9714. }
  9715. //酒店地址
  9716. if (doc.Range.Bookmarks["Address"] != null)
  9717. {
  9718. Bookmark mark = doc.Range.Bookmarks["Address"];
  9719. mark.Text = hr.HotelAddress;
  9720. }
  9721. //酒店电话
  9722. if (doc.Range.Bookmarks["Tel"] != null)
  9723. {
  9724. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9725. mark.Text = hr.HotelTel;
  9726. }
  9727. //酒店传真
  9728. if (doc.Range.Bookmarks["Fax"] != null)
  9729. {
  9730. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9731. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9732. {
  9733. mark.Text = hr.HotelFax;
  9734. }
  9735. }
  9736. //入住时间
  9737. if (doc.Range.Bookmarks["CIn"] != null)
  9738. {
  9739. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9740. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9741. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9742. }
  9743. //退房时间
  9744. if (doc.Range.Bookmarks["COut"] != null)
  9745. {
  9746. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9747. Bookmark mark = doc.Range.Bookmarks["COut"];
  9748. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9749. }
  9750. //客户名称
  9751. if (doc.Range.Bookmarks["GName"] != null)
  9752. {
  9753. string guestName = "";
  9754. string[] clients = new string[] { };
  9755. if (hr.GuestName.Contains(","))
  9756. {
  9757. clients = hr.GuestName.Split(",");
  9758. }
  9759. else
  9760. {
  9761. clients = new string[] { hr.GuestName };
  9762. }
  9763. List<int> clientIds_int = new List<int>();
  9764. if (clients.Length > 0)
  9765. {
  9766. foreach (var item in clients)
  9767. {
  9768. if (item.IsNumeric())
  9769. {
  9770. clientIds_int.Add(int.Parse(item));
  9771. }
  9772. }
  9773. }
  9774. if (clientIds_int.Count > 0)
  9775. {
  9776. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9777. foreach (var client in _clientDatas)
  9778. {
  9779. //男
  9780. if (client.Sex == 0) guestName += $"Mr.";
  9781. //女
  9782. else if (client.Sex == 1) guestName += $"Ms.";
  9783. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9784. {
  9785. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9786. }
  9787. //guestName += $"{client.Pinyin},";
  9788. }
  9789. if (guestName.Length > 0)
  9790. {
  9791. guestName = guestName.Substring(0, guestName.Length - 1);
  9792. }
  9793. }
  9794. else
  9795. {
  9796. guestName = hr.GuestName;
  9797. }
  9798. Bookmark mark = doc.Range.Bookmarks["GName"];
  9799. mark.Text = guestName;
  9800. }
  9801. //房间介绍
  9802. if (doc.Range.Bookmarks["ROOM"] != null)
  9803. {
  9804. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9805. mark.Text = hr.RoomExplanation;
  9806. }
  9807. //报价描述
  9808. if (doc.Range.Bookmarks["NOTE"] != null)
  9809. {
  9810. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9811. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9812. if (ss != null)
  9813. mark.Text = ss.Name;
  9814. }
  9815. //入住时间
  9816. if (doc.Range.Bookmarks["CheckIn"] != null)
  9817. {
  9818. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9819. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9820. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9821. }
  9822. //退房时间
  9823. if (doc.Range.Bookmarks["CheckOut"] != null)
  9824. {
  9825. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9826. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9827. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9828. }
  9829. //日期
  9830. if (doc.Range.Bookmarks["DT"] != null)
  9831. {
  9832. Bookmark mark = doc.Range.Bookmarks["DT"];
  9833. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9834. }
  9835. //名称
  9836. if (doc.Range.Bookmarks["VName"] != null)
  9837. {
  9838. Bookmark mark = doc.Range.Bookmarks["VName"];
  9839. mark.Text = hr.HotelName;
  9840. }
  9841. //号码
  9842. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9843. {
  9844. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9845. mark.Text = hr.CheckNumber;
  9846. }
  9847. #endregion
  9848. strFileName += "VOUCHER.doc";
  9849. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9850. doc.Save(fileDir);
  9851. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9852. return Ok(JsonView(true, "操作成功!", Url));
  9853. }
  9854. else
  9855. {
  9856. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9857. }
  9858. }
  9859. else
  9860. {
  9861. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9862. }
  9863. }
  9864. catch (Exception ex)
  9865. {
  9866. return Ok(JsonView(false, ex.Message));
  9867. }
  9868. }
  9869. /// <summary>
  9870. /// 酒店预订
  9871. /// 生成VOUCHER
  9872. /// 2024.05.06 之后版本
  9873. /// </summary>
  9874. /// <param name="_dto"></param>
  9875. /// <returns></returns>
  9876. [HttpPost]
  9877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9878. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9879. {
  9880. #region 参数验证
  9881. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9882. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9883. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9884. #region 团组操作权限验证 76 酒店预定模块
  9885. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9886. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9887. #endregion
  9888. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9889. #region 页面操作权限验证
  9890. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9891. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9892. #endregion
  9893. #endregion
  9894. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9895. //判断数据是否完整
  9896. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9897. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9898. string strFileName = "HotelStatement/";
  9899. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9900. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9901. #region 数据处理
  9902. List<int> guestIds = new List<int>();
  9903. int index = 0;
  9904. foreach (var item in hrDtas)
  9905. {
  9906. if (item.GuestName.Contains(","))
  9907. {
  9908. string[] guestIdArr = item.GuestName.Split(',');
  9909. foreach (var guestIdStr in guestIdArr)
  9910. {
  9911. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9912. if (guestBool)
  9913. {
  9914. guestIds.Add(guestId);
  9915. }
  9916. }
  9917. }
  9918. else guestNames += item.GuestName;
  9919. var voucherInfo = new HotelVoucherInfoView()
  9920. {
  9921. HotelName = item.HotelName,
  9922. CheckInDate = item.CheckInDate,
  9923. CheckOutDate = item.CheckOutDate,
  9924. ConfirmationNumber = item.DetermineNo.Trim(),
  9925. RoomType = item.RoomExplanation
  9926. };
  9927. vouchers.Add(voucherInfo);
  9928. }
  9929. if (guestIds.Count > 0)
  9930. {
  9931. guestIds = guestIds.Distinct().ToList();
  9932. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9933. if (guestDatas.Count > 0)
  9934. {
  9935. guestNames = "";
  9936. foreach (var guest in guestDatas)
  9937. {
  9938. string guestName = "";
  9939. if (guest.Sex == 0) guestName += @"MR.";
  9940. else if (guest.Sex == 1) guestName += @"MS.";
  9941. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9942. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9943. guestNames += @$"{guestName.Trim()}、";
  9944. }
  9945. if (guestNames.Length > 0)
  9946. {
  9947. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9948. }
  9949. }
  9950. }
  9951. #endregion
  9952. //载入模板
  9953. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9954. Document doc = new Document(sss);
  9955. DocumentBuilder builder = new DocumentBuilder(doc);
  9956. if (doc.Range.Bookmarks["GuestName"] != null)
  9957. {
  9958. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9959. mark.Text = guestNames;
  9960. }
  9961. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9962. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9963. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9964. for (int i = 1; i <= vouchers.Count; i++)
  9965. {
  9966. HotelVoucherInfoView hviv = vouchers[i - 1];
  9967. builder.MoveToCell(0, i, 0, 0);
  9968. builder.Write(hviv.HotelName);
  9969. builder.MoveToCell(0, i, 1, 0);
  9970. builder.Write(hviv.CheckInDate);
  9971. builder.MoveToCell(0, i, 2, 0);
  9972. builder.Write(hviv.CheckOutDate);
  9973. builder.MoveToCell(0, i, 3, 0);
  9974. builder.Write(hviv.RoomType);
  9975. builder.MoveToCell(0, i, 4, 0);
  9976. builder.Write(hviv.ConfirmationNumber);
  9977. }
  9978. //删除多余行
  9979. int currRowIndex = vouchers.Count + 1;
  9980. int delRows = 21 - currRowIndex;
  9981. if (delRows > 0)
  9982. {
  9983. for (int i = 0; i < delRows; i++)
  9984. {
  9985. table.Rows.RemoveAt(currRowIndex);
  9986. //cultivateRowIndex++;
  9987. }
  9988. }
  9989. strFileName += "VOUCHER.docx";
  9990. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9991. doc.Save(fileDir);
  9992. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9993. return Ok(JsonView(true, "操作成功!", Url));
  9994. }
  9995. /// <summary>
  9996. /// 酒店预订
  9997. /// 生成VOUCHER 批量生成
  9998. /// New
  9999. /// </summary>
  10000. /// <param name="_dto"></param>
  10001. /// <returns></returns>
  10002. [HttpPost]
  10003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10004. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  10005. {
  10006. #region 参数验证
  10007. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10008. if (_dto.PageId < 1) _dto.PageId = 28;
  10009. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10010. #region 团组操作权限验证 76 酒店预定模块
  10011. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10012. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10013. #endregion
  10014. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10015. #region 页面操作权限验证
  10016. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10017. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10018. #endregion
  10019. #endregion
  10020. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  10021. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  10022. .OrderBy(x => x.CheckInDate)
  10023. .ToListAsync();
  10024. //判断数据是否完整
  10025. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  10026. string strFileName = "HotelStatement/";
  10027. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  10028. if (dele != null)
  10029. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  10030. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  10031. for (int i = 0; i < hrDtas.Count; i++)
  10032. {
  10033. string guestNames = string.Empty;
  10034. List<int> guestIds = new List<int>();
  10035. var item = hrDtas[i];
  10036. //处理客户姓名
  10037. if (item.GuestName.Contains(","))
  10038. {
  10039. string[] guestIdArr = item.GuestName.Split(',');
  10040. foreach (var guestIdStr in guestIdArr)
  10041. if (int.TryParse(guestIdStr, out int guestId))
  10042. guestIds.Add(guestId);
  10043. }
  10044. else
  10045. {
  10046. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  10047. if (guestIdBool)
  10048. {
  10049. guestIds.Add(guestId);
  10050. }
  10051. //NaN
  10052. if (item.GuestName.Contains("NaN"))
  10053. {
  10054. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  10055. }
  10056. }
  10057. if (guestIds.Count > 0)
  10058. {
  10059. guestIds = guestIds.Distinct().ToList();
  10060. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  10061. if (guestDatas1.Count > 0)
  10062. {
  10063. guestNames = "";
  10064. foreach (var guest in guestDatas1)
  10065. {
  10066. string guestName = "";
  10067. if (guest.Sex == 0) guestName += @"MR.";
  10068. else if (guest.Sex == 1) guestName += @"MS.";
  10069. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  10070. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  10071. guestNames += @$"{guestName.Trim()}、";
  10072. }
  10073. if (guestNames.Length > 0)
  10074. {
  10075. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  10076. }
  10077. }
  10078. }
  10079. //if (!string.IsNullOrEmpty(guestNames))
  10080. //{
  10081. hrDtas[i].GuestName = guestNames;
  10082. //}
  10083. }
  10084. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  10085. Document doc = new Document();
  10086. DocumentBuilder builder = new DocumentBuilder(doc);
  10087. try
  10088. {
  10089. builder.MoveToDocumentStart();
  10090. foreach (var item in hrDtas)
  10091. {
  10092. //标题
  10093. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  10094. builder.ParagraphFormat.LineSpacing = 1;
  10095. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10096. builder.ParagraphFormat.Style.Font.Size = 9;
  10097. builder.ParagraphFormat.Style.Font.Bold = true;
  10098. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  10099. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  10100. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  10101. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  10102. builder.ParagraphFormat.LineSpacing = 1;
  10103. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10104. builder.ParagraphFormat.Style.Font.Size = 9;
  10105. builder.ParagraphFormat.Style.Font.Bold = true;
  10106. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  10107. builder.StartTable();
  10108. // 设置边框颜色
  10109. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  10110. //设置边框样式
  10111. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  10112. //表格
  10113. #region 第一行
  10114. builder.InsertCell();
  10115. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10116. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10117. //builder.CellFormat.AllowAutoFit = false;
  10118. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10119. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10120. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10121. builder.CellFormat.WrapText = true; //自动换行
  10122. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10123. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  10124. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10125. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10126. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10127. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10128. builder.Write("TOUR NO:");
  10129. builder.InsertCell();
  10130. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10131. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10132. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10133. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10134. builder.ParagraphFormat.Style.Font.Bold = false;
  10135. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10136. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10137. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10138. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10139. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10140. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10141. builder.Write($"{dele?.TourCode ?? "-"}");
  10142. builder.InsertCell();
  10143. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10144. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10145. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10146. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10147. builder.ParagraphFormat.Style.Font.Bold = false;
  10148. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10149. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10150. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10151. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10152. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10153. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10154. builder.Write($"CITY:");
  10155. builder.InsertCell();
  10156. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10157. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10158. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10159. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10160. builder.ParagraphFormat.Style.Font.Bold = false;
  10161. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10162. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10163. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10164. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10165. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10166. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10167. builder.Write($"{item.City}");
  10168. builder.EndRow();
  10169. #endregion
  10170. #region 第二行
  10171. builder.InsertCell();
  10172. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10173. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10174. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10175. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10176. builder.ParagraphFormat.Style.Font.Bold = false;
  10177. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10178. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10179. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10180. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10181. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10182. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10183. builder.Write("CONFIRMATION NO:");
  10184. builder.InsertCell();
  10185. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10186. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10187. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10188. builder.ParagraphFormat.Style.Font.Bold = false;
  10189. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10190. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10191. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10192. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10193. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10194. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10195. builder.CellFormat.VerticalMerge = CellMerge.None;
  10196. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10197. builder.Write($"{item.DetermineNo}");
  10198. builder.InsertCell();
  10199. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10200. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10201. builder.InsertCell();
  10202. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10203. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10204. builder.EndRow();
  10205. #endregion
  10206. #region 第三行
  10207. builder.InsertCell();
  10208. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10209. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10210. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10211. builder.ParagraphFormat.Style.Font.Bold = false;
  10212. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10213. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10214. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10215. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10216. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10217. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10218. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10219. builder.Write($"HOTEL NAME:");
  10220. builder.InsertCell();
  10221. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10222. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10223. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10224. builder.ParagraphFormat.Style.Font.Bold = false;
  10225. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10226. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10227. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10228. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10229. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10230. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10231. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10232. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10233. builder.Write($"{item.HotelName}");
  10234. builder.InsertCell();
  10235. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10236. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10237. builder.InsertCell();
  10238. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10239. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10240. builder.EndRow();
  10241. #endregion
  10242. #region 第四行
  10243. builder.InsertCell();
  10244. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10245. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10246. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10247. builder.ParagraphFormat.Style.Font.Bold = false;
  10248. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10249. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10250. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10251. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10252. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10253. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10254. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10255. builder.Write($"HOTEL ADDRESS:");
  10256. builder.InsertCell();
  10257. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10258. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10259. builder.ParagraphFormat.Style.Font.Size = 8;
  10260. builder.ParagraphFormat.Style.Font.Bold = false;
  10261. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10262. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10263. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10264. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10265. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10266. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10267. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10268. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10269. builder.Write($"{item.HotelAddress}");
  10270. builder.InsertCell();
  10271. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10272. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10273. builder.InsertCell();
  10274. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10275. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10276. builder.EndRow();
  10277. #endregion
  10278. #region 第五行
  10279. builder.InsertCell();
  10280. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10281. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10282. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10283. builder.ParagraphFormat.Style.Font.Bold = false;
  10284. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10285. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10286. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10287. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10288. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10289. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10290. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10291. builder.Write("TEL:");
  10292. builder.InsertCell();
  10293. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10294. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10295. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10296. builder.ParagraphFormat.Style.Font.Bold = false;
  10297. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10298. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10299. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10300. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10301. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10302. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10303. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10304. builder.Write($"{item.HotelTel}");
  10305. builder.InsertCell();
  10306. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10307. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10308. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10309. builder.ParagraphFormat.Style.Font.Bold = false;
  10310. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10311. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10312. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10313. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10314. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10315. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10316. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10317. builder.Write($"FAX:");
  10318. builder.InsertCell();
  10319. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10320. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10321. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10322. builder.ParagraphFormat.Style.Font.Bold = false;
  10323. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10324. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10325. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10326. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10327. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10328. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10329. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10330. builder.Write($"{item.HotelFax}");
  10331. builder.EndRow();
  10332. #endregion
  10333. #region 第六行
  10334. builder.InsertCell();
  10335. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10336. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10337. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10338. builder.ParagraphFormat.Style.Font.Bold = false;
  10339. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10340. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10341. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10342. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10343. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10344. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10345. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10346. builder.Write("CHECK IN:");
  10347. builder.InsertCell();
  10348. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10349. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10350. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10351. builder.ParagraphFormat.Style.Font.Bold = false;
  10352. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10353. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10354. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10355. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10356. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10357. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10358. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10359. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  10360. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  10361. builder.Write($"{checkInStr}");
  10362. builder.InsertCell();
  10363. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10364. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10365. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10366. builder.ParagraphFormat.Style.Font.Bold = false;
  10367. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10368. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10369. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10370. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10371. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10372. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10373. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10374. builder.Write($"CHECK OUT:");
  10375. builder.InsertCell();
  10376. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10377. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10378. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10379. builder.ParagraphFormat.Style.Font.Bold = false;
  10380. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10381. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10382. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10383. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10384. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10385. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10386. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10387. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  10388. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  10389. builder.Write($"{checkOutStr}");
  10390. builder.EndRow();
  10391. #endregion
  10392. #region 第七行
  10393. builder.InsertCell();
  10394. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10395. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10396. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10397. builder.ParagraphFormat.Style.Font.Bold = false;
  10398. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10399. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10400. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10401. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10402. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10403. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10404. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10405. builder.Write($"GUEST NAME:");
  10406. builder.InsertCell();
  10407. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10408. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10409. builder.ParagraphFormat.Style.Font.Size = 8;
  10410. builder.ParagraphFormat.Style.Font.Bold = false;
  10411. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10412. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10413. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10414. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10415. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10416. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10417. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10418. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10419. builder.Write($"{item.GuestName}");
  10420. builder.InsertCell();
  10421. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10422. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10423. builder.InsertCell();
  10424. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10425. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10426. builder.EndRow();
  10427. #endregion
  10428. #region 第八行
  10429. builder.InsertCell();
  10430. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10431. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10432. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10433. builder.ParagraphFormat.Style.Font.Bold = false;
  10434. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10435. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10436. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10437. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10438. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10439. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10440. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10441. builder.Write($"ROOM TYPE:");
  10442. builder.InsertCell();
  10443. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10444. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10445. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10446. builder.ParagraphFormat.Style.Font.Bold = false;
  10447. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10448. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10449. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10450. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10451. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10452. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10453. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10454. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10455. builder.Write($"{item.RoomExplanation}");
  10456. builder.InsertCell();
  10457. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10458. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10459. builder.InsertCell();
  10460. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10461. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10462. builder.EndRow();
  10463. #endregion
  10464. #region 第九行
  10465. builder.InsertCell();
  10466. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10467. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10468. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10469. builder.ParagraphFormat.Style.Font.Bold = false;
  10470. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10471. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10472. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10473. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10474. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10475. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10476. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10477. builder.Write($"NOTE:");
  10478. builder.InsertCell();
  10479. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10480. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10481. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10482. builder.ParagraphFormat.Style.Font.Bold = false;
  10483. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10484. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10485. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10486. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10487. builder.Write($"ROOM WITH BREAKFAST AND TAX ONLY.\r\nTHIS SERVICE IS PAYABLE BY C-TRIP. FOR EXTRA CHARGE TO BE COLLECTED FROM THE GUEST.");
  10488. builder.InsertCell();
  10489. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10490. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10491. builder.InsertCell();
  10492. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10493. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10494. builder.EndRow();
  10495. #endregion
  10496. builder.EndTable();
  10497. //换行
  10498. builder.Writeln("");
  10499. builder.Writeln("");
  10500. }
  10501. #region 获取文档中的所有表格 设置文字自适应
  10502. // 获取文档中的所有表格。
  10503. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  10504. {
  10505. // 遍历表格中的所有行。
  10506. foreach (Aspose.Words.Tables.Row row in table.Rows)
  10507. {
  10508. foreach (Cell cell in row.Cells)
  10509. {
  10510. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  10511. cellFormat.Width = 0;
  10512. }
  10513. }
  10514. }
  10515. #endregion
  10516. #region 设置页眉
  10517. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  10518. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  10519. if (System.IO.File.Exists(voucherHeaderPath))
  10520. {
  10521. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  10522. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  10523. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  10524. Shape shape = builder.InsertImage(imageBytes);
  10525. // 调整图片位置
  10526. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  10527. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  10528. shape.Top = 50; // 将图片距离页眉上边缘的距离
  10529. shape.Left = 0; // 将图片距离页面左边缘的距离
  10530. shape.Width = 81; // 设置图片宽度
  10531. shape.Height = 36; // 设置图片高度
  10532. }
  10533. //靠右
  10534. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  10535. //// 设置页脚上下边距
  10536. //builder.PageSetup.HeaderDistance = 42;
  10537. // 添加页眉线
  10538. Aspose.Words.Border borderHeader = null;
  10539. try
  10540. {
  10541. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  10542. }
  10543. catch (Exception e)
  10544. {
  10545. // TODO Auto-generated catch block
  10546. //e.printStackTrace();
  10547. }
  10548. borderHeader.Shadow = true;
  10549. borderHeader.DistanceFromText = 2;
  10550. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  10551. #endregion
  10552. }
  10553. catch (Exception ex)
  10554. {
  10555. }
  10556. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10557. doc.Save(fileDir);
  10558. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10559. return Ok(JsonView(true, "操作成功!", Url));
  10560. }
  10561. /// <summary>
  10562. /// 酒店预订
  10563. /// 生成 预定成本 Excel
  10564. /// </summary>
  10565. /// <param name="_dto"></param>
  10566. /// <returns></returns>
  10567. [HttpPost]
  10568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10569. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  10570. {
  10571. #region 参数验证
  10572. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  10573. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  10574. if (!vadalitorRes.IsValid)
  10575. {
  10576. var errors = new StringBuilder();
  10577. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  10578. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  10579. }
  10580. #region 团组操作权限验证 76 酒店预定模块
  10581. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10582. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10583. #endregion
  10584. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10585. #region 页面操作权限验证
  10586. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10587. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10588. #endregion
  10589. #endregion
  10590. decimal _rate = 1.00M;
  10591. string _currency = "";
  10592. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  10593. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  10594. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  10595. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  10596. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  10597. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  10598. {
  10599. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  10600. }
  10601. _currency = _GroupCostParameter.Currency;
  10602. bool isIntType = int.TryParse(_currency, out int currId);
  10603. if (isIntType)
  10604. {
  10605. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  10606. }
  10607. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  10608. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  10609. if (currInfo == null)
  10610. {
  10611. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  10612. }
  10613. if (!_currency.ToUpper().Equals("CNY"))
  10614. {
  10615. _rate = _GroupCostParameter.Rate;
  10616. }
  10617. _rate = currInfo.Rate;
  10618. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10619. string strFileName = "HotelStatement/";
  10620. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10621. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  10622. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10623. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  10624. #region 数据处理
  10625. foreach (var item in hrDtas)
  10626. {
  10627. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  10628. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  10629. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  10630. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  10631. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  10632. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  10633. string singleRoomFeeStr = string.Empty,
  10634. doubleRoomFeeStr = string.Empty,
  10635. suiteRoomFeeStr = string.Empty,
  10636. otherRoomFeeStr = string.Empty,
  10637. payMoneyStr = string.Empty,
  10638. cardPriceStr = string.Empty;
  10639. if (roomCurr.Equals(_currency))
  10640. {
  10641. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  10642. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  10643. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  10644. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  10645. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  10646. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  10647. }
  10648. else
  10649. {
  10650. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10651. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10652. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10653. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10654. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  10655. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  10656. }
  10657. string breakfastPriceStr = string.Empty,
  10658. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  10659. governmentRentStr = string.Empty,
  10660. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  10661. cityTaxStrStr = string.Empty,
  10662. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  10663. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  10664. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  10665. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  10666. int payDId = roomInfo?.PayDId ?? 0;
  10667. pcfds.Add(new HotelReservations_PCFD_View()
  10668. {
  10669. City = item.City,
  10670. HotelName = item.HotelName,
  10671. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  10672. // SingleRoomCount = item.SingleRoomCount,
  10673. SingleRoomPrice = singleRoomFeeStr,
  10674. // DoubleRoomCount = item.DoubleRoomCount,
  10675. DoubleRoomPrice = doubleRoomFeeStr,
  10676. //SuiteRoomCount = item.SuiteRoomCount,
  10677. SuiteRoomPrice = suiteRoomFeeStr,
  10678. OtherRoomPrice = otherRoomFeeStr,
  10679. //OtherRoomCount = item.OtherRoomCount,
  10680. BreakfastPrice = breakfastPriceStr,
  10681. GovernmentRent = governmentRentStr,
  10682. CityTax = cityTaxStrStr,
  10683. RoomExplanation = item.RoomExplanation,
  10684. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  10685. PayTime = roomInfo?.ConsumptionDate,
  10686. BankNo = roomInfo?.BankNo,
  10687. PayMoney = payMoneyStr,
  10688. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  10689. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  10690. CardPrice = cardPriceStr,
  10691. Remark = ccpInfo.Remark
  10692. });
  10693. }
  10694. #endregion
  10695. //载入模板
  10696. WorkbookDesigner designer = new WorkbookDesigner();
  10697. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  10698. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  10699. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  10700. designer.SetDataSource("TourNo", groupInfo.TourCode);
  10701. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  10702. designer.SetDataSource("Opertor", userInfo.CnName);
  10703. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  10704. dt.TableName = "ViewMyHotelReservations";
  10705. designer.SetDataSource(dt);
  10706. designer.Process();
  10707. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10708. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  10709. designer.Workbook.Save(serverPath);
  10710. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  10711. #region 删除指定行
  10712. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  10713. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  10714. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  10715. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  10716. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  10717. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  10718. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  10719. cssIndex = dt.Columns["CityTax"].Ordinal,
  10720. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  10721. remarkIndex = dt.Columns["Remark"].Ordinal;
  10722. //删除指定列
  10723. foreach (DataRow item in dt.Rows)
  10724. {
  10725. string singleStr = item["SingleRoomPrice"].ToString();
  10726. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  10727. if (containsDigitButNotZero1) singleDel = false;
  10728. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  10729. string doubleStr = item["DoubleRoomPrice"].ToString();
  10730. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10731. if (containsDigitButNotZero2) doubleDel = false;
  10732. string suiteStr = item["SuiteRoomPrice"].ToString();
  10733. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10734. if (containsDigitButNotZero3) suiteDel = false;
  10735. string otherStr = item["OtherRoomPrice"].ToString();
  10736. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  10737. if (containsDigitButNotZero4) otherDel = false;
  10738. string zcStr = item["BreakfastPrice"].ToString();
  10739. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  10740. if (containsDigitButNotZero5) zcDel = false;
  10741. string dsStr = item["GovernmentRent"].ToString();
  10742. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  10743. if (containsDigitButNotZero6) dsDel = false;
  10744. string cssStr = item["CityTax"].ToString();
  10745. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  10746. if (containsDigitButNotZero7) cssDel = false;
  10747. string cpStr = item["ConsumptionPatterns"].ToString();
  10748. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  10749. string remarkStr = item["Remark"].ToString();
  10750. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  10751. }
  10752. DeleteColumn(serverPath, remarkIndex, remarkDel);
  10753. DeleteColumn(serverPath, cpIndex, cpDel);
  10754. DeleteColumn(serverPath, dsIndex, dsDel);
  10755. DeleteColumn(serverPath, cssIndex, cssDel);
  10756. DeleteColumn(serverPath, zcIndex, zcDel);
  10757. DeleteColumn(serverPath, otherIndex, otherDel);
  10758. DeleteColumn(serverPath, suiteIndex, suiteDel);
  10759. DeleteColumn(serverPath, doubleIndex, doubleDel);
  10760. DeleteColumn(serverPath, singleIndex, singleDel);
  10761. #endregion
  10762. //只保留第一个表格
  10763. DeleteSheet(serverPath);
  10764. return Ok(JsonView(true, "操作成功", url = rst));
  10765. }
  10766. /// <summary>
  10767. /// 删除指定列
  10768. /// </summary>
  10769. /// <param name="file"></param>
  10770. /// <param name="columnIndex"></param>
  10771. /// <param name="isDel"></param>
  10772. private void DeleteColumn(string file, int columnIndex, bool isDel)
  10773. {
  10774. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10775. //wb.Save(file);
  10776. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  10777. if (sheet1 != null)
  10778. {
  10779. if (isDel)
  10780. {
  10781. Cells cells = sheet1.Cells;
  10782. cells.DeleteColumn(columnIndex);
  10783. }
  10784. }
  10785. wb.Save(file);
  10786. }
  10787. /// <summary>
  10788. /// 删除sheet
  10789. /// </summary>
  10790. /// <param name="file"></param>
  10791. /// <param name="sheetName"></param>
  10792. private void DeleteSheet(string file, string sheetName = "")
  10793. {
  10794. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10795. //wb.Save(file);
  10796. List<string> sheets = new List<string>();
  10797. foreach (var item in wb.Worksheets)
  10798. {
  10799. sheets.Add(item.Name);
  10800. }
  10801. if (sheets.Count > 0)
  10802. {
  10803. sheets.RemoveAt(0);//不删除第一个sheet
  10804. foreach (var item in sheets)
  10805. {
  10806. wb.Worksheets.RemoveAt(item);
  10807. }
  10808. }
  10809. wb.Save(file);
  10810. }
  10811. /// <summary>
  10812. /// 酒店预订
  10813. /// 确认单
  10814. /// </summary>
  10815. /// <param name="_dto"></param>
  10816. /// <returns></returns>
  10817. [HttpPost]
  10818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10819. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  10820. {
  10821. try
  10822. {
  10823. #region 参数验证
  10824. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10825. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10826. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10827. #region 团组操作权限验证 76 酒店预定模块
  10828. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10829. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10830. #endregion
  10831. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10832. #region 页面操作权限验证
  10833. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10834. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10835. #endregion
  10836. #endregion
  10837. //团组信息
  10838. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  10839. //酒店数据
  10840. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  10841. if (listhoteldata.Count < 0)
  10842. {
  10843. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  10844. }
  10845. //利datatable存储
  10846. DataTable dt = new DataTable();
  10847. dt.Columns.Add("CheckInDate", typeof(string));
  10848. dt.Columns.Add("City", typeof(string));
  10849. dt.Columns.Add("Hotel", typeof(string));
  10850. dt.Columns.Add("Room", typeof(string));
  10851. for (int i = 0; i < listhoteldata.Count; i++)
  10852. {
  10853. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  10854. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  10855. while (dayStart < dayEnd)
  10856. {
  10857. string temp = "";
  10858. DataRow row = dt.NewRow();
  10859. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  10860. row["City"] = listhoteldata[i].City;
  10861. row["Hotel"] = listhoteldata[i].HotelName;
  10862. if (listhoteldata[i].SingleRoomCount > 0)
  10863. {
  10864. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  10865. }
  10866. if (listhoteldata[i].DoubleRoomCount > 0)
  10867. {
  10868. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  10869. }
  10870. if (listhoteldata[i].SuiteRoomCount > 0)
  10871. {
  10872. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  10873. }
  10874. if (listhoteldata[i].OtherRoomCount > 0)
  10875. {
  10876. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  10877. }
  10878. row["Room"] = temp;
  10879. dt.Rows.Add(row);
  10880. dayStart = dayStart.AddDays(1);
  10881. }
  10882. }
  10883. Dictionary<string, string> dic = new Dictionary<string, string>();
  10884. dic.Add("Dele", di.TeamName);
  10885. dic.Add("City", di.VisitCountry);
  10886. //模板路径
  10887. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  10888. //载入模板
  10889. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  10890. DocumentBuilder builder = new DocumentBuilder(doc);
  10891. foreach (var key in dic.Keys)
  10892. {
  10893. builder.MoveToBookmark(key);
  10894. builder.Write(dic[key]);
  10895. }
  10896. //获取word里所有表格
  10897. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10898. //获取所填表格的序数
  10899. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10900. var rowStart = tableOne.Rows[0]; //获取第1行
  10901. //循环赋值
  10902. for (int i = 0; i < dt.Rows.Count; i++)
  10903. {
  10904. builder.MoveToCell(0, i + 1, 0, 0);
  10905. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  10906. builder.MoveToCell(0, i + 1, 1, 0);
  10907. builder.Write(dt.Rows[i]["City"].ToString());
  10908. builder.MoveToCell(0, i + 1, 2, 0);
  10909. builder.Write(dt.Rows[i]["Hotel"].ToString());
  10910. builder.MoveToCell(0, i + 1, 3, 0);
  10911. builder.Write(dt.Rows[i]["Room"].ToString());
  10912. }
  10913. //删除多余行
  10914. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  10915. {
  10916. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  10917. }
  10918. string strFileName = di.TeamName + "酒店确认单.doc";
  10919. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  10920. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  10921. return Ok(JsonView(true, "成功", url));
  10922. }
  10923. catch (Exception ex)
  10924. {
  10925. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  10926. }
  10927. }
  10928. #endregion
  10929. #region 团组状态
  10930. /// <summary>
  10931. /// 团组状态列表 Page
  10932. /// </summary>
  10933. /// <param name="dto">团组列表请求dto</param>
  10934. /// <returns></returns>
  10935. [HttpPost]
  10936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10937. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  10938. {
  10939. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10940. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  10941. {
  10942. string sqlWhere = string.Empty;
  10943. if (dto.IsSure == 0) //未完成
  10944. {
  10945. sqlWhere += string.Format(@" And IsSure = 0");
  10946. }
  10947. else if (dto.IsSure == 1) //已完成
  10948. {
  10949. sqlWhere += string.Format(@" And IsSure = 1");
  10950. }
  10951. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  10952. {
  10953. string tj = dto.SearchCriteria;
  10954. 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}%')",
  10955. tj, tj, tj, tj, tj);
  10956. }
  10957. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  10958. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  10959. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  10960. From (
  10961. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  10962. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  10963. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  10964. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  10965. From Grp_DelegationInfo gdi
  10966. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  10967. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  10968. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  10969. Where gdi.IsDel = 0 {0}
  10970. ) temp ", sqlWhere);
  10971. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  10972. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  10973. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  10974. }
  10975. else
  10976. {
  10977. return Ok(JsonView(false, "查询失败"));
  10978. }
  10979. }
  10980. /// <summary>
  10981. /// 团组状态
  10982. /// 设置操作完成
  10983. /// </summary>
  10984. /// <param name="dto">团组列表请求dto</param>
  10985. /// <returns></returns>
  10986. [HttpPost]
  10987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10988. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  10989. {
  10990. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10991. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  10992. {
  10993. Id = dto.Id,
  10994. IsSure = 1
  10995. };
  10996. var result = await _sqlSugar.Updateable(_DelegationInfo)
  10997. .UpdateColumns(it => new { it.IsSure })
  10998. .WhereColumns(it => new { it.Id })
  10999. .ExecuteCommandAsync();
  11000. if (result > 0)
  11001. {
  11002. return Ok(JsonView(true, "操作完成!"));
  11003. }
  11004. return Ok(JsonView(false, "操作失败!"));
  11005. }
  11006. #endregion
  11007. #region 保险费用录入
  11008. /// <summary>
  11009. /// 根据团组Id查询保险费用列表
  11010. /// </summary>
  11011. /// <param name="dto"></param>
  11012. /// <returns></returns>
  11013. [HttpPost]
  11014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11015. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  11016. {
  11017. try
  11018. {
  11019. Result groupData = await _customersRep.CustomersByDiId(dto);
  11020. if (groupData.Code != 0)
  11021. {
  11022. return Ok(JsonView(false, groupData.Msg));
  11023. }
  11024. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11025. }
  11026. catch (Exception ex)
  11027. {
  11028. return Ok(JsonView(false, ex.Message));
  11029. }
  11030. }
  11031. /// <summary>
  11032. /// 根据保险费用Id查询保险费用详细
  11033. /// </summary>
  11034. /// <param name="dto"></param>
  11035. /// <returns></returns>
  11036. [HttpPost]
  11037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11038. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  11039. {
  11040. try
  11041. {
  11042. Result groupData = await _customersRep.CustomersById(dto);
  11043. if (groupData.Code != 0)
  11044. {
  11045. return Ok(JsonView(false, groupData.Msg));
  11046. }
  11047. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11048. }
  11049. catch (Exception ex)
  11050. {
  11051. return Ok(JsonView(false, ex.Message));
  11052. }
  11053. }
  11054. /// <summary>
  11055. /// 保险费用录入页面初始化绑定
  11056. /// </summary>
  11057. /// <param name="dto"></param>
  11058. /// <returns></returns>
  11059. [HttpPost]
  11060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11061. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  11062. {
  11063. try
  11064. {
  11065. Result groupData = await _customersRep.CustomersInitialize(dto);
  11066. if (groupData.Code != 0)
  11067. {
  11068. return Ok(JsonView(false, groupData.Msg));
  11069. }
  11070. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11071. }
  11072. catch (Exception ex)
  11073. {
  11074. return Ok(JsonView(false, ex.Message));
  11075. }
  11076. }
  11077. /// <summary>
  11078. /// 保险费用操作(Status:1.新增,2.修改)
  11079. /// </summary>
  11080. /// <param name="dto"></param>
  11081. /// <returns></returns>
  11082. [HttpPost]
  11083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11084. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  11085. {
  11086. Result groupData = await _customersRep.OpCustomers(dto);
  11087. if (groupData.Code != 0)
  11088. {
  11089. return Ok(JsonView(false, groupData.Msg));
  11090. }
  11091. #region 应用推送
  11092. try
  11093. {
  11094. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11095. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11096. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11097. }
  11098. catch (Exception ex)
  11099. {
  11100. }
  11101. #endregion
  11102. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11103. }
  11104. /// <summary>
  11105. /// 保险文件上传
  11106. /// </summary>
  11107. /// <param name="file"></param>
  11108. /// <returns></returns>
  11109. [HttpPost]
  11110. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11111. public async Task<IActionResult> UploadCus(IFormFile file)
  11112. {
  11113. try
  11114. {
  11115. if (file != null)
  11116. {
  11117. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  11118. //文件名称
  11119. string projectFileName = file.FileName;
  11120. //上传的文件的路径
  11121. string filePath = "";
  11122. if (!Directory.Exists(fileDir))
  11123. {
  11124. Directory.CreateDirectory(fileDir);
  11125. }
  11126. //上传的文件的路径
  11127. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  11128. using (FileStream fs = System.IO.File.Create(filePath))
  11129. {
  11130. file.CopyTo(fs);
  11131. fs.Flush();
  11132. }
  11133. return Ok(JsonView(true, "上传成功!", projectFileName));
  11134. }
  11135. else
  11136. {
  11137. return Ok(JsonView(false, "上传失败!"));
  11138. }
  11139. }
  11140. catch (Exception ex)
  11141. {
  11142. return Ok(JsonView(false, "程序错误!"));
  11143. throw;
  11144. }
  11145. }
  11146. /// <summary>
  11147. /// 保险删除指定文件
  11148. /// </summary>
  11149. /// <param name="dto"></param>
  11150. /// <returns></returns>
  11151. [HttpPost]
  11152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11153. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  11154. {
  11155. try
  11156. {
  11157. string filePath = "";
  11158. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  11159. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  11160. //int id = 0;
  11161. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  11162. // 删除该文件
  11163. try
  11164. {
  11165. System.IO.File.Delete(filePath);
  11166. 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()
  11167. {
  11168. Attachment = "",
  11169. }).ExecuteCommandAsync();
  11170. if (result != 0)
  11171. {
  11172. return Ok(JsonView(true, "成功!"));
  11173. }
  11174. else
  11175. {
  11176. return Ok(JsonView(false, "失败!"));
  11177. }
  11178. }
  11179. catch (Exception)
  11180. {
  11181. 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()
  11182. {
  11183. Attachment = "",
  11184. }).ExecuteCommandAsync();
  11185. if (result != 0)
  11186. {
  11187. return Ok(JsonView(true, "成功!"));
  11188. }
  11189. else
  11190. {
  11191. return Ok(JsonView(false, "失败!"));
  11192. }
  11193. }
  11194. }
  11195. catch (Exception ex)
  11196. {
  11197. return Ok(JsonView(false, "程序错误!"));
  11198. throw;
  11199. }
  11200. }
  11201. /// <summary>
  11202. /// 保险费用操作(删除)
  11203. /// </summary>
  11204. /// <param name="dto"></param>
  11205. /// <returns></returns>
  11206. [HttpPost]
  11207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11208. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  11209. {
  11210. try
  11211. {
  11212. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  11213. if (!res)
  11214. {
  11215. return Ok(JsonView(false, "删除失败"));
  11216. }
  11217. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  11218. {
  11219. IsDel = 1,
  11220. DeleteUserId = dto.DeleteUserId,
  11221. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11222. }).ExecuteCommandAsync();
  11223. return Ok(JsonView(true, "删除成功!"));
  11224. }
  11225. catch (Exception ex)
  11226. {
  11227. return Ok(JsonView(false, "程序错误!"));
  11228. throw;
  11229. }
  11230. }
  11231. #endregion
  11232. #region 接团客户名单 PageId 104
  11233. /// <summary>
  11234. /// 接团客户名单
  11235. /// 迁移数据(慎用!)
  11236. /// </summary>
  11237. /// <param name="dto"></param>
  11238. /// <returns></returns>
  11239. [HttpPost]
  11240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11241. public async Task<IActionResult> PostTourClientListChange()
  11242. {
  11243. try
  11244. {
  11245. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  11246. //var groupClinetData1
  11247. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  11248. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  11249. int updateCount = 0;
  11250. if (oldOAClientList.Count > 0)
  11251. {
  11252. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  11253. _sqlSugar.BeginTran();
  11254. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  11255. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  11256. foreach (var item in oldOAClientList)
  11257. {
  11258. int comId = 0;
  11259. string format = "yyyy-MM-dd HH:mm:ss";
  11260. string data11 = "1990-01-01 00:00";
  11261. var data1 = IsValidDate(item.OPdate, format);
  11262. if (data1) data11 = item.OPdate;
  11263. //客户公司验证
  11264. if (!string.IsNullOrEmpty(item.Company))
  11265. {
  11266. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  11267. if (clientComInfo == null) // add
  11268. {
  11269. var addInfo = new Crm_CustomerCompany()
  11270. {
  11271. CompanyAbbreviation = "",
  11272. CompanyFullName = item.Company,
  11273. Address = "",
  11274. PostCodes = "",
  11275. LastedOpUserId = item.OPer,
  11276. LastedOpDt = Convert.ToDateTime(data11),
  11277. CreateUserId = item.OPer,
  11278. CreateTime = Convert.ToDateTime(data11),
  11279. IsDel = 0
  11280. };
  11281. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  11282. if (comId1 > 0) comId = comId1;
  11283. }
  11284. else comId = clientComInfo.Id;
  11285. }
  11286. //客户人员验证
  11287. int clientId = 0;
  11288. string name = item.LastName + item.Name;
  11289. if (!string.IsNullOrEmpty(name))
  11290. {
  11291. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  11292. if (clientInfo == null)
  11293. {
  11294. DateTime? dateTime = null;
  11295. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  11296. if (isDt) dateTime = birthDayDt;
  11297. var addInfo1 = new Crm_DeleClient()
  11298. {
  11299. CrmCompanyId = comId,
  11300. DiId = -1,
  11301. LastName = item.LastName,
  11302. FirstName = item.Name,
  11303. OldName = "",
  11304. Pinyin = item.Pinyin,
  11305. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  11306. Marriage = 0,
  11307. Phone = item.Phone,
  11308. Job = item.Job,
  11309. BirthDay = dateTime
  11310. };
  11311. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  11312. if (clientId1 > 0) clientId = clientId1;
  11313. }
  11314. else clientId = clientInfo.Id;
  11315. }
  11316. if (clientId < 1)
  11317. {
  11318. continue;
  11319. }
  11320. int airType = 0;
  11321. if (item.AirType == "超经舱") airType = 459;
  11322. else if (item.AirType == "公务舱") airType = 458;
  11323. else if (item.AirType == "经济舱") airType = 460;
  11324. else if (item.AirType == "其他") airType = 565;
  11325. else if (item.AirType == "头等舱") airType = 457;
  11326. var _TourClientListEntity = new Grp_TourClientList()
  11327. {
  11328. DiId = item.Diid,
  11329. ClientId = clientId,
  11330. CreateUserId = item.OPer,
  11331. CreateTime = Convert.ToDateTime(data11),
  11332. Remark = item.Remark,
  11333. IsDel = item.Isdel,
  11334. ShippingSpaceTypeId = airType,
  11335. ShippingSpaceSpecialNeeds = item.AirRemark,
  11336. HotelSpecialNeeds = item.RoomType
  11337. };
  11338. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  11339. if (_TourClientList > 0)
  11340. {
  11341. updateCount++;
  11342. }
  11343. }
  11344. _sqlSugar.CommitTran();
  11345. }
  11346. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  11347. }
  11348. catch (Exception ex)
  11349. {
  11350. _sqlSugar.RollbackTran();
  11351. return Ok(JsonView(false, ex.Message));
  11352. }
  11353. return Ok(JsonView(true));
  11354. }
  11355. private bool IsValidDate(string dateString, string format)
  11356. {
  11357. DateTime dateValue;
  11358. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  11359. return valid;
  11360. }
  11361. /// <summary>
  11362. /// 接团客户名单
  11363. /// 根据团组Id查询List
  11364. /// </summary>
  11365. /// <param name="dto"></param>
  11366. /// <returns></returns>
  11367. [HttpPost]
  11368. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11369. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  11370. {
  11371. #region 参数验证
  11372. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  11373. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  11374. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  11375. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11376. #region 页面操作权限验证
  11377. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11378. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11379. #endregion
  11380. #endregion
  11381. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  11382. if (viewData.Code != 0)
  11383. {
  11384. return Ok(JsonView(false, viewData.Msg));
  11385. }
  11386. return Ok(JsonView(viewData.Data));
  11387. }
  11388. /// <summary>
  11389. /// 接团客户名单
  11390. /// 基础数据 Init
  11391. /// </summary>
  11392. /// <param name="_dto"></param>
  11393. /// <returns></returns>
  11394. [HttpPost]
  11395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11396. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  11397. {
  11398. #region 参数验证
  11399. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11400. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11401. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11402. #region 页面操作权限验证
  11403. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11404. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11405. #endregion
  11406. #endregion
  11407. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  11408. }
  11409. /// <summary>
  11410. /// 接团客户名单
  11411. /// 根据 Id查询 Details
  11412. /// </summary>
  11413. /// <param name="_dto"></param>
  11414. /// <returns></returns>
  11415. [HttpPost]
  11416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11417. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  11418. {
  11419. #region 参数验证
  11420. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11421. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11422. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11423. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11424. #region 页面操作权限验证
  11425. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11426. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11427. #endregion
  11428. #endregion
  11429. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  11430. if (viewData.Code != 0)
  11431. {
  11432. return Ok(JsonView(false, viewData.Msg));
  11433. }
  11434. return Ok(JsonView(viewData.Data));
  11435. }
  11436. /// <summary>
  11437. /// 接团客户名单
  11438. /// Add Or Edit
  11439. /// </summary>
  11440. /// <param name="_dto"></param>
  11441. /// <returns></returns>
  11442. [HttpPost]
  11443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11444. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  11445. {
  11446. #region 参数验证
  11447. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11448. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11449. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11450. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11451. #region 页面操作权限验证
  11452. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11453. if (_dto.Id == 0) //添加
  11454. {
  11455. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11456. }
  11457. else if (_dto.Id >= 0) //修改
  11458. {
  11459. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  11460. }
  11461. #endregion
  11462. #endregion
  11463. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  11464. if (viewData.Code != 0)
  11465. {
  11466. return Ok(JsonView(false, viewData.Msg));
  11467. }
  11468. return Ok(JsonView(true));
  11469. }
  11470. /// <summary>
  11471. /// 接团客户名单
  11472. /// AddMultiple(添加多个)
  11473. /// </summary>
  11474. /// <param name="_dto"></param>
  11475. /// <returns></returns>
  11476. [HttpPost]
  11477. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11478. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  11479. {
  11480. #region 参数验证
  11481. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11482. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11483. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11484. #region 页面操作权限验证
  11485. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11486. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11487. #endregion
  11488. #endregion
  11489. var viewData = await _tourClientListRep._AddMultiple(_dto);
  11490. if (viewData.Code != 0)
  11491. {
  11492. return Ok(JsonView(false, viewData.Msg));
  11493. }
  11494. return Ok(JsonView(true));
  11495. }
  11496. /// <summary>
  11497. /// 接团客户名单
  11498. /// Del
  11499. /// </summary>
  11500. /// <param name="_dto"></param>
  11501. /// <returns></returns>
  11502. [HttpPost]
  11503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11504. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  11505. {
  11506. #region 参数验证
  11507. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11508. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11509. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11510. #region 页面操作权限验证
  11511. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11512. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  11513. #endregion
  11514. #endregion
  11515. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  11516. if (viewData.Code != 0)
  11517. {
  11518. return Ok(JsonView(false, viewData.Msg));
  11519. }
  11520. return Ok(JsonView(true));
  11521. }
  11522. /// <summary>
  11523. /// 接团客户名单
  11524. /// 文件下载 客户名单
  11525. /// </summary>
  11526. /// <param name="_dto"></param>
  11527. /// <returns></returns>
  11528. [HttpPost]
  11529. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11530. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  11531. {
  11532. #region 参数验证
  11533. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11534. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11535. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  11536. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11537. #region 页面操作权限验证
  11538. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11539. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11540. #endregion
  11541. #endregion
  11542. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  11543. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  11544. From Grp_TourClientList tcl
  11545. Left Join
  11546. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  11547. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  11548. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  11549. From Crm_DeleClient dc
  11550. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  11551. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  11552. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  11553. Where dc.IsDel = 0) temp
  11554. On temp.DcId =tcl.ClientId
  11555. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  11556. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  11557. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  11558. //载入模板
  11559. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  11560. if (_dto.Language == 1)
  11561. {
  11562. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  11563. }
  11564. //载入模板
  11565. var doc = new Document(tempPath);
  11566. DocumentBuilder builder = new DocumentBuilder(doc);
  11567. //获取word里所有表格
  11568. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11569. //获取所填表格的序数
  11570. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11571. var rowStart = tableOne.Rows[0]; //获取第1行
  11572. if (_dto.Language == 0)
  11573. {
  11574. //循环赋值
  11575. for (int i = 0; i < DcList.Count; i++)
  11576. {
  11577. builder.MoveToCell(0, i + 1, 0, 0);
  11578. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  11579. builder.MoveToCell(0, i + 1, 1, 0);
  11580. int sex = DcList[i].Sex;
  11581. string sexStr = string.Empty;
  11582. if (sex == 0) sexStr = "男";
  11583. else if (sex == 1) sexStr = "女";
  11584. else sexStr = "未设置";
  11585. builder.Write(sexStr);
  11586. builder.MoveToCell(0, i + 1, 2, 0);
  11587. string birthDay = DcList[i].BirthDay;
  11588. string birthDayStr = string.Empty;
  11589. if (!string.IsNullOrEmpty(birthDay))
  11590. {
  11591. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  11592. }
  11593. builder.Write(birthDayStr);
  11594. builder.MoveToCell(0, i + 1, 3, 0);
  11595. string company = "";
  11596. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11597. {
  11598. company = DcList[i].CompanyFullName.ToString();
  11599. }
  11600. builder.Write(company);
  11601. builder.MoveToCell(0, i + 1, 4, 0);
  11602. builder.Write(DcList[i].Job);
  11603. }
  11604. }
  11605. else if (_dto.Language == 1)
  11606. {
  11607. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  11608. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  11609. List<string> transArrayStr = new List<string>();
  11610. string transStrRes1 = "";
  11611. for (int i = 0; i < DcList.Count; i++)
  11612. {
  11613. var dc = DcList[i];
  11614. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  11615. if (dc.Job.Equals("暂无")) dc.Job = "-";
  11616. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  11617. if (DcList.Count - 1 == i) transStrRes1 += str1;
  11618. else transStrRes1 += $"{str1}|";
  11619. }
  11620. //string transStrRes = "0 & Provincial Health & Health Commission Deputy Director | 1 & Provincial People's Hospital & Provincial People's Hospital Chief Accountant | 2 & Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College & North Sichuan Medical College | 3 & Provincial Health Commission Planning & Provincial Health Commission Planning and Information Division Director | 4 &-& Deputy Director | 5 & Provincial Health Commission population and Family Division & Provincial Health Commission population and Family Division Director";
  11621. string transStrRes = "";
  11622. if (transStrRes1.Length > 0)
  11623. {
  11624. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  11625. }
  11626. //0、 Deputy Director of the Provincial Health and Health Commission | 1、 Chief Accountant of the provincial People's Hospital | 2、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 3、 Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director | 5、 Director of the population and Family Department of the Provincial Health and Health Commission | 3、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 4、 Deputy Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director of the population and Family Department of the Provincial Health and Health Commission | 5、 Director of the population and Family Department of the Provincial Health and Health Commission
  11627. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  11628. //List<string> transArray = new List<string> { };
  11629. List<TranslateInfo> transArray = new List<TranslateInfo>();
  11630. if (transStrRes.Contains("|"))
  11631. {
  11632. string[] transArray1 = transStrRes.Split('|');
  11633. if (transArray1.Length > 0)
  11634. {
  11635. foreach (var item in transArray1)
  11636. {
  11637. if (item.Contains("&"))
  11638. {
  11639. string[] transArray2 = item.Split('&');
  11640. int index = 0;
  11641. string companyName = "", job = "";
  11642. if (transArray2.Length > 0)
  11643. {
  11644. bool success = int.TryParse(transArray2[0].Trim(), out index);
  11645. if (1 < transArray2.Length) companyName = transArray2[1];
  11646. if (2 < transArray2.Length) job = transArray2[2];
  11647. }
  11648. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  11649. }
  11650. }
  11651. }
  11652. }
  11653. //循环赋值
  11654. for (int i = 0; i < DcList.Count; i++)
  11655. {
  11656. string PYName = "";
  11657. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  11658. {
  11659. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  11660. string PY_First = DcList[i].Pinyin.Split('/')[1];
  11661. PYName = PY_First + " " + PY_Last;
  11662. }
  11663. else
  11664. {
  11665. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  11666. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  11667. PYName = PY_First + " " + PY_Last;
  11668. }
  11669. builder.MoveToCell(0, i + 1, 0, 0);
  11670. builder.Write(PYName);
  11671. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  11672. builder.MoveToCell(0, i + 1, 1, 0);
  11673. builder.Write(sex);
  11674. DateTime birthDt;
  11675. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  11676. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  11677. builder.MoveToCell(0, i + 1, 2, 0);
  11678. builder.Write(birthday);
  11679. string company = string.Empty, job = string.Empty;
  11680. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  11681. if (dcTransInfo != null)
  11682. {
  11683. company = dcTransInfo.CompanyName;
  11684. job = dcTransInfo.Job;
  11685. }
  11686. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11687. {
  11688. //查询对照表
  11689. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  11690. if (tempCec != null)
  11691. {
  11692. company = tempCec.enName;
  11693. }
  11694. //翻译
  11695. else
  11696. {
  11697. }
  11698. }
  11699. builder.MoveToCell(0, i + 1, 3, 0);
  11700. builder.Write(company);
  11701. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  11702. {
  11703. //查询对照表
  11704. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  11705. if (tempPec != null)
  11706. {
  11707. job = tempPec.enName;
  11708. }
  11709. //翻译
  11710. else
  11711. {
  11712. }
  11713. }
  11714. builder.MoveToCell(0, i + 1, 4, 0);
  11715. builder.Write(job);
  11716. }
  11717. }
  11718. //删除多余行
  11719. while (tableOne.Rows.Count > DcList.Count + 1)
  11720. {
  11721. tableOne.Rows.RemoveAt(DcList.Count + 1);
  11722. }
  11723. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  11724. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  11725. doc.Save(fileDir);
  11726. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  11727. return Ok(JsonView(true, "操作成功!", Url));
  11728. }
  11729. private class TranslateInfo
  11730. {
  11731. public int Index { get; set; }
  11732. public string CompanyName { get; set; }
  11733. public string Job { get; set; }
  11734. }
  11735. #endregion
  11736. #region 团组倒推表
  11737. /// <summary>
  11738. /// 倒推表基础数据
  11739. /// Init
  11740. /// </summary>
  11741. /// <param name="dto"></param>
  11742. /// <returns></returns>
  11743. [HttpPost]
  11744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11745. public async Task<IActionResult> PostInvertedListInit()
  11746. {
  11747. var viewData = await _invertedListRep._Init();
  11748. if (viewData.Code != 0)
  11749. {
  11750. return Ok(JsonView(false, viewData.Msg));
  11751. }
  11752. return Ok(JsonView(viewData.Data));
  11753. }
  11754. /// <summary>
  11755. /// 倒推表
  11756. /// Info
  11757. /// </summary>
  11758. /// <param name="dto"></param>
  11759. /// <returns></returns>
  11760. [HttpPost]
  11761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11762. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  11763. {
  11764. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  11765. if (viewData.Code != 0)
  11766. {
  11767. return Ok(JsonView(false, viewData.Msg));
  11768. }
  11769. return Ok(JsonView(viewData.Data));
  11770. }
  11771. /// <summary>
  11772. /// 倒推表
  11773. /// Create
  11774. /// </summary>
  11775. /// <param name="dto"></param>
  11776. /// <returns></returns>
  11777. [HttpPost]
  11778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11779. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  11780. {
  11781. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  11782. if (viewData.Code != 0)
  11783. {
  11784. return Ok(JsonView(false, viewData.Msg));
  11785. }
  11786. return Ok(JsonView(viewData.Data));
  11787. }
  11788. /// <summary>
  11789. /// 倒推表
  11790. /// Update
  11791. /// </summary>
  11792. /// <param name="dto"></param>
  11793. /// <returns></returns>
  11794. [HttpPost]
  11795. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11796. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  11797. {
  11798. var viewData = await _invertedListRep._Update(dto);
  11799. if (viewData.Code != 0)
  11800. {
  11801. return Ok(JsonView(false, viewData.Msg));
  11802. }
  11803. return Ok(JsonView(viewData.Data));
  11804. }
  11805. /// <summary>
  11806. /// 倒推表
  11807. /// File Download
  11808. /// </summary>
  11809. /// <param name="dto"></param>
  11810. /// <returns></returns>
  11811. [HttpPost]
  11812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11813. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  11814. {
  11815. var info2 = await _invertedListRep._Info(1, dto.DiId);
  11816. if (info2.Code != 0)
  11817. {
  11818. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  11819. }
  11820. var info1 = info2.Data as InvertedListInfoView;
  11821. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  11822. string teamName = "";
  11823. if (info != null) teamName = info.TeamName;
  11824. //载入模板
  11825. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  11826. DocumentBuilder builder = new DocumentBuilder(doc);
  11827. //利用键值对存放数据
  11828. Dictionary<string, string> dic = new Dictionary<string, string>();
  11829. dic.Add("TeamName", teamName);
  11830. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  11831. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  11832. dic.Add("BPRemark", info1.ApprovalDataRemark);
  11833. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  11834. dic.Add("SQRemark", info1.ApprovalRemark);
  11835. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  11836. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  11837. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  11838. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  11839. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  11840. dic.Add("QZRemark", info1.VisaInformationRemark);
  11841. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  11842. dic.Add("SQQZRemark", info1.SendVisaRemark);
  11843. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  11844. dic.Add("CQRemark", info1.IssueVisaRemark);
  11845. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  11846. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  11847. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  11848. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  11849. #region 填充word模板书签内容
  11850. foreach (var key in dic.Keys)
  11851. {
  11852. builder.MoveToBookmark(key);
  11853. builder.Write(dic[key]);
  11854. }
  11855. #endregion
  11856. var fileDir = AppSettingsHelper.Get("WordBasePath");
  11857. string fileName = $"{teamName}团出行准备流程表.doc";
  11858. string filePath = fileDir + $@"InvertedList/{fileName}";
  11859. doc.Save(filePath);
  11860. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  11861. return Ok(JsonView(true, "操作成功!", Url));
  11862. }
  11863. #endregion
  11864. #region 三公签证费用(签证费、代办费)
  11865. /// <summary>
  11866. /// 三公签证费用(签证费、代办费)
  11867. /// List
  11868. /// </summary>
  11869. /// <returns></returns>
  11870. [HttpPost]
  11871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11872. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  11873. {
  11874. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  11875. if (_view.Code != 0)
  11876. {
  11877. return Ok(JsonView(false, _view.Msg));
  11878. }
  11879. return Ok(JsonView(true, "操作成功!", _view.Data));
  11880. }
  11881. /// <summary>
  11882. /// 三公签证费用(签证费、代办费)
  11883. /// Add Or Update
  11884. /// </summary>
  11885. /// <returns></returns>
  11886. [HttpPost]
  11887. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11888. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  11889. {
  11890. var _view = await _visaFeeInfoRep._Update(_dto);
  11891. if (_view.Code != 0)
  11892. {
  11893. return Ok(JsonView(false, _view.Msg));
  11894. }
  11895. return Ok(JsonView(true, _view.Msg));
  11896. }
  11897. #endregion
  11898. #region 酒店询价
  11899. /// <summary>
  11900. /// 酒店询价
  11901. /// Init
  11902. /// </summary>
  11903. /// <param name="dto"></param>
  11904. /// <returns></returns>
  11905. [HttpPost]
  11906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11907. public async Task<IActionResult> PostHotelInquiryInit()
  11908. {
  11909. var res = await _hotelInquiryRep._Init();
  11910. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11911. return Ok(JsonView(true, res.Msg, res.Data));
  11912. }
  11913. /// <summary>
  11914. /// 酒店询价
  11915. /// page Item
  11916. /// </summary>
  11917. /// <param name="_dto"></param>
  11918. /// <returns></returns>
  11919. [HttpPost]
  11920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11921. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  11922. {
  11923. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  11924. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11925. var view = res.Data as PageDataViewBase;
  11926. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  11927. }
  11928. /// <summary>
  11929. /// 酒店询价
  11930. /// info
  11931. /// </summary>
  11932. /// <param name="_dto"></param>
  11933. /// <returns></returns>
  11934. [HttpPost]
  11935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11936. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  11937. {
  11938. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  11939. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11940. return Ok(JsonView(true, res.Msg, res.Data));
  11941. }
  11942. /// <summary>
  11943. /// 酒店询价
  11944. /// Add Or Edit
  11945. /// </summary>
  11946. /// <param name="_dto"></param>
  11947. /// <returns></returns>
  11948. [HttpPost]
  11949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11950. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  11951. {
  11952. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  11953. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11954. return Ok(JsonView(true, res.Msg, res.Data));
  11955. }
  11956. /// <summary>
  11957. /// 酒店询价
  11958. /// Del
  11959. /// </summary>
  11960. /// <param name="_dto"></param>
  11961. /// <returns></returns>
  11962. [HttpPost]
  11963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11964. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  11965. {
  11966. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  11967. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11968. return Ok(JsonView(true, res.Msg, res.Data));
  11969. }
  11970. #endregion
  11971. #region 下载匹配op行程单
  11972. /// <summary>
  11973. /// 匹配op行程单
  11974. /// Init
  11975. /// </summary>
  11976. /// <param name="dto">团组列表请求dto</param>
  11977. /// <returns></returns>
  11978. [HttpPost]
  11979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11980. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  11981. {
  11982. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11983. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11984. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  11985. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  11986. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  11987. .Where(it => it.IsDel == 0)
  11988. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  11989. .OrderByDescending(it => it.CreateUserId)
  11990. .ToList();
  11991. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  11992. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11993. var diids = groupInfos.Select(it => it.Id).ToList();
  11994. List<string> countrys = new List<string>();
  11995. foreach (var item in country)
  11996. {
  11997. var data = _groupRepository.FormartTeamName(item);
  11998. var dataArray = _groupRepository.GroupSplitCountry(data);
  11999. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12000. }
  12001. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  12002. List<string> areaArray = new List<string>(); //GetGroupCityLine
  12003. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  12004. foreach (var item in areaItem)
  12005. {
  12006. string areaStr = item.Value;
  12007. if (!string.IsNullOrEmpty(areaStr))
  12008. {
  12009. string[] str1 = areaStr.Split("-");
  12010. if (str1.Length > 0)
  12011. {
  12012. areaArray.AddRange(str1);
  12013. }
  12014. }
  12015. }
  12016. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  12017. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  12018. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  12019. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  12020. .ToList();
  12021. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  12022. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  12023. .Where(it => countriesIds.Contains(it.Id))
  12024. .Select(it => new { it.Id, Name = it.Name_CN })
  12025. .ToList();
  12026. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  12027. .Select(it => it.TeamName).ToList();
  12028. stopwatch.Stop();
  12029. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  12030. }
  12031. ///// <summary>
  12032. ///// 匹配op行程单
  12033. ///// Init 查询区域数据
  12034. ///// </summary>
  12035. ///// <param name="dto">团组列表请求dto</param>
  12036. ///// <returns></returns>
  12037. //[HttpPost]
  12038. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12039. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  12040. //{
  12041. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  12042. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  12043. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  12044. // if (string.IsNullOrEmpty(countriesDataStr))
  12045. // {
  12046. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  12047. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  12048. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  12049. // }
  12050. // else
  12051. // {
  12052. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  12053. // }
  12054. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  12055. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  12056. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  12057. // List<dynamic> childList = new List<dynamic>();
  12058. // int parentId = dto.CountriesId;
  12059. // if (provinceData.Count > 1)
  12060. // {
  12061. // foreach (var item1 in provinceData)
  12062. // {
  12063. // List<dynamic> childList1 = new List<dynamic>();
  12064. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  12065. // foreach (var item2 in citiesData1)
  12066. // {
  12067. // List<dynamic> childList2 = new List<dynamic>();
  12068. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12069. // foreach (var item3 in countiesData1)
  12070. // {
  12071. // childList2.Add(new
  12072. // {
  12073. // id = item3.Id,
  12074. // parentId = item2.Id,
  12075. // level = "district",
  12076. // name = item3.Name_CN,
  12077. // });
  12078. // }
  12079. // childList1.Add(new
  12080. // {
  12081. // id = item2.Id,
  12082. // parentId = item1.Id,
  12083. // level = "city",
  12084. // name = item2.Name_CN,
  12085. // childList = childList2
  12086. // });
  12087. // }
  12088. // childList.Add(new
  12089. // {
  12090. // id = item1.Id,
  12091. // parentId = parentId,
  12092. // level = "province",
  12093. // name = item1.Name_CN,
  12094. // childList = childList1
  12095. // });
  12096. // }
  12097. // //城市
  12098. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  12099. // foreach (var item2 in citiesData2)
  12100. // {
  12101. // List<dynamic> childList22 = new List<dynamic>();
  12102. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12103. // foreach (var item3 in countiesData1)
  12104. // {
  12105. // childList22.Add(new
  12106. // {
  12107. // id = item3.Id,
  12108. // parentId = item2.Id,
  12109. // level = "district",
  12110. // name = item3.Name_CN,
  12111. // });
  12112. // }
  12113. // childList.Add(new
  12114. // {
  12115. // id = item2.Id,
  12116. // parentId = parentId,
  12117. // level = "city",
  12118. // name = item2.Name_CN,
  12119. // childList = childList22
  12120. // });
  12121. // }
  12122. // }
  12123. // else
  12124. // {
  12125. // foreach (var item2 in citiesData)
  12126. // {
  12127. // string cname = item2.Name_CN;
  12128. // List<dynamic> childList1 = new List<dynamic>();
  12129. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12130. // foreach (var item3 in countiesData1)
  12131. // {
  12132. // childList1.Add(new
  12133. // {
  12134. // Id = item3.Id,
  12135. // parentId = item2.Id,
  12136. // level = "district",
  12137. // name = item3.Name_CN
  12138. // });
  12139. // }
  12140. // childList.Add(new
  12141. // {
  12142. // id = item2.Id,
  12143. // parentId = parentId,
  12144. // level = "city",
  12145. // name = item2.Name_CN,
  12146. // childList = childList1
  12147. // });
  12148. // }
  12149. // }
  12150. // stopwatch.Stop();
  12151. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  12152. //}
  12153. /// <summary>
  12154. /// 匹配op行程单
  12155. /// 接团信息列表 Page
  12156. /// </summary>
  12157. /// <param name="dto">团组列表请求dto</param>
  12158. /// <returns></returns>
  12159. [HttpPost]
  12160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12161. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  12162. {
  12163. var swatch = new Stopwatch();
  12164. swatch.Start();
  12165. #region 参数验证
  12166. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12167. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12168. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12169. #region 页面操作权限验证
  12170. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12171. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  12172. #endregion
  12173. #endregion
  12174. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12175. {
  12176. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  12177. string sqlWhere = "";
  12178. if (!string.IsNullOrEmpty(dto.Country))
  12179. {
  12180. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  12181. }
  12182. if (!string.IsNullOrEmpty(dto.Area))
  12183. {
  12184. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  12185. }
  12186. if (!string.IsNullOrEmpty(dto.TeamName))
  12187. {
  12188. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  12189. }
  12190. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  12191. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  12192. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  12193. swatch.Stop();
  12194. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  12195. }
  12196. else
  12197. {
  12198. return Ok(JsonView(false, "查询失败"));
  12199. }
  12200. }
  12201. /// <summary>
  12202. /// 匹配op行程单
  12203. /// 行程单下载
  12204. /// </summary>
  12205. /// <param name="dto">团组列表请求dto</param>
  12206. /// <returns></returns>
  12207. [HttpPost]
  12208. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12209. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  12210. {
  12211. #region 参数验证
  12212. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12213. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12214. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12215. #region 页面操作权限验证
  12216. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12217. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  12218. #endregion
  12219. #endregion
  12220. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12221. {
  12222. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  12223. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  12224. }
  12225. else
  12226. {
  12227. return Ok(JsonView(false, "下载失败!"));
  12228. }
  12229. }
  12230. #endregion
  12231. #region 国家信息 数据 注释
  12232. //[HttpPost]
  12233. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  12234. //{
  12235. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  12236. // foreach (var item in dto)
  12237. // {
  12238. // infos.Add(new Grp_GroupsTaskAssignment()
  12239. // {
  12240. // DIId = item,
  12241. // CTId = 82,
  12242. // UId = 248,
  12243. // IsEnable = 1,
  12244. // CreateUserId = 233,
  12245. // CreateTime = DateTime.Now,
  12246. // IsDel = 0
  12247. // });
  12248. // infos.Add(new Grp_GroupsTaskAssignment()
  12249. // {
  12250. // DIId = item,
  12251. // CTId = 82,
  12252. // UId = 286,
  12253. // IsEnable = 1,
  12254. // CreateUserId = 233,
  12255. // CreateTime = DateTime.Now,
  12256. // IsDel = 0
  12257. // });
  12258. // }
  12259. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  12260. // return Ok("操作成功");
  12261. //}
  12262. //public class paramJsonDto
  12263. //{
  12264. // public List<CountriesInfo> str { get; set; }
  12265. //}
  12266. //[HttpPost]
  12267. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  12268. //{
  12269. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  12270. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  12271. // List<Sys_Cities> cities = new List<Sys_Cities>();
  12272. // List<Sys_Cities> districts = new List<Sys_Cities>();
  12273. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12274. // _sqlSugar.BeginTran();
  12275. // int countitiesIndex = 0;
  12276. // foreach (var item in dto.str)
  12277. // {
  12278. // dynamic data = item.c;
  12279. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  12280. // if (data != null)
  12281. // {
  12282. // countitiesIndex++;
  12283. // foreach (var item1 in data)
  12284. // {
  12285. // string cnname = item1.cn;
  12286. // string enname = item1.en;
  12287. // Sys_Cities provinceInfo = new Sys_Cities()
  12288. // {
  12289. // CountriesId = countriesId,
  12290. // Name_CN = cnname,
  12291. // Name_EN = enname,
  12292. // ParentId = 0,
  12293. // IsCapital = 1,
  12294. // CreateUserId = 208,
  12295. // CreateTime = DateTime.Now,
  12296. // IsDel = 0
  12297. // };
  12298. // if (item1.lv == "province") //省份
  12299. // {
  12300. // provinceInfo.Level = 1;
  12301. // int provinceId = 0;
  12302. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  12303. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  12304. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12305. // var data1 = item1.c;
  12306. // foreach (var item2 in data1)
  12307. // {
  12308. // if (item2.lv == "city")
  12309. // {
  12310. // string citycnname = item2.cn;
  12311. // string cityenname = item2.en;
  12312. // Sys_Cities cityInfo = new Sys_Cities()
  12313. // {
  12314. // CountriesId = countriesId,
  12315. // ParentId = provinceId,
  12316. // Level = 2,
  12317. // Name_CN = citycnname,
  12318. // Name_EN = cityenname,
  12319. // IsCapital = 1,
  12320. // CreateUserId = 208,
  12321. // CreateTime = DateTime.Now,
  12322. // IsDel = 0
  12323. // };
  12324. // if (item2.c != null)
  12325. // {
  12326. // int cityId = 0;
  12327. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  12328. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12329. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  12330. // foreach (var item3 in item2.c)
  12331. // {
  12332. // if (item3.lv == "district")
  12333. // {
  12334. // var districtInfo = new Sys_Cities()
  12335. // {
  12336. // CountriesId = countriesId,
  12337. // Name_CN = item3.cn,
  12338. // Name_EN = item3.en,
  12339. // Level = 3,
  12340. // ParentId = cityId,
  12341. // IsCapital = 1,
  12342. // CreateUserId = 208,
  12343. // CreateTime = DateTime.Now,
  12344. // IsDel = 0
  12345. // };
  12346. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12347. // //{
  12348. // districts.Add(districtInfo);
  12349. // //}
  12350. // }
  12351. // }
  12352. // }
  12353. // else
  12354. // {
  12355. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  12356. // //{
  12357. // cities.Add(cityInfo);
  12358. // //}
  12359. // }
  12360. // }
  12361. // }
  12362. // }
  12363. // else if (item1.lv == "city")//城市
  12364. // {
  12365. // provinceInfo.Level = 2;
  12366. // if (item1.c != null)
  12367. // {
  12368. // int cityId = 0;
  12369. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  12370. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12371. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12372. // foreach (var item3 in item1.c)
  12373. // {
  12374. // if (item3.lv == "district")
  12375. // {
  12376. // var districtInfo = new Sys_Cities()
  12377. // {
  12378. // CountriesId = countriesId,
  12379. // Name_CN = item3.cn,
  12380. // Name_EN = item3.en,
  12381. // Level = 3,
  12382. // ParentId = cityId,
  12383. // IsCapital = 1,
  12384. // CreateUserId = 208,
  12385. // CreateTime = DateTime.Now,
  12386. // IsDel = 0
  12387. // };
  12388. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12389. // //{
  12390. // districts.Add(districtInfo);
  12391. // //}
  12392. // }
  12393. // }
  12394. // }
  12395. // else
  12396. // {
  12397. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  12398. // //{
  12399. // cities.Add(provinceInfo);
  12400. // //}
  12401. // }
  12402. // }
  12403. // }
  12404. // }
  12405. // }
  12406. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  12407. // cities = cities.Distinct().ToList();
  12408. // districts = districts.Distinct().ToList();
  12409. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  12410. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  12411. // cities.AddRange(districts);
  12412. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  12413. // //_sqlSugar.RollbackTran();
  12414. // _sqlSugar.CommitTran();
  12415. // return Ok(JsonView(false, "操作成功!"));
  12416. //}
  12417. //[HttpPost]
  12418. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  12419. //{
  12420. // List<CountitiesInfo> infos = dto.MyProperty;
  12421. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  12422. // _sqlSugar.BeginTran();
  12423. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12424. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  12425. // foreach (var item in infos)
  12426. // {
  12427. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  12428. // if (countryInfo != null)
  12429. // {
  12430. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  12431. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  12432. // if (cityInfo1 != null)
  12433. // {
  12434. // cityInfo1.IsCapital = 0;
  12435. // cityInfos.Add(cityInfo1);
  12436. // }
  12437. // }
  12438. // }
  12439. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  12440. // .UpdateColumns(it => it.IsCapital)
  12441. // .WhereColumns(it => it.Id)
  12442. // .ExecuteCommand();
  12443. // //_sqlSugar.RollbackTran();
  12444. // _sqlSugar.CommitTran();
  12445. // return Ok(JsonView(false, "操作成功!"));
  12446. //}
  12447. //public class CounrtiesDto
  12448. //{
  12449. // public List<CountitiesInfo> MyProperty { get; set; }
  12450. //}
  12451. //public class CountitiesInfo
  12452. //{
  12453. // /// <summary>
  12454. // /// 圣约翰
  12455. // /// </summary>
  12456. // public string capital_name_chinese { get; set; }
  12457. // /// <summary>
  12458. // ///
  12459. // /// </summary>
  12460. // public string capital_name { get; set; }
  12461. // /// <summary>
  12462. // ///
  12463. // /// </summary>
  12464. // public string country_type { get; set; }
  12465. // /// <summary>
  12466. // /// 安提瓜和巴布达
  12467. // /// </summary>
  12468. // public string country_name_chinese { get; set; }
  12469. // /// <summary>
  12470. // /// 安提瓜和巴布达
  12471. // /// </summary>
  12472. // public string country_name_chinese_short { get; set; }
  12473. // /// <summary>
  12474. // /// 安提瓜和巴布达
  12475. // /// </summary>
  12476. // public string country_name_chinese_UN { get; set; }
  12477. // /// <summary>
  12478. // ///
  12479. // /// </summary>
  12480. // public string country_name_english_abbreviation { get; set; }
  12481. // /// <summary>
  12482. // ///
  12483. // /// </summary>
  12484. // public string country_name_english_formal { get; set; }
  12485. // /// <summary>
  12486. // ///
  12487. // /// </summary>
  12488. // public string country_name_english_UN { get; set; }
  12489. // /// <summary>
  12490. // ///
  12491. // /// </summary>
  12492. // public string continent_name { get; set; }
  12493. // /// <summary>
  12494. // ///
  12495. // /// </summary>
  12496. // public string subregion_name { get; set; }
  12497. // /// <summary>
  12498. // ///
  12499. // /// </summary>
  12500. // public string country_code2 { get; set; }
  12501. // /// <summary>
  12502. // ///
  12503. // /// </summary>
  12504. // public string country_code3 { get; set; }
  12505. // /// <summary>
  12506. // ///
  12507. // /// </summary>
  12508. // public string phone_code { get; set; }
  12509. //}
  12510. //public class CountriesInfo : BasicInfo
  12511. //{
  12512. // public List<CitiesInfo> c { get; set; }
  12513. //}
  12514. //public class CitiesInfo : BasicInfo
  12515. //{
  12516. // public List<AreaInfo> c { get; set; }
  12517. //}
  12518. //public class AreaInfo : BasicInfo
  12519. //{
  12520. // public List<AreaInfo> c { get; set; }
  12521. //}
  12522. //public class BasicInfo
  12523. //{
  12524. // public string code { get; set; }
  12525. // public string cn { get; set; }
  12526. // public string lv { get; set; }
  12527. // public string en { get; set; }
  12528. //}
  12529. #endregion
  12530. #region 查看邀请方
  12531. /// <summary>
  12532. /// 查看邀请方
  12533. /// 邀请方信息 Init
  12534. /// </summary>
  12535. /// <param name="dto"></param>
  12536. /// <returns></returns>
  12537. [HttpPost]
  12538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12539. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  12540. {
  12541. string sqlWhere = string.Empty;
  12542. if (!string.IsNullOrEmpty(dto.Search))
  12543. {
  12544. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  12545. }
  12546. string sql = string.Format($@"Select
  12547. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  12548. Id,
  12549. UnitName
  12550. From Res_InvitationOfficialActivityData
  12551. Where IsDel = 0
  12552. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  12553. RefAsync<int> total = 0;
  12554. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12555. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  12556. }
  12557. /// <summary>
  12558. /// 查看邀请方
  12559. /// 国家信息 Init
  12560. /// </summary>
  12561. /// <param name="dto"></param>
  12562. /// <returns></returns>
  12563. [HttpPost]
  12564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12565. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  12566. {
  12567. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  12568. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12569. var diids = groupInfos.Select(it => it.Id).ToList();
  12570. List<string> countrys = new List<string>();
  12571. foreach (var item in country)
  12572. {
  12573. var data = _groupRepository.FormartTeamName(item);
  12574. var dataArray = _groupRepository.GroupSplitCountry(data);
  12575. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12576. }
  12577. countrys = countrys.Distinct().ToList();
  12578. for (int i = 0; i < countrys.Count; i++)
  12579. {
  12580. string item = countrys[i];
  12581. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  12582. {
  12583. countrys.Remove(item);
  12584. i--;
  12585. }
  12586. }
  12587. RefAsync<int> total = 0;
  12588. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  12589. .Where(it => countrys.Contains(it.Name_CN))
  12590. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12591. .Select(it => new { id = it.Id, name = it.Name_CN })
  12592. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12593. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12594. }
  12595. /// <summary>
  12596. /// 查看邀请方
  12597. /// 城市信息 Init
  12598. /// </summary>
  12599. /// <param name="dto"></param>
  12600. /// <returns></returns>
  12601. [HttpPost]
  12602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12603. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  12604. {
  12605. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  12606. RefAsync<int> total = 0;
  12607. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  12608. .Where(it => it.CountriesId == dto.CountiesId)
  12609. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12610. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  12611. .Select(it => new { id = it.Id, name = it.Name_CN })
  12612. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12613. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12614. }
  12615. /// <summary>
  12616. /// 查看邀请方
  12617. /// 团组名称 Init
  12618. /// </summary>
  12619. /// <param name="dto"></param>
  12620. /// <returns></returns>
  12621. [HttpPost]
  12622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12623. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  12624. {
  12625. var watch = new Stopwatch();
  12626. watch.Start();
  12627. RefAsync<int> total = 0;
  12628. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  12629. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  12630. .Where((oa, di) => oa.IsDel == 0)
  12631. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  12632. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  12633. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  12634. .Distinct()
  12635. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12636. watch.Stop();
  12637. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  12638. }
  12639. /// <summary>
  12640. /// 查看邀请方
  12641. /// 团组 & 邀请方信息
  12642. /// </summary>
  12643. /// <param name="dto"></param>
  12644. /// <returns></returns>
  12645. [HttpPost]
  12646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12647. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  12648. {
  12649. var watch = new Stopwatch();
  12650. watch.Start();
  12651. RefAsync<int> total = 0;
  12652. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  12653. .AS("Grp_DelegationInfo")
  12654. .Includes(x => x.InvitingInfos)
  12655. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  12656. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  12657. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  12658. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  12659. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  12660. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  12661. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12662. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  12663. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  12664. infos.ForEach(x =>
  12665. {
  12666. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  12667. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  12668. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  12669. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  12670. });
  12671. watch.Stop();
  12672. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  12673. }
  12674. #endregion
  12675. #region 报批行程
  12676. /// <summary>
  12677. /// 报批行程初始化
  12678. /// </summary>
  12679. /// <param name="dto"></param>
  12680. /// <returns></returns>
  12681. [HttpPost]
  12682. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  12683. {
  12684. const int chiNumber = 5;
  12685. var jw = JsonView(false);
  12686. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  12687. var group = groupList.First();
  12688. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  12689. group = groupList.First(x => x.Id == diid);
  12690. if (group == null)
  12691. {
  12692. jw.Msg = "暂无团组!";
  12693. return Ok(jw);
  12694. }
  12695. var data = new
  12696. {
  12697. groupList = groupList.Select(x => new
  12698. {
  12699. x.TeamName,
  12700. x.Id
  12701. }),
  12702. content = new ArrayList(),
  12703. groupInfo = new
  12704. {
  12705. group.VisitDays,
  12706. group.TourCode,
  12707. group.VisitPNumber,
  12708. group.TeamName,
  12709. group.Id,
  12710. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  12711. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  12712. },
  12713. };
  12714. var resultArr = new ArrayList();
  12715. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  12716. if (content.Count == 0)
  12717. {
  12718. var stay = "-";
  12719. var cityPath = "-";
  12720. //添加城市路径以及住宿地
  12721. //黑屏代码数据
  12722. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12723. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12724. {
  12725. jw = JsonView(true, "黑屏代码有误!", data);
  12726. return Ok(jw);
  12727. }
  12728. foreach (DataRow row in dtBlack.Rows)
  12729. {
  12730. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12731. {
  12732. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  12733. return Ok(jw);
  12734. }
  12735. }
  12736. //黑屏代码获取时间区间
  12737. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12738. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12739. _sqlSugar.BeginTran();
  12740. for (int i = 0; i < timeArr.Count; i++)
  12741. {
  12742. stay = "-";
  12743. cityPath = "-";
  12744. DateTime NewData = DateTime.Parse(timeArr[i]);
  12745. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12746. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12747. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12748. if (tbSelect.Length > 0)
  12749. {
  12750. List<string> threeCodeStr = new List<string>();
  12751. foreach (var item in tbSelect)
  12752. {
  12753. var threeCode = item["Three"].ToString() ?? "";
  12754. if (threeCode.Length == 6)
  12755. {
  12756. var start = threeCode.Substring(0, 3);
  12757. var end = threeCode.Substring(3, 3);
  12758. if (threeCodeStr.Count == 0)
  12759. {
  12760. threeCodeStr.Add(start);
  12761. threeCodeStr.Add(end);
  12762. }
  12763. else
  12764. {
  12765. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12766. {
  12767. threeCodeStr.Add(end);
  12768. }
  12769. else
  12770. {
  12771. threeCodeStr.Add(start);
  12772. threeCodeStr.Add(end);
  12773. }
  12774. }
  12775. }
  12776. }
  12777. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12778. var last = threeCodeStr.Last();
  12779. foreach (var item in threeCodeStr)
  12780. {
  12781. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12782. if (item.Equals(last))
  12783. {
  12784. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12785. }
  12786. }
  12787. cityPath = cityPath.Trim('-');
  12788. }
  12789. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12790. appro.Diid = diid ?? -1;
  12791. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12792. appro.Id = thisId;
  12793. appro.CreateUserId = dto.UserId;
  12794. appro.CreateTime = DateTime.Now;
  12795. content.Add(appro);
  12796. }
  12797. _sqlSugar.CommitTran();
  12798. }
  12799. foreach (var x in content)
  12800. {
  12801. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  12802. if (chiList.Count < chiNumber)
  12803. {
  12804. for (int i = chiList.Count; i < chiNumber; i++)
  12805. {
  12806. chiList.Add(new Grp_ApprovalTravelDetails());
  12807. }
  12808. }
  12809. resultArr.Add(new
  12810. {
  12811. x.Id,
  12812. x.Date,
  12813. x.Diid,
  12814. chiList = chiList.Select(x1 => new
  12815. {
  12816. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12817. x1.Details,
  12818. x1.ParentId,
  12819. x1.Id
  12820. })
  12821. });
  12822. }
  12823. data = data with
  12824. {
  12825. content = resultArr,
  12826. };
  12827. jw = JsonView(true, "获取成功!", data);
  12828. return Ok(jw);
  12829. }
  12830. /// <summary>
  12831. /// 报批行程删除
  12832. /// </summary>
  12833. /// <param name="dto"></param>
  12834. /// <returns></returns>
  12835. [HttpPost]
  12836. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  12837. {
  12838. var jw = JsonView(false);
  12839. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12840. if (group == null)
  12841. {
  12842. jw.Msg = "团组参数有误!";
  12843. return Ok(jw);
  12844. }
  12845. try
  12846. {
  12847. _sqlSugar.BeginTran();
  12848. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  12849. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  12850. {
  12851. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12852. DeleteUserId = dto.uesrId,
  12853. IsDel = 1
  12854. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  12855. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  12856. {
  12857. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12858. DeleteUserId = dto.uesrId,
  12859. IsDel = 1
  12860. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  12861. _sqlSugar.CommitTran();
  12862. jw = JsonView(true, "删除成功");
  12863. }
  12864. catch (Exception ex)
  12865. {
  12866. jw = JsonView(false, ex.Message);
  12867. }
  12868. return Ok(jw);
  12869. }
  12870. /// <summary>
  12871. /// 报批行程保存
  12872. /// </summary>
  12873. /// <param name="dto"></param>
  12874. /// <returns></returns>
  12875. [HttpPost]
  12876. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  12877. {
  12878. var jw = JsonView(false);
  12879. var Find = dto.Arr.Find(x => x.id == 0);
  12880. if (Find != null)
  12881. {
  12882. jw.Msg = "生成的ID为0!";
  12883. return Ok(jw);
  12884. }
  12885. foreach (var item in dto.Arr)
  12886. {
  12887. foreach (var chi in item.chiList)
  12888. {
  12889. if (chi.parentId == 0)
  12890. {
  12891. chi.parentId = item.id;
  12892. }
  12893. }
  12894. }
  12895. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  12896. _sqlSugar.BeginTran();
  12897. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  12898. {
  12899. var parentIds = dto.Arr.Select(x => x.id).ToList();
  12900. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  12901. {
  12902. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12903. DeleteUserId = dto.UserId,
  12904. IsDel = 1
  12905. }).ExecuteCommand();
  12906. }
  12907. try
  12908. {
  12909. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  12910. {
  12911. CreateTime = DateTime.Now,
  12912. CreateUserId = dto.UserId,
  12913. Details = x.details,
  12914. ParentId = x.parentId,
  12915. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12916. Remark = "",
  12917. IsDel = 0
  12918. }).ToList()).ExecuteCommand();
  12919. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  12920. {
  12921. Id = x.id,
  12922. Details = x.details,
  12923. ParentId = x.parentId,
  12924. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12925. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  12926. {
  12927. Details = x.Details,
  12928. ParentId = x.ParentId,
  12929. Time = x.Time
  12930. }).ExecuteCommand();
  12931. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  12932. {
  12933. Id = x.id,
  12934. Date = x.date,
  12935. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  12936. {
  12937. Date = x.Date
  12938. }).ExecuteCommand();
  12939. _sqlSugar.CommitTran();
  12940. jw = JsonView(true, "保存成功!");
  12941. }
  12942. catch (Exception ex)
  12943. {
  12944. _sqlSugar.RollbackTran();
  12945. jw = JsonView(false, "保存失败!" + ex.Message);
  12946. }
  12947. return Ok(jw);
  12948. }
  12949. /// <summary>
  12950. /// 报批行程生成
  12951. /// </summary>
  12952. /// <param name="dto"></param>
  12953. /// <returns></returns>
  12954. [HttpPost]
  12955. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  12956. {
  12957. var jw = JsonView(false);
  12958. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12959. if (group == null)
  12960. {
  12961. jw.Msg = "暂无该团组!";
  12962. return Ok(jw);
  12963. }
  12964. //黑屏代码数据
  12965. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12966. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12967. {
  12968. jw.Msg = "黑屏代码有误!";
  12969. return Ok(jw);
  12970. }
  12971. foreach (DataRow row in dtBlack.Rows)
  12972. {
  12973. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12974. {
  12975. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  12976. return Ok(jw);
  12977. }
  12978. }
  12979. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12980. var resultArr = new ArrayList();
  12981. if (officialActivitiesArr.Count == 0)
  12982. {
  12983. jw.Msg = "暂无公务出访信息!";
  12984. return Ok(jw);
  12985. }
  12986. try
  12987. {
  12988. _sqlSugar.BeginTran();
  12989. DeleteApprovalJourney(new
  12990. Domain.Dtos.Groups.DeleteApprovalJourney
  12991. {
  12992. Diid = dto.Diid,
  12993. uesrId = dto.Userid
  12994. });
  12995. var stay = "-";
  12996. var cityPath = "-";
  12997. //添加城市路径以及住宿地
  12998. //黑屏代码获取时间区间
  12999. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  13000. var empty = "【未收入该三字码!请机票同事录入】";
  13001. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  13002. for (int i = 0; i < timeArr.Count; i++)
  13003. {
  13004. stay = "-";
  13005. cityPath = "-";
  13006. var chiarr = new List<Grp_ApprovalTravelDetails>();
  13007. DateTime NewData = DateTime.Parse(timeArr[i]);
  13008. 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();
  13009. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  13010. if (tbSelect.Length > 0)
  13011. {
  13012. List<string> threeCodeStr = new List<string>();
  13013. bool isTrade = false;
  13014. string trip = string.Empty;
  13015. var rowLast = tbSelect.Last();
  13016. var rowFirst = tbSelect.First();
  13017. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  13018. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  13019. var takeOffTime = DateTime.Parse(timeArr[i]);
  13020. var fallToTime = DateTime.Parse(timeArr[i]);
  13021. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  13022. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  13023. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  13024. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  13025. foreach (var item in tbSelect)
  13026. {
  13027. var start = string.Empty;
  13028. var end = string.Empty;
  13029. var threeCode = item["Three"].ToString() ?? "";
  13030. if (threeCode.Length == 6)
  13031. {
  13032. start = threeCode.Substring(0, 3);
  13033. end = threeCode.Substring(3, 3);
  13034. if (threeCodeStr.Count == 0)
  13035. {
  13036. threeCodeStr.Add(start);
  13037. threeCodeStr.Add(end);
  13038. }
  13039. else
  13040. {
  13041. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  13042. {
  13043. threeCodeStr.Add(end);
  13044. }
  13045. else
  13046. {
  13047. threeCodeStr.Add(start);
  13048. threeCodeStr.Add(end);
  13049. }
  13050. }
  13051. }
  13052. //处理机票信息
  13053. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  13054. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  13055. if (start_Object == null)
  13056. {
  13057. start_Object = new Res_ThreeCode()
  13058. {
  13059. AirPort = empty,
  13060. AirPort_En = empty,
  13061. City = empty,
  13062. Country = empty,
  13063. Four = empty,
  13064. Three = empty,
  13065. };
  13066. }
  13067. if (end_Object == null)
  13068. {
  13069. end_Object = new Res_ThreeCode()
  13070. {
  13071. AirPort = empty,
  13072. AirPort_En = empty,
  13073. City = empty,
  13074. Country = empty,
  13075. Four = empty,
  13076. Three = empty,
  13077. };
  13078. }
  13079. //机型判断
  13080. string airModel = item["AirModel"].ToString();
  13081. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  13082. string flightTime = item["FlightTime"].ToString();
  13083. if (flightTime!.Contains(":"))
  13084. {
  13085. flightTime = flightTime.Replace(":", "小时");
  13086. flightTime += "分钟";
  13087. }
  13088. if (flightTime.Contains("H"))
  13089. {
  13090. flightTime = flightTime.Replace("H", "小时");
  13091. }
  13092. if (flightTime.Contains("M"))
  13093. {
  13094. flightTime = flightTime.Replace("M", "分钟");
  13095. }
  13096. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  13097. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  13098. {
  13099. flightTime = flightDataTime.Hour > 0
  13100. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  13101. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  13102. ? flightDataTime.Minute.ToString() + "分钟" : "";
  13103. }
  13104. //航班号
  13105. string flightcode = item["Fliagtcode"].ToString();
  13106. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  13107. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  13108. if (aircompany == null)
  13109. {
  13110. aircompany = new Res_AirCompany
  13111. {
  13112. CnName = hsEmpty,
  13113. EnName = hsEmpty,
  13114. ShortCode = hsEmpty,
  13115. };
  13116. }
  13117. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  13118. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  13119. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  13120. if (isTrade)
  13121. {
  13122. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  13123. }
  13124. else
  13125. {
  13126. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  13127. }
  13128. }
  13129. chiarr.Add(new Grp_ApprovalTravelDetails
  13130. {
  13131. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  13132. CreateTime = DateTime.Now,
  13133. CreateUserId = dto.Userid,
  13134. ParentId = 0,
  13135. Details = trip
  13136. });
  13137. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  13138. var last = threeCodeStr.Last();
  13139. foreach (var item in threeCodeStr)
  13140. {
  13141. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  13142. if (item.Equals(last))
  13143. {
  13144. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  13145. }
  13146. }
  13147. cityPath = cityPath.Trim('-');
  13148. }
  13149. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  13150. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  13151. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  13152. appro.Diid = dto.Diid;
  13153. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  13154. appro.Id = thisId;
  13155. appro.CreateUserId = dto.Userid;
  13156. appro.CreateTime = DateTime.Now;
  13157. foreach (var item in gwinfo)
  13158. {
  13159. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  13160. chi.Details = "拜访" + item.Client;
  13161. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  13162. {
  13163. chi.Details += "," + item.ReqSample;
  13164. }
  13165. chi.ParentId = thisId;
  13166. chi.Time = item.Time;
  13167. chiarr.Add(chi);
  13168. }
  13169. if (chiarr.Count < 5)
  13170. {
  13171. for (int j = chiarr.Count; j < 5; j++)
  13172. {
  13173. chiarr.Add(new
  13174. Grp_ApprovalTravelDetails());
  13175. }
  13176. }
  13177. resultArr.Add(new
  13178. {
  13179. appro.Id,
  13180. appro.Date,
  13181. appro.Diid,
  13182. chiList = chiarr.Select(x1 => new
  13183. {
  13184. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  13185. x1.Details,
  13186. x1.ParentId,
  13187. x1.Id
  13188. })
  13189. });
  13190. }
  13191. _sqlSugar.CommitTran();
  13192. jw = JsonView(true, "生成成功!", resultArr);
  13193. }
  13194. catch (Exception ex)
  13195. {
  13196. jw.Code = 400;
  13197. jw.Msg = "生成失败!" + ex.Message;
  13198. }
  13199. return Ok(jw);
  13200. }
  13201. /// <summary>
  13202. /// 报批行程word导出
  13203. /// </summary>
  13204. /// <param name="dto"></param>
  13205. /// <returns></returns>
  13206. [HttpPost]
  13207. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  13208. {
  13209. var jw = JsonView(false);
  13210. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13211. if (group == null)
  13212. {
  13213. jw.Msg = "暂无该团组!";
  13214. return Ok(jw);
  13215. }
  13216. //模板路径
  13217. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  13218. //载入模板
  13219. Document doc = new Document(tempPath);
  13220. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13221. //获取所填表格的序数
  13222. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13223. Aspose.Words.Tables.Row titleRowClone = null;
  13224. Aspose.Words.Tables.Row CenterRowClone = null;
  13225. int index = 0;
  13226. int indexChi = 0;
  13227. int SetIndex = 0;
  13228. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  13229. //获取数据,放到datatable
  13230. foreach (var item in ApprovalTravelArr)
  13231. {
  13232. if (index > 0)
  13233. {
  13234. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  13235. tableOne.AppendChild(titleRowClone);
  13236. }
  13237. var textTime = item.Date;
  13238. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  13239. SetCells(tableOne, doc, SetIndex, 0, textTime);
  13240. SetIndex++;
  13241. if (ChiRep.Count > 0)
  13242. {
  13243. foreach (var itemChi in ChiRep)
  13244. {
  13245. var txtTime = itemChi.Time;
  13246. var txtDetail = itemChi.Details;
  13247. if (indexChi > 0)
  13248. {
  13249. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13250. tableOne.AppendChild(CenterRowClone);
  13251. }
  13252. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  13253. {
  13254. SetCells(tableOne, doc, SetIndex, 0, "");
  13255. SetCells(tableOne, doc, SetIndex, 1, "");
  13256. indexChi++;
  13257. SetIndex++;
  13258. break;
  13259. }
  13260. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  13261. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  13262. indexChi++;
  13263. SetIndex++;
  13264. }
  13265. }
  13266. else
  13267. {
  13268. if (indexChi > 0)
  13269. {
  13270. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13271. tableOne.AppendChild(CenterRowClone);
  13272. }
  13273. SetCells(tableOne, doc, SetIndex, 0, "");
  13274. SetCells(tableOne, doc, SetIndex, 1, "");
  13275. indexChi++;
  13276. SetIndex++;
  13277. }
  13278. index++;
  13279. }
  13280. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  13281. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13282. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13283. jw.Code = 200;
  13284. jw.Msg = "";
  13285. return Ok(jw);
  13286. }
  13287. private string intToString(int numberVal)
  13288. {
  13289. string numberval = numberVal.ToString();
  13290. Dictionary<char, string> Number = new Dictionary<char, string>();
  13291. Number.Add('1', "一");
  13292. Number.Add('2', "二");
  13293. Number.Add('3', "三");
  13294. Number.Add('4', "四");
  13295. Number.Add('5', "五");
  13296. Number.Add('6', "六");
  13297. Number.Add('7', "七");
  13298. Number.Add('8', "八");
  13299. Number.Add('9', "九");
  13300. string stringNumberVal = string.Empty;
  13301. for (int i = 0; i < numberval.Length; i++)
  13302. {
  13303. if (i == 0)
  13304. {
  13305. stringNumberVal += Number[numberval[i]];
  13306. }
  13307. else if (i >= 1)
  13308. {
  13309. if (numberval[i] == '0')
  13310. {
  13311. stringNumberVal = "十";
  13312. }
  13313. else
  13314. {
  13315. stringNumberVal += "十" + Number[numberval[i]];
  13316. }
  13317. }
  13318. }
  13319. return stringNumberVal;
  13320. }
  13321. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  13322. {
  13323. //获取table中的某个单元格,从0开始
  13324. Cell lshCell = table.Rows[rows].Cells[cells];
  13325. //将单元格中段落移除
  13326. foreach (Node item in lshCell.Paragraphs)
  13327. {
  13328. lshCell.Paragraphs.Remove(item);
  13329. }
  13330. if (val.Contains("\r\n"))
  13331. {
  13332. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  13333. foreach (var item in spArr)
  13334. {
  13335. //新建一个段落
  13336. Paragraph p = new Paragraph(doc);
  13337. var r = new Run(doc, item);
  13338. //把设置的值赋给之前新建的段落
  13339. p.AppendChild(r);
  13340. //将此段落加到单元格内
  13341. lshCell.AppendChild(p);
  13342. }
  13343. }
  13344. else
  13345. {
  13346. //新建一个段落
  13347. Paragraph p = new Paragraph(doc);
  13348. var r = new Run(doc, val);
  13349. //把设置的值赋给之前新建的段落
  13350. p.AppendChild(r);
  13351. //将此段落加到单元格内
  13352. lshCell.AppendChild(p);
  13353. }
  13354. }
  13355. [HttpPost]
  13356. public async Task<IActionResult> ServerHttp(string paramStr)
  13357. {
  13358. paramStr = paramStr.TrimEnd('\'');
  13359. paramStr = paramStr.TrimStart('\'');
  13360. JsonView jw = JsonView(false);
  13361. JObject param = JObject.Parse(paramStr);
  13362. if (!param.ContainsKey("url"))
  13363. {
  13364. jw.Msg = "url null";
  13365. return Ok(jw);
  13366. }
  13367. string url = param["url"]!.ToString();
  13368. var methon = "get";
  13369. Dictionary<string, string> headValues = null;
  13370. string bodyStr = string.Empty;
  13371. if (param.ContainsKey("methon"))
  13372. {
  13373. methon = param["methon"]!.ToString().ToLower();
  13374. }
  13375. if (param.ContainsKey("header"))
  13376. {
  13377. var header = param["header"]!.ToString();
  13378. JObject headerJobject = JObject.Parse(header);
  13379. headValues = new Dictionary<string, string>();
  13380. foreach (JProperty item in headerJobject.Properties())
  13381. {
  13382. var value = item.Value.ToString();
  13383. var head = item.Path;
  13384. headValues.Add(head, value);
  13385. }
  13386. }
  13387. HttpClient client = new HttpClient();
  13388. string responseString = string.Empty;
  13389. StringContent content = null;
  13390. if (headValues != null)
  13391. {
  13392. foreach (var item in headValues.Keys)
  13393. {
  13394. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  13395. {
  13396. if (param.ContainsKey("body"))
  13397. {
  13398. bodyStr = param["body"]!.ToString();
  13399. }
  13400. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  13401. }
  13402. else
  13403. {
  13404. client.DefaultRequestHeaders.Add(item, headValues[item]);
  13405. }
  13406. }
  13407. }
  13408. try
  13409. {
  13410. if (methon == "get")
  13411. {
  13412. responseString = await client.GetStringAsync(url);
  13413. }
  13414. else if (methon == "post")
  13415. {
  13416. var request = new HttpRequestMessage(HttpMethod.Post, url)
  13417. {
  13418. Content = content
  13419. };
  13420. var response = await client.SendAsync(request);
  13421. try
  13422. {
  13423. Stream responseStream = await response.Content.ReadAsStreamAsync();
  13424. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  13425. {
  13426. using (StreamReader reader = new StreamReader(gzipStream))
  13427. {
  13428. responseString = await reader.ReadToEndAsync();
  13429. }
  13430. }
  13431. }
  13432. catch (Exception)
  13433. {
  13434. responseString = await response.Content.ReadAsStringAsync();
  13435. }
  13436. }
  13437. else
  13438. {
  13439. responseString = "methon error";
  13440. }
  13441. jw = JsonView(true, "success", responseString);
  13442. }
  13443. catch (Exception ex)
  13444. {
  13445. jw.Msg = "error " + ex.Message;
  13446. jw.Data = ex.StackTrace;
  13447. }
  13448. finally
  13449. {
  13450. client.Dispose();
  13451. }
  13452. return Ok(jw);
  13453. }
  13454. #endregion
  13455. #region 团组接待意见调查 Grp_ReceptionOpinionSurvey
  13456. /// <summary>
  13457. /// 团组接待意见调查 - 信息管理
  13458. /// 基础数据(团组)
  13459. /// </summary>
  13460. /// <param name="dto"></param>
  13461. /// <returns></returns>
  13462. [HttpGet]
  13463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13464. public async Task<IActionResult> OpinionaireInit()
  13465. {
  13466. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  13467. .Select(x => new
  13468. {
  13469. x.Id,
  13470. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  13471. })
  13472. .OrderByDescending(x => x.Id)
  13473. .ToListAsync();
  13474. return Ok(JsonView(groupData, groupData.Count));
  13475. }
  13476. /// <summary>
  13477. /// 团组接待意见调查 - 信息管理
  13478. /// 列表
  13479. /// </summary>
  13480. /// <param name="groupId"></param>
  13481. /// <returns></returns>
  13482. [HttpGet("{groupId}")]
  13483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13484. public async Task<IActionResult> OpinionaireManageList(int groupId)
  13485. {
  13486. if (groupId < 1) Ok(JsonView(false,"请传入有效的diId"));
  13487. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  13488. .Select(x => new
  13489. {
  13490. x.Id,
  13491. x.TourGuideName,
  13492. x.CityName,
  13493. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  13494. x.CreateTime
  13495. })
  13496. .OrderBy(x => x.Id)
  13497. .ToListAsync();
  13498. return Ok(JsonView(data));
  13499. }
  13500. /// <summary>
  13501. /// 团组接待意见调查 - 信息管理
  13502. /// 保存
  13503. /// </summary>
  13504. /// <param name="dto"></param>
  13505. /// <returns></returns>
  13506. [HttpPost]
  13507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13508. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  13509. {
  13510. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  13511. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  13512. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  13513. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  13514. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  13515. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  13516. _opinionaireRep.BeginTran();
  13517. if (addData != null && addData.Count > 0)
  13518. {
  13519. foreach (var item in addData)
  13520. {
  13521. item.CreateUserId = currUserInfo.UserId;
  13522. item.DiId = dto.DiId;
  13523. }
  13524. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  13525. }
  13526. if (updData != null && updData.Count > 0)
  13527. {
  13528. var upd = await _opinionaireRep._sqlSugar
  13529. .Updateable(updData)
  13530. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  13531. .WhereColumns(x =>new{ x.Id})
  13532. .ExecuteCommandAsync();
  13533. }
  13534. _opinionaireRep.CommitTran();
  13535. return Ok(JsonView("操作成功!"));
  13536. }
  13537. /// <summary>
  13538. /// 团组接待意见调查 - 信息管理
  13539. /// 删除
  13540. /// </summary>
  13541. /// <param name="id"></param>
  13542. /// <returns></returns>
  13543. [HttpDelete("{id}")]
  13544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13545. public async Task<IActionResult> OpinionaireManageDel(int id)
  13546. {
  13547. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  13548. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  13549. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  13550. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  13551. if (!del) return Ok(JsonView("操作失败!"));
  13552. return Ok(JsonView("操作成功!"));
  13553. }
  13554. /// <summary>
  13555. /// 团组接待意见调查 - 用户
  13556. /// 列表
  13557. /// </summary>
  13558. /// <param name="id"></param>
  13559. /// <returns></returns>
  13560. [HttpDelete("{diId}")]
  13561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13562. public async Task<IActionResult> OpinionaireUserList(int diId)
  13563. {
  13564. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  13565. var data = await _opinionaireRep.Query(x => x.DiId == diId)
  13566. .Select(x => new {
  13567. })
  13568. .ToListAsync();
  13569. return Ok(JsonView(data));
  13570. }
  13571. #endregion
  13572. // /// <summary>
  13573. // ///
  13574. // /// </summary>
  13575. // /// <param name="_dto"></param>
  13576. // /// <returns></returns>
  13577. // [HttpPost]
  13578. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13579. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  13580. // {
  13581. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  13582. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  13583. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  13584. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  13585. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  13586. // dic_psg.Add("客人", 974);
  13587. // dic_psg.Add("司机", 975);
  13588. // dic_psg.Add("导游", 976);
  13589. // dic_psg.Add("公司内部人员", 977);
  13590. // dic_psg.Add("司机/导游/公司内部人员", 978);
  13591. // foreach (var item in list_visa)
  13592. // {
  13593. // Grp_VisaInfo temp = new Grp_VisaInfo();
  13594. // temp.Id = item.Id;
  13595. // temp.DIId = item.DIId;
  13596. // temp.VisaClient = item.VisaClient;
  13597. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  13598. // temp.VisaCurrency = item.VisaCurrency;
  13599. // temp.IsThird = item.IsThird;
  13600. // if (dic_psg.ContainsKey(item.PassengerType))
  13601. // {
  13602. // temp.PassengerType = dic_psg[item.PassengerType];
  13603. // }
  13604. // else {
  13605. // temp.PassengerType = -1;
  13606. // }
  13607. // temp.VisaNumber = item.VisaNumber;
  13608. // temp.VisaFreeNumber = item.VisaFreeNumber;
  13609. // temp.CreateUserId = item.Operators;
  13610. // DateTime dt_ct;
  13611. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  13612. // if (b_ct)
  13613. // {
  13614. // temp.CreateTime = dt_ct;
  13615. // }
  13616. // else
  13617. // {
  13618. // temp.CreateTime = DateTime.Now;
  13619. // }
  13620. // temp.DeleteTime = "";
  13621. // temp.DeleteUserId = 0;
  13622. // temp.Remark = item.Remark;
  13623. // if (string.IsNullOrEmpty(temp.Remark)) {
  13624. // temp.Remark = "";
  13625. // }
  13626. // temp.IsDel = item.IsDel;
  13627. // temp.VisaDescription = item.VisaAttachment;
  13628. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  13629. //([Id]
  13630. // ,[DIId]
  13631. // ,[VisaClient]
  13632. // ,[VisaPrice]
  13633. // ,[VisaCurrency]
  13634. // ,[IsThird]
  13635. // ,[PassengerType]
  13636. // ,[VisaNumber]
  13637. // ,[VisaFreeNumber]
  13638. // ,[CreateUserId]
  13639. // ,[CreateTime]
  13640. // ,[DeleteTime]
  13641. // ,[DeleteUserId]
  13642. // ,[Remark]
  13643. // ,[IsDel]
  13644. // ,[visaDescription])
  13645. // VALUES
  13646. // ({0},{1},'{2}',{3},{4}
  13647. //,{5},{6},{7},{8},{9}
  13648. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  13649. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  13650. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  13651. //);
  13652. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  13653. // }
  13654. // return Ok(JsonView(true, "操作成功!"));
  13655. // }
  13656. /// <summary>
  13657. /// 123132123
  13658. /// </summary>
  13659. /// <param name="_dto"></param>
  13660. /// <returns></returns>
  13661. [HttpPost]
  13662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13663. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  13664. {
  13665. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  13666. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  13667. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  13668. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  13669. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  13670. dicDetail.Add(789, 1034);
  13671. dicDetail.Add(790, 1035);
  13672. dicDetail.Add(791, 1036);
  13673. dicDetail.Add(792, 1037);
  13674. dicDetail.Add(793, 1038);
  13675. dicDetail.Add(794, 1039);
  13676. dicDetail.Add(795, 1040);
  13677. dicDetail.Add(796, 1041);
  13678. dicDetail.Add(797, 1042);
  13679. dicDetail.Add(798, 1043);
  13680. dicDetail.Add(801, 1044);
  13681. dicDetail.Add(802, 1045);
  13682. dicDetail.Add(803, 1046);
  13683. Dictionary<int, int> dic = new Dictionary<int, int>();
  13684. dic.Add(806, 1027);
  13685. dic.Add(807, 1028);
  13686. dic.Add(808, 1029);
  13687. dic.Add(809, 1030);
  13688. dic.Add(810, 1031);
  13689. dic.Add(811, 1032);
  13690. dic.Add(812, 1033);
  13691. foreach (var item in list_visa)
  13692. {
  13693. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  13694. temp.Coefficient = item.coefficient;
  13695. DateTime dtCrt;
  13696. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  13697. if (b1)
  13698. {
  13699. temp.CreateTime = dtCrt;
  13700. }
  13701. else
  13702. {
  13703. temp.CreateTime = DateTime.Now;
  13704. }
  13705. temp.CreateUserId = item.Operators;
  13706. temp.DeleteTime = "";
  13707. temp.DeleteUserId = 0;
  13708. temp.DiId = int.Parse(item.DIID);
  13709. temp.FilePath = item.FilePath;
  13710. temp.IsDel = item.IsDel;
  13711. temp.Price = item.Price;
  13712. temp.PriceCount = 1;
  13713. temp.PriceCurrency = item.Currency;
  13714. int detailId = 0;
  13715. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  13716. {
  13717. detailId = dicDetail[item.PriceTypeDetail];
  13718. }
  13719. temp.PriceDetailType = detailId;
  13720. temp.PriceDt = DateTime.Now;
  13721. temp.PriceName = item.PriceName;
  13722. temp.PriceSum = item.Price;
  13723. int tid = 0;
  13724. if (dic.ContainsKey(item.PriceType))
  13725. {
  13726. tid = dic[item.PriceType];
  13727. }
  13728. temp.PriceType = tid;
  13729. temp.Remark = item.Remark;
  13730. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  13731. }
  13732. return Ok(JsonView(true, "操作成功!"));
  13733. }
  13734. }
  13735. }