GroupsController.cs 711 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using Microsoft.AspNetCore.SignalR;
  6. using MySqlX.XDevAPI.Relational;
  7. using NPOI.HSSF.UserModel;
  8. using NPOI.SS.Format;
  9. using NPOI.SS.UserModel;
  10. using NPOI.SS.Util;
  11. using NPOI.XSSF.UserModel;
  12. using OASystem.API.OAMethodLib;
  13. using OASystem.API.OAMethodLib.File;
  14. using OASystem.API.OAMethodLib.Hub.HubClients;
  15. using OASystem.API.OAMethodLib.Hub.Hubs;
  16. using OASystem.API.OAMethodLib.JuHeAPI;
  17. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  18. using OASystem.Domain.Dtos.CRM;
  19. using OASystem.Domain.Dtos.FileDto;
  20. using OASystem.Domain.Dtos.Financial;
  21. using OASystem.Domain.Dtos.Groups;
  22. using OASystem.Domain.Entities.Customer;
  23. using OASystem.Domain.Entities.Financial;
  24. using OASystem.Domain.Entities.Groups;
  25. using OASystem.Domain.ViewModels.Groups;
  26. using OASystem.Infrastructure.Repositories.Financial;
  27. using OASystem.Infrastructure.Repositories.Groups;
  28. using Quartz.Util;
  29. using SqlSugar;
  30. using SqlSugar.Extensions;
  31. using System.Collections;
  32. using System.Data;
  33. using System.Diagnostics;
  34. using System.Globalization;
  35. using System.IO;
  36. using System.Reflection.PortableExecutable;
  37. using Ubiety.Dns.Core;
  38. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  39. using Bookmark = Aspose.Words.Bookmark;
  40. using Cell = Aspose.Words.Tables.Cell;
  41. using Table = Aspose.Words.Tables.Table;
  42. namespace OASystem.API.Controllers
  43. {
  44. /// <summary>
  45. /// 团组相关
  46. /// </summary>
  47. //[Authorize]
  48. [Route("api/[controller]/[action]")]
  49. public class GroupsController : ControllerBase
  50. {
  51. private readonly ILogger<GroupsController> _logger;
  52. private readonly GrpScheduleRepository _grpScheduleRep;
  53. private readonly IMapper _mapper;
  54. private readonly DelegationInfoRepository _groupRepository;
  55. private readonly TaskAssignmentRepository _taskAssignmentRep;
  56. private readonly AirTicketResRepository _airTicketResRep;
  57. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  58. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  59. private readonly DelegationEnDataRepository _delegationEnDataRep;
  60. private readonly DelegationVisaRepository _delegationVisaRep;
  61. private readonly VisaPriceRepository _visaPriceRep;
  62. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  63. private readonly HotelPriceRepository _hotelPriceRep;
  64. private readonly CustomersRepository _customersRep;
  65. private readonly MessageRepository _message;
  66. private readonly SqlSugarClient _sqlSugar;
  67. private readonly TourClientListRepository _tourClientListRep;
  68. private readonly TeamRateRepository _teamRateRep;
  69. #region 成本相关
  70. private readonly CheckBoxsRepository _checkBoxs;
  71. private readonly GroupCostRepository _GroupCostRepository;
  72. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  73. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  74. #endregion
  75. private readonly SetDataRepository _setDataRep;
  76. private string url;
  77. private string path;
  78. private readonly EnterExitCostRepository _enterExitCostRep;
  79. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  80. private readonly UsersRepository _usersRep;
  81. private readonly IJuHeApiService _juHeApi;
  82. private readonly InvertedListRepository _invertedListRep;
  83. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  84. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  85. private readonly ThreeCodeRepository _threeCodeRepository;
  86. private readonly HotelInquiryRepository _hotelInquiryRep;
  87. private readonly FeeAuditRepository _feeAuditRep;
  88. private readonly VisaCommissionRepository _visaCommissionRep;
  89. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  90. public GroupsController(ILogger<GroupsController> logger, IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  91. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  92. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  93. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  94. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  95. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  96. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  97. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
  98. ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep, VisaCommissionRepository visaCommissionRep, ForeignReceivablesRepository ffrRep)
  99. {
  100. _logger = logger;
  101. _mapper = mapper;
  102. _grpScheduleRep = grpScheduleRep;
  103. _groupRepository = groupRepository;
  104. _taskAssignmentRep = taskAssignmentRep;
  105. _airTicketResRep = airTicketResRep;
  106. _sqlSugar = sqlSugar;
  107. url = AppSettingsHelper.Get("ExcelBaseUrl");
  108. path = AppSettingsHelper.Get("ExcelBasePath");
  109. if (!System.IO.Directory.Exists(path))
  110. {
  111. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  112. }
  113. _decreasePaymentsRep = decreasePaymentsRep;
  114. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  115. _delegationEnDataRep = delegationEnDataRep;
  116. _enterExitCostRep = enterExitCostRep;
  117. _delegationVisaRep = delegationVisaRep;
  118. _message = message;
  119. _visaPriceRep = visaPriceRep;
  120. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  121. _checkBoxs = checkBoxs;
  122. _GroupCostRepository = GroupCostRepository;
  123. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  124. _GroupCostParameterRepository = GroupCostParameterRepository;
  125. _hotelPriceRep = hotelPriceRep;
  126. _customersRep = customersRep;
  127. _setDataRep = setDataRep;
  128. _tourClientListRep = tourClientListRep;
  129. _teamRateRep = teamRateRep;
  130. _hubContext = hubContext;
  131. _usersRep = usersRep;
  132. _juHeApi = juHeApi;
  133. _invertedListRep = invertedListRep;
  134. _visaFeeInfoRep = visaFeeInfoRep;
  135. _ticketBlackCodeRep = ticketBlackCodeRep;
  136. _hotelInquiryRep = hotelInquiryRep;
  137. _threeCodeRepository = threeCodeRepository;
  138. _feeAuditRep = feeAuditRep;
  139. _visaCommissionRep = visaCommissionRep;
  140. _ffrRep = ffrRep;
  141. }
  142. #region 流程管控
  143. /// <summary>
  144. /// 获取团组流程管控信息
  145. /// </summary>
  146. /// <param name="paras">参数Json字符串</param>
  147. /// <returns></returns>
  148. [HttpPost]
  149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  150. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  151. {
  152. if (string.IsNullOrEmpty(_jsonDto.Paras))
  153. {
  154. return Ok(JsonView(false, "参数为空"));
  155. }
  156. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  157. if (_ScheduleDto != null)
  158. {
  159. if (_ScheduleDto.SearchType == 2)//获取列表
  160. {
  161. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  162. return Ok(JsonView(_grpScheduleViewList));
  163. }
  164. else//获取对象
  165. {
  166. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  167. if (_grpScheduleView != null)
  168. {
  169. return Ok(JsonView(_grpScheduleView));
  170. }
  171. }
  172. }
  173. else
  174. {
  175. return Ok(JsonView(false, "参数反序列化失败"));
  176. }
  177. return Ok(JsonView(false, "暂无数据!"));
  178. }
  179. /// <summary>
  180. /// 修改团组流程管控详细表数据
  181. /// </summary>
  182. /// <param name="paras"></param>
  183. /// <returns></returns>
  184. [HttpPost]
  185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  186. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  187. {
  188. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  189. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  190. .SetColumns(it => it.Duty == _detail.Duty)
  191. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  192. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  193. .SetColumns(it => it.JobContent == _detail.JobContent)
  194. .SetColumns(it => it.Remark == _detail.Remark)
  195. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  196. .Where(s => s.Id == dto.Id)
  197. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  198. .ExecuteCommandAsync();
  199. if (result > 0)
  200. {
  201. return Ok(JsonView(true, "保存成功!"));
  202. }
  203. return Ok(JsonView(false, "保存失败!"));
  204. }
  205. /// <summary>
  206. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  207. /// </summary>
  208. /// <param name="dto"></param>
  209. /// <returns></returns>
  210. [HttpPost]
  211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  212. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  213. {
  214. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  215. _detail.IsDel = 1;
  216. _detail.DeleteUserId = dto.Duty;
  217. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  218. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  219. .SetColumns(it => it.IsDel == _detail.IsDel)
  220. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  221. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  222. .Where(it => it.Id == dto.Id)
  223. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  224. //.WhereColumns(s => s.Id == dto.Id)
  225. .ExecuteCommandAsync();
  226. if (result > 0)
  227. {
  228. return Ok(JsonView(true, "删除成功!"));
  229. }
  230. return Ok(JsonView(false, "删除失败!"));
  231. }
  232. /// <summary>
  233. /// 增加团组流程管控详细表数据
  234. /// </summary>
  235. /// <param name="dto"></param>
  236. /// <returns></returns>
  237. [HttpPost]
  238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  239. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  240. {
  241. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  242. if (DateTime.Now < _detail.ExpectBeginDt)
  243. {
  244. _detail.StepStatus = 0;
  245. }
  246. else
  247. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  248. _detail.StepStatus = 1;
  249. }
  250. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  251. if (result > 0)
  252. {
  253. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  254. return Ok(JsonView(true, "添加成功!", _result));
  255. }
  256. return Ok(JsonView(false, "添加失败!"));
  257. }
  258. #endregion
  259. #region 团组基本信息
  260. /// <summary>
  261. /// 接团信息列表
  262. /// </summary>
  263. /// <param name="dto">团组列表请求dto</param>
  264. /// <returns></returns>
  265. [HttpPost]
  266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  267. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  268. {
  269. var groupData = await _groupRepository.GetGroupList(dto);
  270. if (groupData.Code != 0)
  271. {
  272. return Ok(JsonView(false, groupData.Msg));
  273. }
  274. return Ok(JsonView(groupData.Data));
  275. }
  276. /// <summary>
  277. /// 分页查询团组列表
  278. /// </summary>
  279. /// <param name="dto"></param>
  280. /// <returns></returns>
  281. [HttpPost]
  282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  283. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  284. {
  285. var watch = new Stopwatch();
  286. watch.Start();
  287. RefAsync<int> total = 0;
  288. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  289. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  290. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  291. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  292. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName , di.VisitPNumber , di.VisitCountry, di.VisitDays, di.VisitStartDate , di.VisitEndDate, di.TourCode })
  293. .Distinct()
  294. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  295. watch.Stop();
  296. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  297. }
  298. /// <summary>
  299. /// 接团信息列表 Page
  300. /// </summary>
  301. /// <param name="dto">团组列表请求dto</param>
  302. /// <returns></returns>
  303. [HttpPost]
  304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  305. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  306. {
  307. #region 参数验证
  308. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  309. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  310. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  311. #region 页面操作权限验证
  312. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  313. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  314. #endregion
  315. #endregion
  316. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  317. {
  318. string sqlWhere = string.Empty;
  319. if (dto.IsSure == 0) //未完成
  320. {
  321. sqlWhere += string.Format(@" And IsSure = 0");
  322. }
  323. else if (dto.IsSure == 1) //已完成
  324. {
  325. sqlWhere += string.Format(@" And IsSure = 1");
  326. }
  327. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  328. {
  329. string tj = dto.SearchCriteria;
  330. 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}%')",
  331. tj, tj, tj, tj, tj);
  332. }
  333. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  334. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  335. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  336. JietuanOperator,IsSure,CreateTime,IsBid
  337. From (
  338. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  339. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  340. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  341. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  342. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  343. From Grp_DelegationInfo gdi
  344. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  345. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  346. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  347. Where gdi.IsDel = 0 {0}
  348. ) temp", sqlWhere);
  349. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  350. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  351. #region 处理所属部门
  352. /*
  353. * 1.sq 和 gyy 等显示 市场部
  354. * 2.王鸽和主管及张总还有管理员号统一国交部
  355. * 2-1. 4 管理员 ,21 张海麟
  356. */
  357. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  358. List<int> userIds1 = new List<int>() { 4, 21 };
  359. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  360. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  361. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  362. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  363. .ToList();
  364. foreach (var item in _DelegationList)
  365. {
  366. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  367. }
  368. #endregion
  369. var _view = new
  370. {
  371. PageFuncAuth = pageFunAuthView,
  372. Data = _DelegationList
  373. };
  374. return Ok(JsonView(true, "查询成功!", _view, total));
  375. }
  376. else
  377. {
  378. return Ok(JsonView(false, "查询失败"));
  379. }
  380. }
  381. /// <summary>
  382. /// 团组列表
  383. /// </summary>
  384. /// <returns></returns>
  385. [HttpPost]
  386. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  387. {
  388. #region 参数验证
  389. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  390. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  391. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  392. #region 页面操作权限验证
  393. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  394. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  395. #endregion
  396. #endregion
  397. if (dto.PortType != 1 && dto.PortType != 2)
  398. {
  399. return Ok(JsonView(false, "查询失败!"));
  400. }
  401. string orderbyStr = "order by gdi.CreateTime Desc";
  402. string sqlWhere = string.Empty;
  403. if (dto.IsSure == 0) //未完成
  404. {
  405. sqlWhere += string.Format(@" And IsSure = 0");
  406. }
  407. else if (dto.IsSure == 1) //已完成
  408. {
  409. sqlWhere += string.Format(@" And IsSure = 1");
  410. }
  411. //团组类型
  412. if (dto.TeamDid > 0)
  413. {
  414. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  415. }
  416. //团组名称
  417. if (!string.IsNullOrEmpty(dto.TeamName))
  418. {
  419. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  420. }
  421. //客户名称
  422. if (!string.IsNullOrEmpty(dto.ClientName))
  423. {
  424. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  425. }
  426. //客户单位
  427. if (!string.IsNullOrEmpty(dto.ClientUnit))
  428. {
  429. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  430. }
  431. //出访时间
  432. if (!string.IsNullOrEmpty(dto.visitDataTime))
  433. {
  434. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  435. orderbyStr = "order by gdi.VisitDate";
  436. }
  437. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  438. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  439. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  440. JietuanOperator,IsSure,CreateTime
  441. From (
  442. Select row_number() over({0}) as Row_Number,
  443. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  444. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  445. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  446. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  447. From Grp_DelegationInfo gdi
  448. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  449. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  450. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  451. Where gdi.IsDel = 0 {1}
  452. ) temp ", orderbyStr, sqlWhere);
  453. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  454. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  455. #region 处理所属部门
  456. /*
  457. * 1.sq 和 gyy 等显示 市场部
  458. * 2.王鸽和主管及张总还有管理员号统一国交部
  459. * 2-1. 4 管理员 ,21 张海麟
  460. */
  461. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  462. List<int> userIds1 = new List<int>() { 4, 21 };
  463. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  464. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  465. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  466. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  467. .ToList();
  468. foreach (var item in _DelegationList)
  469. {
  470. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  471. }
  472. #endregion
  473. var _view = new
  474. {
  475. PageFuncAuth = pageFunAuthView,
  476. Data = _DelegationList
  477. };
  478. return Ok(JsonView(true, "查询成功!", _view, total));
  479. }
  480. /// <summary>
  481. /// 接团信息详情
  482. /// </summary>
  483. /// <param name="dto">团组info请求dto</param>
  484. /// <returns></returns>
  485. [HttpPost]
  486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  487. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  488. {
  489. var groupData = await _groupRepository.GetGroupInfo(dto);
  490. if (groupData.Code != 0)
  491. {
  492. return Ok(JsonView(false, groupData.Msg));
  493. }
  494. return Ok(JsonView(groupData.Data));
  495. }
  496. /// <summary>
  497. /// 接团信息 编辑添加
  498. /// 基础信息数据源
  499. /// </summary>
  500. /// <param name="dto"></param>
  501. /// <returns></returns>
  502. [HttpPost]
  503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  504. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  505. {
  506. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  507. if (groupData.Code != 0)
  508. {
  509. return Ok(JsonView(false, groupData.Msg));
  510. }
  511. return Ok(JsonView(groupData.Data));
  512. }
  513. /// <summary>
  514. /// 接团信息 操作(增改)
  515. /// </summary>
  516. /// <param name="dto"></param>
  517. /// <returns></returns>
  518. [HttpPost]
  519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  520. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  521. {
  522. try
  523. {
  524. decimal ffrPrice = 0.00M;
  525. DateTime? visitDt = null;
  526. if (dto.Status == 2)
  527. {
  528. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  529. if (groupInfo != null)
  530. {
  531. ffrPrice = groupInfo.PaymentMoney;
  532. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  533. }
  534. }
  535. var groupData = await _groupRepository.GroupOperation(dto);
  536. if (groupData.Code != 0)
  537. {
  538. return Ok(JsonView(false, groupData.Msg));
  539. }
  540. int diId = 0;
  541. //添加时 默认加入团组汇率
  542. if (dto.Status == 1) //添加
  543. {
  544. diId = groupData.Data;
  545. //添加默认币种
  546. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  547. //默认分配权限
  548. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  549. //消息提示 王鸽 主管号
  550. List<int> _managerIds = new List<int>() { 22, 32 };
  551. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  552. if (userIds.Count > 0)
  553. {
  554. userIds.Add(208);
  555. //创建团组管控
  556. GroupStepForDelegation.CreateWorkStep(diId);
  557. //发送消息
  558. string groupName = dto.TeamName;
  559. string createGroupUser = string.Empty;
  560. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  561. if (userInfo != null) createGroupUser = userInfo.CnName;
  562. string title = $"系统通知";
  563. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  564. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  565. }
  566. //默认创建倒推表
  567. await _invertedListRep._Create(dto.UserId, diId);
  568. }
  569. else if (dto.Status == 2)
  570. {
  571. diId = dto.Id;
  572. }
  573. #region 团组操作默认添加/修改收款账单
  574. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  575. {
  576. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  577. .Where(x => x.IsDel == 0 &&
  578. x.Diid == diId &&
  579. x.Remark.Equals("预付款")
  580. )
  581. .WhereIF(ffrPrice > 0 , x => x.ItemSumPrice == ffrPrice)
  582. .WhereIF(visitDt != null, x=> x.CreateTime == visitDt)
  583. .FirstAsync();
  584. ffrInfo.Diid = diId;
  585. ffrInfo.PriceName = dto.ClientUnit;
  586. ffrInfo.Price = dto.PaymentMoney;
  587. ffrInfo.Count = 1;
  588. ffrInfo.Unit = $"元";
  589. ffrInfo.ItemSumPrice = dto.PaymentMoney;
  590. ffrInfo.Rate = 1.0000M;
  591. ffrInfo.Currency = 836;
  592. ffrInfo.AddingWay = 0;
  593. ffrInfo.CreateUserId = dto.UserId;
  594. ffrInfo.CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay);
  595. ffrInfo.Remark = $"预付款";
  596. if (ffrInfo == null) //Add
  597. {
  598. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  599. }
  600. else //修改
  601. {
  602. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  603. .UpdateColumns(x => new
  604. {
  605. x.PriceName,
  606. x.Price,
  607. x.ItemSumPrice,
  608. x.CreateTime,
  609. x.CreateUserId
  610. })
  611. .WhereColumns(x => x.Id)
  612. .ExecuteCommandAsync();
  613. }
  614. }
  615. #endregion
  616. return Ok(JsonView(true, "操作成功!", diId));
  617. }
  618. catch (Exception ex)
  619. {
  620. Logs("[response]" + JsonConvert.SerializeObject(dto));
  621. Logs(ex.Message);
  622. return Ok(JsonView(false, ex.Message));
  623. }
  624. }
  625. /// <summary>
  626. /// 接团流程操作(增改)
  627. /// 安卓端使用 建团时添加客户名单
  628. /// </summary>
  629. /// <param name="dto"></param>
  630. /// <returns></returns>
  631. [HttpPost]
  632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  633. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  634. {
  635. try
  636. {
  637. #region 参数验证
  638. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  639. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  640. #region 页面操作权限验证
  641. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  642. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  643. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  644. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  645. #endregion
  646. #endregion
  647. _sqlSugar.BeginTran();
  648. decimal ffrPrice = 0.00M;
  649. DateTime? visitDt = null;
  650. if (dto.Status == 2)
  651. {
  652. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  653. if (groupInfo != null)
  654. {
  655. ffrPrice = groupInfo.PaymentMoney;
  656. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  657. }
  658. }
  659. var _dto = new GroupOperationDto();
  660. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  661. var groupData = await _groupRepository.GroupOperation(_dto);
  662. if (groupData.Code != 0)
  663. {
  664. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  665. }
  666. int diId = 0;
  667. //添加时 默认加入团组汇率
  668. if (dto.Status == 1) //添加
  669. {
  670. diId = groupData.Data;
  671. //添加默认币种
  672. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  673. //默认分配权限
  674. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  675. //消息提示 王鸽 主管号
  676. List<int> _managerIds = new List<int>() { 22, 32 };
  677. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  678. if (userIds.Count > 0)
  679. {
  680. userIds.Add(208);
  681. //创建团组管控
  682. GroupStepForDelegation.CreateWorkStep(diId);
  683. //发送消息
  684. string groupName = dto.TeamName;
  685. string createGroupUser = string.Empty;
  686. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  687. if (userInfo != null) createGroupUser = userInfo.CnName;
  688. string title = $"系统通知";
  689. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  690. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  691. }
  692. //默认创建倒推表
  693. await _invertedListRep._Create(dto.UserId, diId);
  694. }
  695. if (dto.Status == 2)
  696. {
  697. diId = dto.Id;
  698. if (diId == 0)
  699. {
  700. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  701. }
  702. }
  703. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  704. if (viewData.Code != 0)
  705. {
  706. _sqlSugar.RollbackTran();
  707. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  708. }
  709. #region 团组操作默认添加/修改收款账单
  710. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  711. {
  712. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  713. .Where(x => x.IsDel == 0 &&
  714. x.Diid == diId &&
  715. x.Remark.Equals("预付款")
  716. )
  717. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  718. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  719. .FirstAsync();
  720. ffrInfo.Diid = diId;
  721. ffrInfo.PriceName = dto.ClientUnit;
  722. ffrInfo.Price = dto.PaymentMoney;
  723. ffrInfo.Count = 1;
  724. ffrInfo.Unit = $"元";
  725. ffrInfo.ItemSumPrice = dto.PaymentMoney;
  726. ffrInfo.Rate = 1.0000M;
  727. ffrInfo.Currency = 836;
  728. ffrInfo.AddingWay = 0;
  729. ffrInfo.CreateUserId = dto.UserId;
  730. ffrInfo.CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay);
  731. ffrInfo.Remark = $"预付款";
  732. if (ffrInfo == null) //Add
  733. {
  734. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  735. }
  736. else //修改
  737. {
  738. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  739. .UpdateColumns(x => new
  740. {
  741. x.PriceName,
  742. x.Price,
  743. x.ItemSumPrice,
  744. x.CreateTime,
  745. x.CreateUserId
  746. })
  747. .WhereColumns(x => x.Id)
  748. .ExecuteCommandAsync();
  749. }
  750. }
  751. #endregion
  752. _sqlSugar.CommitTran();
  753. return Ok(JsonView(true, "添加成功"));
  754. }
  755. catch (Exception ex)
  756. {
  757. _sqlSugar.RollbackTran();
  758. return Ok(JsonView(false, ex.Message));
  759. }
  760. }
  761. /// <summary>
  762. /// 接团信息 操作(删除)
  763. /// </summary>
  764. /// <param name="dto"></param>
  765. /// <returns></returns>
  766. [HttpPost]
  767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  768. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  769. {
  770. try
  771. {
  772. var groupData = await _groupRepository.GroupDel(dto);
  773. if (groupData.Code != 0)
  774. {
  775. return Ok(JsonView(false, groupData.Msg));
  776. }
  777. return Ok(JsonView(true));
  778. }
  779. catch (Exception ex)
  780. {
  781. Logs("[response]" + JsonConvert.SerializeObject(dto));
  782. Logs(ex.Message);
  783. return Ok(JsonView(false, ex.Message));
  784. }
  785. }
  786. /// <summary>
  787. /// 获取团组销售报价号
  788. /// 团组添加时 使用
  789. /// </summary>
  790. /// <returns></returns>
  791. [HttpPost]
  792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  793. public async Task<IActionResult> GetGroupSalesQuoteNo()
  794. {
  795. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  796. if (groupData.Code != 0)
  797. {
  798. return Ok(JsonView(false, groupData.Msg));
  799. }
  800. object salesQuoteNo = new
  801. {
  802. SalesQuoteNo = groupData.Data
  803. };
  804. return Ok(JsonView(salesQuoteNo));
  805. }
  806. /// <summary>
  807. /// 设置确认出团
  808. /// </summary>
  809. /// <param name="dto"></param>
  810. /// <returns></returns>
  811. [HttpPost]
  812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  813. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  814. {
  815. var groupData = await _groupRepository.ConfirmationGroup(dto);
  816. if (groupData.Code != 0)
  817. {
  818. return Ok(JsonView(false, groupData.Msg));
  819. }
  820. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  821. #region OA消息推送
  822. try
  823. {
  824. string groupName = groupInfo.TeamName;
  825. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  826. List<int> userIds = new List<int>();
  827. listUser.ForEach(s => userIds.Add(s.Id));
  828. string title = $"系统通知";
  829. string content = $"团组[{groupName}]已确认出团!";
  830. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  831. }
  832. catch (Exception ex)
  833. {
  834. }
  835. #endregion
  836. #region 应用推送
  837. try
  838. {
  839. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  840. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  841. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  842. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  843. {
  844. List<string> userList = new List<string>() { users.QiyeChatUserId };
  845. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  846. }
  847. }
  848. catch (Exception ex)
  849. {
  850. }
  851. #endregion
  852. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  853. return Ok(JsonView(true, "操作成功!", groupData.Data));
  854. }
  855. /// <summary>
  856. /// 获取团组名称data And 签证国别Data
  857. /// </summary>
  858. /// <param name="dto"></param>
  859. /// <returns></returns>
  860. [HttpPost]
  861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  862. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  863. {
  864. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  865. if (groupData.Code != 0)
  866. {
  867. return Ok(JsonView(false, groupData.Msg));
  868. }
  869. return Ok(JsonView(groupData.Data));
  870. }
  871. /// <summary>
  872. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  873. /// </summary>
  874. /// <returns></returns>
  875. [HttpPost]
  876. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  877. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  878. {
  879. try
  880. {
  881. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  882. if (groupData.Code != 0)
  883. {
  884. return Ok(JsonView(false, groupData.Msg));
  885. }
  886. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  887. }
  888. catch (Exception ex)
  889. {
  890. return Ok(JsonView(false, "程序错误!"));
  891. throw;
  892. }
  893. }
  894. /// <summary>
  895. /// 团组清单 Excel
  896. /// </summary>
  897. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  898. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  899. /// <returns></returns>
  900. [HttpGet]
  901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  902. public async Task<IActionResult> GroupListFile([FromQuery]string beginDt, [FromQuery] string endDt)
  903. {
  904. DateTime _beginDt, _endDt;
  905. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  906. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  907. if (!beginBool && !endBool)
  908. {
  909. return Ok(JsonView(false, "开始或结束时间不正确!"));
  910. }
  911. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  912. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  913. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  914. JietuanOperator,IsSure,CreateTime,IsBid
  915. From (
  916. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  917. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  918. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  919. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  920. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  921. From Grp_DelegationInfo gdi
  922. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  923. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  924. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  925. Where gdi.IsDel = 0 And gdi.CreateTime Between '{0}' And '{1}'
  926. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  927. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  928. #region 处理所属部门
  929. /*
  930. * 1.sq 和 gyy 等显示 市场部
  931. * 2.王鸽和主管及张总还有管理员号统一国交部
  932. * 2-1. 4 管理员 ,21 张海麟
  933. */
  934. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  935. List<int> userIds1 = new List<int>() { 4, 21 };
  936. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  937. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  938. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  939. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  940. .ToListAsync();
  941. foreach (var item in groupList)
  942. {
  943. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  944. }
  945. #endregion
  946. #region Excel
  947. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  948. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  949. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  950. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  951. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  952. //载入模板
  953. WorkbookDesigner designer = new WorkbookDesigner();
  954. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  955. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  956. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  957. dt.TableName = "GroupList";
  958. designer.SetDataSource(dt);
  959. designer.Process();
  960. if (!Directory.Exists(savePath))
  961. {
  962. Directory.CreateDirectory(savePath);
  963. }
  964. string serverPath = $"{savePath}{fileName}";
  965. designer.Workbook.Save(serverPath);
  966. string rst =$"{servicePath}{ftpPath}{fileName}";
  967. #endregion
  968. return Ok(JsonView(true, "操作成功!", rst));
  969. }
  970. #endregion
  971. #region 团组&签证
  972. /// <summary>
  973. /// 根据团组Id获取签证客户信息List
  974. /// </summary>
  975. /// <param name="dto">请求dto</param>
  976. /// <returns></returns>
  977. [HttpPost]
  978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  979. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  980. {
  981. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  982. if (groupData.Code != 0)
  983. {
  984. return Ok(JsonView(false, groupData.Msg));
  985. }
  986. return Ok(JsonView(groupData.Data));
  987. }
  988. /// <summary>
  989. /// IOS获取团组签证拍照上传进度01(团组列表)
  990. /// </summary>
  991. /// <param name="dto">请求dto</param>
  992. /// <returns></returns>
  993. [HttpPost]
  994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  995. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  996. {
  997. if (dto == null)
  998. {
  999. return Ok(JsonView(false, "参数为空"));
  1000. }
  1001. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1002. return Ok(JsonView(visaList));
  1003. }
  1004. /// <summary>
  1005. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1006. /// </summary>
  1007. /// <returns></returns>
  1008. [HttpPost]
  1009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1010. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1011. {
  1012. if (dto == null)
  1013. {
  1014. return Ok(JsonView(false, "请求错误:"));
  1015. }
  1016. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1017. return Ok(JsonView(list));
  1018. }
  1019. /// <summary>
  1020. /// IOS获取团组签证拍照上传进度03(相册)
  1021. /// </summary>
  1022. /// <returns></returns>
  1023. [HttpPost]
  1024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1025. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1026. {
  1027. if (dto == null)
  1028. {
  1029. return Ok(JsonView(false, "请求错误:"));
  1030. }
  1031. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1032. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1033. list.ForEach(s => s.url = url);
  1034. return Ok(JsonView(list));
  1035. }
  1036. /// <summary>
  1037. /// IOS获取团组签证拍照上传进度04(图片上传)
  1038. /// </summary>
  1039. /// <param name="dto"></param>
  1040. /// <returns></returns>
  1041. [HttpPost]
  1042. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1043. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1044. {
  1045. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1046. //if (!string.IsNullOrEmpty(result))
  1047. //{
  1048. //}
  1049. //else {
  1050. // return Ok(JsonView(false, "上传失败"));
  1051. //}
  1052. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1053. int sucNum = 0;
  1054. try
  1055. {
  1056. foreach (var item in dto.base64DataList)
  1057. {
  1058. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1059. string result = decodeBase64ToImage(item, imageName);
  1060. if (!string.IsNullOrEmpty(result))
  1061. {
  1062. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1063. pic.CreateUserId = dto.CreateUserId;
  1064. pic.PicName = imageName;
  1065. pic.PicPath = result;
  1066. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1067. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1068. if (insertResult > 0)
  1069. {
  1070. sucNum++;
  1071. }
  1072. }
  1073. }
  1074. }
  1075. catch (Exception ex)
  1076. {
  1077. return Ok(JsonView(false, ex.Message));
  1078. }
  1079. string msg = string.Format(@"成功上传{0}张", sucNum);
  1080. return Ok(JsonView(true, msg));
  1081. }
  1082. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1083. {
  1084. string filename = "";//声明一个string类型的相对路径
  1085. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1086. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1087. try//会有异常抛出,try,catch一下
  1088. {
  1089. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1090. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1091. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1092. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1093. //文件名称
  1094. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1095. //上传的文件的路径
  1096. string filePath = "";
  1097. if (!Directory.Exists(fileDir))
  1098. {
  1099. Directory.CreateDirectory(fileDir);
  1100. }
  1101. //上传的文件的路径
  1102. filePath = fileDir + filename;
  1103. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1104. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1105. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1106. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1107. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1108. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1109. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1110. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1111. bitmap.Dispose();
  1112. }
  1113. catch (Exception e)
  1114. {
  1115. string massage = e.Message;
  1116. Logs("IOS图片上传Error:" + massage);
  1117. //filename = e.Message;
  1118. }
  1119. return filename;//返回相对路径
  1120. }
  1121. /// <summary>
  1122. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1123. /// </summary>
  1124. /// <param name="dto"></param>
  1125. /// <returns></returns>
  1126. [HttpPost]
  1127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1128. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1129. {
  1130. if (dto == null)
  1131. {
  1132. return Ok(JsonView(false, "请求错误:"));
  1133. }
  1134. string msg = "参数错误";
  1135. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1136. {
  1137. try
  1138. {
  1139. //_delegationVisaRep.BeginTran();
  1140. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1141. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1142. .Where(s => s.Id == dto.visaProgressCustomerId)
  1143. .ExecuteCommandAsync();
  1144. if (updCount > 0 && dto.publishCode == 1)
  1145. {
  1146. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1147. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1148. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1149. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1150. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1151. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1152. if (groupData == null)
  1153. {
  1154. _delegationVisaRep.RollbackTran();
  1155. }
  1156. string title = string.Format(@"[签证进度更新]");
  1157. string content = string.Format(@"测试文本");
  1158. bool rst = await _message.AddMsg(new MessageDto()
  1159. {
  1160. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1161. IssuerId = dto.publisher,
  1162. Title = title,
  1163. Content = content,
  1164. ReleaseTime = DateTime.Now,
  1165. UIdList = new List<int> {
  1166. 234
  1167. }
  1168. });
  1169. if (rst)
  1170. {
  1171. return Ok(JsonView(true, "发送通知成功"));
  1172. }
  1173. }
  1174. //_delegationVisaRep.CommitTran();
  1175. }
  1176. catch (Exception)
  1177. {
  1178. //_delegationVisaRep.RollbackTran();
  1179. }
  1180. }
  1181. return Ok(JsonView(true, msg));
  1182. }
  1183. #endregion
  1184. #region 团组任务分配
  1185. /// <summary>
  1186. /// 团组任务分配初始化
  1187. /// </summary>
  1188. /// <param name="dto"></param>
  1189. /// <returns></returns>
  1190. [HttpPost]
  1191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1192. public async Task<IActionResult> GetTaskAssignmen()
  1193. {
  1194. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1195. if (groupData.Code != 0)
  1196. {
  1197. return Ok(JsonView(false, groupData.Msg));
  1198. }
  1199. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1200. }
  1201. /// <summary>
  1202. /// 团组任务分配查询
  1203. /// </summary>
  1204. /// <param name="dto"></param>
  1205. /// <returns></returns>
  1206. [HttpPost]
  1207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1208. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1209. {
  1210. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1211. if (groupData.Code != 0)
  1212. {
  1213. return Ok(JsonView(false, groupData.Msg));
  1214. }
  1215. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1216. }
  1217. /// <summary>
  1218. /// 团组任务分配操作
  1219. /// </summary>
  1220. /// <param name="dto"></param>
  1221. /// <returns></returns>
  1222. [HttpPost]
  1223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1224. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1225. {
  1226. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1227. if (groupData.Code != 0)
  1228. {
  1229. return Ok(JsonView(false, groupData.Msg));
  1230. }
  1231. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1232. }
  1233. /// <summary>
  1234. /// 团组任务分配
  1235. /// 批量分配
  1236. /// 查询团组
  1237. /// </summary>
  1238. /// <param name="dto"></param>
  1239. /// <returns></returns>
  1240. [HttpPost]
  1241. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1242. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1243. {
  1244. //参数验证
  1245. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1246. if (!DateTime.TryParse(dto.VisitBeginDt,out _) || !DateTime.TryParse(dto.VisitEndDt,out _))
  1247. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1248. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1249. }
  1250. /// <summary>
  1251. /// 团组任务分配
  1252. /// 批量分配
  1253. /// </summary>
  1254. /// <param name="dto"></param>
  1255. /// <returns></returns>
  1256. [HttpPost]
  1257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1258. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1259. {
  1260. //参数验证
  1261. if (dto.UserIds.Length < 1 ) return Ok(JsonView(false, $"请选择分配人员!"));
  1262. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1263. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1264. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1265. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1266. }
  1267. #endregion
  1268. #region 团组费用审核
  1269. /// <summary>
  1270. /// 费用审核
  1271. /// 团组列表 Page
  1272. /// </summary>
  1273. /// <param name="_dto">团组列表请求dto</param>
  1274. /// <returns></returns>
  1275. [HttpPost]
  1276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1277. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1278. {
  1279. #region 参数验证
  1280. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1281. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1282. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1283. #region 页面操作权限验证
  1284. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1285. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1286. #endregion
  1287. #endregion
  1288. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1289. {
  1290. string sqlWhere = string.Empty;
  1291. if (_dto.IsSure == 0) //未完成
  1292. {
  1293. sqlWhere += string.Format(@" And IsSure = 0");
  1294. }
  1295. else if (_dto.IsSure == 1) //已完成
  1296. {
  1297. sqlWhere += string.Format(@" And IsSure = 1");
  1298. }
  1299. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1300. {
  1301. string tj = _dto.SearchCriteria;
  1302. 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}%')",
  1303. tj, tj, tj, tj, tj);
  1304. }
  1305. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1306. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1307. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1308. From (
  1309. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1310. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1311. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1312. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1313. From Grp_DelegationInfo gdi
  1314. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1315. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1316. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1317. Where gdi.IsDel = 0 {0}
  1318. ) temp ", sqlWhere);
  1319. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1320. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1321. var _view = new
  1322. {
  1323. PageFuncAuth = pageFunAuthView,
  1324. Data = _DelegationList
  1325. };
  1326. return Ok(JsonView(true, "查询成功!", _view, total));
  1327. }
  1328. else
  1329. {
  1330. return Ok(JsonView(false, "查询失败"));
  1331. }
  1332. }
  1333. /// <summary>
  1334. /// 获取团组费用审核
  1335. /// </summary>
  1336. /// <param name="paras">参数Json字符串</param>
  1337. /// <returns></returns>
  1338. [HttpPost]
  1339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1340. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1341. {
  1342. try
  1343. {
  1344. #region 参数验证
  1345. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1346. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1347. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1348. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1349. #region 页面操作权限验证
  1350. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1351. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1352. #endregion
  1353. #endregion
  1354. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1355. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1356. #region 费用清单
  1357. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1358. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1359. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1360. List<Grp_CreditCardPayment> entityList = _groupRepository
  1361. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1362. .Where(exp.ToExpression())
  1363. .ToList();
  1364. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1365. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1366. /*
  1367. * 76://酒店预订
  1368. */
  1369. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1370. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1371. .ToListAsync();
  1372. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1373. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1374. .ToListAsync();
  1375. /*
  1376. * 79://车/导游地接
  1377. */
  1378. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1379. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1380. .ToListAsync();
  1381. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1382. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1383. .ToListAsync();
  1384. /*
  1385. * 80: //签证
  1386. */
  1387. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1388. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1389. .ToListAsync();
  1390. /*
  1391. *81: //邀请/公务活动
  1392. */
  1393. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1394. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1395. .ToListAsync();
  1396. /*
  1397. * 82: //团组客户保险
  1398. */
  1399. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1400. /*
  1401. * Lable = 85 机票预订
  1402. */
  1403. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1404. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1405. .ToListAsync();
  1406. /*
  1407. * 85 机票预定
  1408. */
  1409. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1410. /*
  1411. * 98 其他款项
  1412. */
  1413. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1414. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1415. .ToListAsync();
  1416. /*
  1417. * 285:收款退还
  1418. */
  1419. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1420. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1421. .ToListAsync();
  1422. /*
  1423. * 1015: //超支费用
  1424. */
  1425. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1426. /*
  1427. * 币种信息
  1428. */
  1429. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1430. /*
  1431. * 车/导游地接 费用类型
  1432. */
  1433. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1434. /*
  1435. * 车/导游地接 费用类型
  1436. */
  1437. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1438. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1439. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1440. /*
  1441. * 用户信息
  1442. */
  1443. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1444. /*
  1445. * 费用模块
  1446. */
  1447. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1448. string priceModule = string.Empty;
  1449. if (sdPriceName != null)
  1450. {
  1451. priceModule = sdPriceName.Name;
  1452. }
  1453. /*
  1454. * 成本信息
  1455. */
  1456. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1457. decimal _groupRate = 0.0000M;
  1458. string _groupCurrencyCode = "-";
  1459. if (groupCost != null)
  1460. {
  1461. _groupRate = groupCost.Rate;
  1462. if (int.TryParse(groupCost.Currency, out int _currency))
  1463. {
  1464. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1465. }
  1466. else _groupCurrencyCode = groupCost.Currency;
  1467. }
  1468. string costContentSql = $"Select * From Grp_GroupCost";
  1469. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1470. //处理日期为空的天数
  1471. for (int i = 0; i < groupCostDetails.Count; i++)
  1472. if (i != 0)
  1473. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1474. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1475. /*
  1476. * 处理详情数据
  1477. */
  1478. foreach (var entity in entityList)
  1479. {
  1480. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1481. _detail.Id = entity.Id;
  1482. _detail.PriceName = priceModule;
  1483. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1484. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1485. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1486. /*
  1487. * 应付款金额
  1488. */
  1489. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1490. string PaymentCurrency_WaitPay = "Unknown";
  1491. string hotelCurrncyCode = "Unknown";
  1492. string hotelCurrncyName = "Unknown";
  1493. if (sdPaymentCurrency_WaitPay != null)
  1494. {
  1495. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1496. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1497. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1498. if (hotelCurrncyCode.Equals("CNY"))
  1499. {
  1500. entity.DayRate = 1.0000M;
  1501. }
  1502. }
  1503. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1504. /*
  1505. * 此次付款金额
  1506. */
  1507. decimal CurrPayStr = 0.00M,
  1508. OriginalCurrPay = 0.00M;
  1509. if (entity.PayPercentage == 0)
  1510. {
  1511. if (entity.PayThenMoney != 0)
  1512. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1513. }
  1514. else
  1515. {
  1516. if (entity.PayMoney != 0)
  1517. {
  1518. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1519. }
  1520. }
  1521. if (_dto.Label == 79)
  1522. {
  1523. string original = string.Empty;
  1524. if (hotelCurrncyCode.Equals("CNY"))
  1525. {
  1526. OriginalCurrPay = CurrPayStr;
  1527. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1528. }
  1529. else
  1530. {
  1531. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1532. //760 EUR(7600.00 CNY)
  1533. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1534. }
  1535. }
  1536. else
  1537. {
  1538. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1539. }
  1540. /*
  1541. * 剩余尾款
  1542. */
  1543. decimal BalanceStr = 0;
  1544. if (CurrPayStr != 0)
  1545. {
  1546. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1547. BalanceStr = 0;
  1548. else
  1549. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1550. }
  1551. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1552. /*
  1553. * Bus名称
  1554. */
  1555. _detail.BusName = "待增加";
  1556. /*
  1557. *费用所属
  1558. */
  1559. switch (entity.CTable)
  1560. {
  1561. case 76://酒店预订
  1562. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1563. if (hotelReservations != null)
  1564. {
  1565. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1566. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1567. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1568. string roomFeeStr = "", roomFeestr1 = "";
  1569. //是否比较房型价格
  1570. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1571. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1572. roomFeeStr += $"<br/>";
  1573. if (hotelReservations.SingleRoomPrice > 0)
  1574. {
  1575. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1576. __isSingle = true;
  1577. }
  1578. if (hotelReservations.DoubleRoomPrice > 0)
  1579. {
  1580. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1581. __isDouble = true;
  1582. }
  1583. if (hotelReservations.SuiteRoomPrice > 0)
  1584. {
  1585. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1586. __isSuite = true;
  1587. }
  1588. if (hotelReservations.OtherRoomPrice > 0)
  1589. {
  1590. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1591. __isOther = true;
  1592. }
  1593. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1594. else roomFeeStr += " 0.00 * 0";
  1595. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1596. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1597. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1598. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1599. /*
  1600. * 费用类型
  1601. * 1:房费
  1602. * 2:早餐
  1603. * 3:地税
  1604. * 4:城市税
  1605. * </summary>
  1606. */
  1607. //地税
  1608. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1609. if (governmentRentData != null)
  1610. {
  1611. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1612. governmentRentFee = governmentRentData.Price;
  1613. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1614. if (governmentRentCurrData != null)
  1615. {
  1616. governmentRentCode = governmentRentCurrData.Name;
  1617. governmentRentName = $"({governmentRentCurrData.Remark})";
  1618. }
  1619. }
  1620. //城市税
  1621. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1622. if (cityTaxData != null)
  1623. {
  1624. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1625. cityTaxFee = cityTaxData.Price;
  1626. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1627. if (cityTaxCurrData != null)
  1628. {
  1629. cityTaxCode = cityTaxCurrData.Name;
  1630. cityTaxName = $"({cityTaxCurrData.Remark})";
  1631. }
  1632. }
  1633. //酒店早餐
  1634. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1635. if (breakfastData != null)
  1636. {
  1637. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1638. breakfastFee = breakfastData.Price;
  1639. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1640. if (breakfastCurrData != null)
  1641. {
  1642. breakfastCode = breakfastCurrData.Name;
  1643. breakfastName = $"({breakfastCurrData.Remark})";
  1644. }
  1645. }
  1646. //房间费用
  1647. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1648. if (roomData != null)
  1649. {
  1650. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1651. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1652. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1653. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1654. roomFee = roomData.Price;
  1655. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1656. if (roomCurrData != null)
  1657. {
  1658. roomCode = roomCurrData.Name;
  1659. roomName = $"({roomCurrData.Remark})";
  1660. }
  1661. }
  1662. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1663. string hotelCostStr = "";
  1664. decimal hotelCsotTotal = 0.00M;
  1665. if (groupCost != null)
  1666. {
  1667. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1668. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1669. }
  1670. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1671. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1672. string hotelCost_day = "";
  1673. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1674. foreach (var item in hotelCostDetails1)
  1675. {
  1676. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1677. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1678. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1679. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1680. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1681. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1682. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1683. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1684. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1685. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1686. hotelCost_day += @$"</br>";
  1687. }
  1688. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1689. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1690. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1691. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1692. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1693. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1694. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1695. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1696. $"房间说明: {hotelReservations.Remark} <br/>" +
  1697. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1698. $"{hotelBreakfastStr}" +
  1699. $"{hotelGovernmentRentStr}" +
  1700. $"{hotelCityTaxStr}";
  1701. _detail.PriceNameContent = hotelReservations.HotelName;
  1702. }
  1703. break;
  1704. case 79://车/导游地接
  1705. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1706. if (touristGuideGroundReservations != null)
  1707. {
  1708. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1709. {
  1710. _detail.BusName = touristGuideGroundReservations.BusName;
  1711. }
  1712. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1713. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1714. //if (isInt)
  1715. //{
  1716. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1717. // if (cityInfo != null)
  1718. // {
  1719. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1720. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1721. // if (carFeeItem != null)
  1722. // {
  1723. // nameContent += $@"({carFeeItem.Name})";
  1724. // }
  1725. // _detail.PriceNameContent = nameContent;
  1726. // }
  1727. //}
  1728. //else
  1729. //{
  1730. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1731. //}
  1732. var touristGuideGroundReservationsContents =
  1733. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1734. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1735. foreach (var item in touristGuideGroundReservationsContents)
  1736. {
  1737. string typeName = "Unknown";
  1738. string carCurrencyCode = "Unknown";
  1739. string carCurrencyName = "Unknown";
  1740. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1741. if (carTypeData != null) typeName = carTypeData.Name;
  1742. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1743. if (currencyData != null)
  1744. {
  1745. carCurrencyCode = currencyData.Name;
  1746. carCurrencyName = currencyData.Remark;
  1747. }
  1748. //op、成本 币种是否一致
  1749. bool IsCurrencyAgreement = false;
  1750. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1751. string opCostStr = string.Empty;
  1752. decimal opCostTypePrice = 0.00M;
  1753. #region 处理成本各项费用
  1754. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1755. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1756. if (opCost.Count > 0)
  1757. {
  1758. switch (item.SId)
  1759. {
  1760. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1761. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1762. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1763. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1764. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1765. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1766. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1767. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1768. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1769. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1770. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1771. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1772. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1773. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1774. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1775. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1776. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1777. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1778. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1779. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1780. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1781. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1782. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1783. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1784. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1785. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1786. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1787. }
  1788. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1789. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1790. }
  1791. #endregion
  1792. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})" ;
  1793. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1794. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1795. $"{opTypeStr} {opCostStr}<br/>" +
  1796. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1797. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1798. }
  1799. _detail.PriceMsgContent = priceMsg;
  1800. }
  1801. break;
  1802. case 80: //签证
  1803. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1804. if (visaInfo != null)
  1805. {
  1806. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1807. _detail.PriceNameContent = visaInfo.VisaDescription ;
  1808. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1809. }
  1810. break;
  1811. case 81: //邀请/公务活动
  1812. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1813. if (_ioa != null)
  1814. {
  1815. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1816. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1817. sendCurrName = "Unknown", //快递费用币种 Name
  1818. sendCurrCode = "Unknown", //快递费用币种 Code
  1819. eventsCurrName = "Unknown", //公务活动费币种 Name
  1820. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1821. translateCurrName = "Unknown", //公务翻译费 Name
  1822. translateCurrCode = "Unknown"; //公务翻译费 Code
  1823. #region 处理费用币种
  1824. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1825. if (inviteCurrData != null)
  1826. {
  1827. inviteCurrName = inviteCurrData.Remark;
  1828. inviteCurrCode = inviteCurrData.Name;
  1829. }
  1830. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1831. if (sendCurrData != null)
  1832. {
  1833. sendCurrName = sendCurrData.Remark;
  1834. sendCurrCode = sendCurrData.Name;
  1835. }
  1836. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1837. if (eventsCurrData != null)
  1838. {
  1839. eventsCurrName = eventsCurrData.Remark;
  1840. eventsCurrCode = eventsCurrData.Name;
  1841. }
  1842. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1843. if (translateCurrData != null)
  1844. {
  1845. translateCurrName = translateCurrData.Remark;
  1846. translateCurrCode = translateCurrData.Name;
  1847. }
  1848. #endregion
  1849. _detail.PriceNameContent = _ioa.InviterArea;
  1850. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1851. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1852. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1853. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1854. $@"备注:" + _ioa.Remark + "<br/>";
  1855. }
  1856. break;
  1857. case 82: //团组客户保险
  1858. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1859. if (customers != null)
  1860. {
  1861. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1862. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1863. }
  1864. break;
  1865. case 85: //机票预订
  1866. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1867. if (jpRes != null)
  1868. {
  1869. string FlightsDescription = jpRes.FlightsDescription;
  1870. string PriceDescription = jpRes.PriceDescription;
  1871. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1872. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1873. }
  1874. break;
  1875. case 98://其他款项
  1876. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1877. if (gdpRes != null)
  1878. {
  1879. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1880. _detail.PriceNameContent = gdpRes.PriceName;
  1881. }
  1882. break;
  1883. case 285://收款退还
  1884. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1885. if (refundAndOtherMoney != null)
  1886. {
  1887. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1888. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1889. }
  1890. break;
  1891. case 751://酒店早餐
  1892. break;
  1893. case 1015://超支费用
  1894. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1895. if (groupExtraCost != null)
  1896. {
  1897. _detail.PriceNameContent = groupExtraCost.PriceName;
  1898. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1899. }
  1900. break;
  1901. default:
  1902. break;
  1903. }
  1904. /*
  1905. * 申请人
  1906. */
  1907. string operatorName = " - ";
  1908. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1909. if (_opUser != null)
  1910. {
  1911. operatorName = _opUser.CnName;
  1912. }
  1913. _detail.OperatorName = operatorName;
  1914. /*
  1915. * 审核人
  1916. */
  1917. string auditOperatorName = "Unknown";
  1918. if (entity.AuditGMOperate == 0)
  1919. auditOperatorName = " - ";
  1920. else if (entity.AuditGMOperate == 4)
  1921. auditOperatorName = "自动审核";
  1922. else
  1923. {
  1924. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1925. if (_adUser != null)
  1926. {
  1927. auditOperatorName = _adUser.CnName;
  1928. }
  1929. }
  1930. _detail.AuditOperatorName = auditOperatorName;
  1931. /*
  1932. * 超预算比例
  1933. */
  1934. string overBudgetStr = "";
  1935. if (entity.ExceedBudget == -1)
  1936. overBudgetStr = sdPriceName.Name + "尚无预算";
  1937. else if (entity.ExceedBudget == 0)
  1938. {
  1939. if (entity.CTable == 76 || entity.CTable == 79)
  1940. {
  1941. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  1942. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  1943. }
  1944. else
  1945. {
  1946. overBudgetStr = "未超预算";
  1947. }
  1948. }
  1949. else
  1950. overBudgetStr = entity.ExceedBudget.ToString("P");
  1951. _detail.OverBudget = overBudgetStr;
  1952. /*
  1953. * 已审核金额
  1954. */
  1955. decimal auditFee = 0.00M;
  1956. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  1957. /*
  1958. * 费用总计
  1959. */
  1960. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1961. {
  1962. CurrencyId = entity.PaymentCurrency,
  1963. CurrencyName = PaymentCurrency_WaitPay,
  1964. AmountPayable = entity.PayMoney,
  1965. ThisPayment = OriginalCurrPay,
  1966. BalancePayment = BalanceStr,
  1967. AuditedFunds = auditFee
  1968. });
  1969. _detail.IsAuditGM = entity.IsAuditGM;
  1970. detailList.Add(_detail);
  1971. }
  1972. #endregion
  1973. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1974. /*
  1975. * 下方描述处理
  1976. */
  1977. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1978. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1979. if (ccpCurrencyPrice != null)
  1980. {
  1981. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1982. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1983. }
  1984. else
  1985. {
  1986. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1987. }
  1988. string amountPayableStr = string.Format(@"应付款总金额: ");
  1989. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1990. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1991. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1992. foreach (var item in nonDuplicat)
  1993. {
  1994. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1995. if (strs.Count > 0)
  1996. {
  1997. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1998. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1999. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2000. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  2001. //单独处理此次付款金额
  2002. if (item.CurrencyId == 836) //人民币
  2003. {
  2004. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2005. }
  2006. else
  2007. {
  2008. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2009. }
  2010. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  2011. //单独处理已审核费用
  2012. if (item.CurrencyId == 836) //人民币
  2013. {
  2014. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2015. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  2016. }
  2017. else
  2018. {
  2019. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  2020. }
  2021. }
  2022. }
  2023. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2024. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2025. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2026. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  2027. var _view1 = new
  2028. {
  2029. PageFuncAuth = pageFunAuthView,
  2030. Data = _view
  2031. };
  2032. return Ok(JsonView(_view1));
  2033. }
  2034. catch (Exception ex)
  2035. {
  2036. return Ok(JsonView(false, ex.Message));
  2037. }
  2038. }
  2039. /// <summary>
  2040. /// 费用审核
  2041. /// 修改团组费用审核状态
  2042. /// </summary>
  2043. /// <param name="_dto">参数Json字符串</param>
  2044. /// <returns></returns>
  2045. [HttpPost]
  2046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2047. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2048. {
  2049. #region 参数验证
  2050. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2051. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2052. #endregion
  2053. #region 页面操作权限验证
  2054. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2055. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2056. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2057. #endregion
  2058. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2059. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2060. DateTime dtNow = DateTime.Now;
  2061. _groupRepository.BeginTran();
  2062. int rst = 0;
  2063. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2064. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2065. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2066. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2067. List<dynamic> msgDatas = new List<dynamic>();
  2068. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2069. foreach (var item in idList)
  2070. {
  2071. int CreditId = int.Parse(item);
  2072. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2073. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2074. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2075. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2076. .Where(s => s.Id == CreditId)
  2077. .ExecuteCommandAsync();
  2078. if (result < 1)
  2079. {
  2080. rst = -1;
  2081. _groupRepository.RollbackTran();
  2082. return Ok(JsonView(false, "操作失败并回滚!"));
  2083. }
  2084. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2085. if (creditData != null)
  2086. {
  2087. #region 应用通知配置
  2088. try
  2089. {
  2090. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2091. }
  2092. catch (Exception ex)
  2093. {
  2094. }
  2095. #endregion
  2096. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2097. string groupNameStr = string.Empty;
  2098. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2099. if (groupData != null) groupNameStr = groupData.TeamName;
  2100. string creditTypeStr = string.Empty;
  2101. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2102. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2103. string creditCurrency = string.Empty;
  2104. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2105. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2106. if (creditCurrency.Equals("CNY"))
  2107. {
  2108. creditData.DayRate = 1.0000M;
  2109. }
  2110. if (creditData.PayPercentage == 0.00M)
  2111. {
  2112. creditData.PayPercentage = 100M;
  2113. }
  2114. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2115. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2116. string msgContent = "";
  2117. if (creditCurrency.Equals("CNY"))
  2118. {
  2119. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2120. }
  2121. else
  2122. {
  2123. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2124. }
  2125. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2126. }
  2127. }
  2128. if (rst == 0)
  2129. {
  2130. _groupRepository.CommitTran();
  2131. foreach (var item in msgDatas)
  2132. {
  2133. //发送消息
  2134. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2135. }
  2136. #region 应用推送
  2137. try
  2138. {
  2139. foreach (var ccpId in dic_ccp_user.Keys)
  2140. {
  2141. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2142. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2143. }
  2144. }
  2145. catch (Exception)
  2146. {
  2147. }
  2148. #endregion
  2149. return Ok(JsonView(true, "操作成功!"));
  2150. }
  2151. return Ok(JsonView(false, "操作失败!"));
  2152. }
  2153. #endregion
  2154. #region 机票费用录入
  2155. /// <summary>
  2156. /// 机票录入当前登录人可操作团组
  2157. /// </summary>
  2158. /// <param name="dto"></param>
  2159. /// <returns></returns>
  2160. [HttpPost]
  2161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2162. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2163. {
  2164. try
  2165. {
  2166. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2167. if (groupData.Code != 0)
  2168. {
  2169. return Ok(JsonView(false, groupData.Msg));
  2170. }
  2171. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2172. }
  2173. catch (Exception ex)
  2174. {
  2175. return Ok(JsonView(false, "程序错误!"));
  2176. throw;
  2177. }
  2178. }
  2179. /// <summary>
  2180. /// 机票费用录入列表
  2181. /// </summary>
  2182. /// <param name="dto"></param>
  2183. /// <returns></returns>
  2184. [HttpPost]
  2185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2186. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2187. {
  2188. try
  2189. {
  2190. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2191. if (groupData.Code != 0)
  2192. {
  2193. return Ok(JsonView(false, groupData.Msg));
  2194. }
  2195. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2196. }
  2197. catch (Exception ex)
  2198. {
  2199. return Ok(JsonView(false, ex.Message));
  2200. throw;
  2201. }
  2202. }
  2203. /// <summary>
  2204. /// 根据id查询费用录入信息
  2205. /// </summary>
  2206. /// <param name="dto"></param>
  2207. /// <returns></returns>
  2208. [HttpPost]
  2209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2210. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2211. {
  2212. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2213. if (groupData.Code != 0)
  2214. {
  2215. return Ok(JsonView(false, groupData.Msg));
  2216. }
  2217. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2218. }
  2219. /// <summary>
  2220. /// 机票费用录入操作(Status:1.新增,2.修改)
  2221. /// </summary>
  2222. /// <param name="dto"></param>
  2223. /// <returns></returns>
  2224. [HttpPost]
  2225. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2226. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2227. {
  2228. try
  2229. {
  2230. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2231. if (groupData.Code != 0)
  2232. {
  2233. return Ok(JsonView(false, groupData.Msg));
  2234. }
  2235. #region 应用推送
  2236. try
  2237. {
  2238. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2239. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2240. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2241. }
  2242. catch (Exception ex)
  2243. {
  2244. }
  2245. #endregion
  2246. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2247. }
  2248. catch (Exception ex)
  2249. {
  2250. return Ok(JsonView(false, "程序错误!"));
  2251. throw;
  2252. }
  2253. }
  2254. /// <summary>
  2255. /// 根据舱位类型查询接团客户名单信息
  2256. /// </summary>
  2257. /// <param name="dto"></param>
  2258. /// <returns></returns>
  2259. [HttpPost]
  2260. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2261. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2262. {
  2263. try
  2264. {
  2265. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2266. if (crm_Groups.Count != 0)
  2267. {
  2268. List<dynamic> Customer = new List<dynamic>();
  2269. foreach (var item in crm_Groups)
  2270. {
  2271. var data = new
  2272. {
  2273. Id = item.Id,
  2274. Pinyin = item.Pinyin,
  2275. Name = item.LastName + item.FirstName
  2276. };
  2277. Customer.Add(data);
  2278. }
  2279. return Ok(JsonView(true, "查询成功!", Customer));
  2280. }
  2281. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2282. }
  2283. catch (Exception ex)
  2284. {
  2285. return Ok(JsonView(false, "程序错误!"));
  2286. throw;
  2287. }
  2288. }
  2289. /// <summary>
  2290. /// 根据团号获取客户信息
  2291. /// </summary>
  2292. /// <param name="dto"></param>
  2293. /// <returns></returns>
  2294. [HttpPost]
  2295. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2296. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2297. {
  2298. var jw = JsonView(false);
  2299. if (dto.DIID < 1)
  2300. {
  2301. jw.Msg += "请输入正确的diid";
  2302. return Ok(jw);
  2303. }
  2304. var arr = getSimplClientList(dto.DIID);
  2305. jw = JsonView(true, "获取成功!", arr);
  2306. return Ok(jw);
  2307. }
  2308. private List<SimplClientInfo> getSimplClientList(int diId)
  2309. {
  2310. 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);
  2311. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2312. return arr;
  2313. }
  2314. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2315. {
  2316. string result = origin;
  2317. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2318. {
  2319. string[] temparr = origin.Split(',');
  2320. string fistrStr = temparr[0];
  2321. int count = temparr.Count();
  2322. int tempId;
  2323. bool success = int.TryParse(fistrStr, out tempId);
  2324. if (success)
  2325. {
  2326. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2327. if (tempInfo != null)
  2328. {
  2329. if (count > 1)
  2330. {
  2331. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2332. }
  2333. else
  2334. {
  2335. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2336. }
  2337. }
  2338. }
  2339. }
  2340. return result;
  2341. }
  2342. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2343. {
  2344. string result = origin;
  2345. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2346. {
  2347. string[] temparr = origin.Split(',');
  2348. result = "";
  2349. foreach (var item in temparr)
  2350. {
  2351. int tempId;
  2352. bool success = int.TryParse(item, out tempId);
  2353. if (success)
  2354. {
  2355. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2356. if (tempInfo != null)
  2357. {
  2358. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2359. }
  2360. }
  2361. }
  2362. }
  2363. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2364. return result;
  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> DelAirTicketRes(DelBaseDto dto)
  2374. {
  2375. try
  2376. {
  2377. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2378. if (res)
  2379. {
  2380. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2381. {
  2382. IsDel = 1,
  2383. DeleteUserId = dto.DeleteUserId,
  2384. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2385. }).ExecuteCommandAsync();
  2386. return Ok(JsonView(true, "删除成功!"));
  2387. }
  2388. return Ok(JsonView(false, "删除失败!"));
  2389. }
  2390. catch (Exception ex)
  2391. {
  2392. return Ok(JsonView(false, "程序错误!"));
  2393. throw;
  2394. }
  2395. }
  2396. /// <summary>
  2397. /// 导出机票录入报表
  2398. /// </summary>
  2399. /// <param name="dto"></param>
  2400. /// <returns></returns>
  2401. [HttpPost]
  2402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2403. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2404. {
  2405. try
  2406. {
  2407. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2408. if (groupData.Code != 0)
  2409. {
  2410. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2411. }
  2412. else
  2413. {
  2414. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2415. if (AirTicketReservations.Count != 0)
  2416. {
  2417. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2418. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2419. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2420. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2421. WorkbookDesigner designer = new WorkbookDesigner();
  2422. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2423. decimal countCost = 0;
  2424. foreach (var item in AirTicketReservations)
  2425. {
  2426. #region 处理客人姓名
  2427. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2428. item.ClientName = clientNames;
  2429. #endregion
  2430. if (item.BankType == "其他")
  2431. {
  2432. item.BankNo = "--";
  2433. }
  2434. else
  2435. {
  2436. if (!string.IsNullOrEmpty(item.BankType))
  2437. {
  2438. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2439. }
  2440. }
  2441. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2442. item.Price = System.Decimal.Round(item.Price, 2);
  2443. countCost += Convert.ToDecimal(item.Price);
  2444. }
  2445. designer.SetDataSource("Export", AirTicketReservations);
  2446. designer.SetDataSource("ExportDiCode", diCode);
  2447. designer.SetDataSource("ExportDiName", diName);
  2448. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2449. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2450. designer.Process();
  2451. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2452. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2453. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2454. return Ok(JsonView(true, "成功", url = rst));
  2455. }
  2456. else
  2457. {
  2458. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2459. }
  2460. }
  2461. }
  2462. catch (Exception ex)
  2463. {
  2464. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2465. throw;
  2466. }
  2467. }
  2468. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2469. /// <summary>
  2470. /// 行程单导出
  2471. /// </summary>
  2472. /// <param name="dto"></param>
  2473. /// <returns></returns>
  2474. [HttpPost]
  2475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2476. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2477. {
  2478. try
  2479. {
  2480. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2481. if (groupData.Code != 0)
  2482. {
  2483. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2484. }
  2485. else
  2486. {
  2487. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2488. if (dto.Language == "CN")
  2489. {
  2490. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2491. DocumentBuilder builder = new DocumentBuilder(doc);
  2492. int tableIndex = 0;//表格索引
  2493. //得到文档中的第一个表格
  2494. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2495. foreach (var item in _AirTicketReservations)
  2496. {
  2497. #region 处理固定数据
  2498. string[] FlightsCode = item.FlightsCode.Split('/');
  2499. if (FlightsCode.Length != 0)
  2500. {
  2501. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2502. if (_AirCompany != null)
  2503. {
  2504. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2505. }
  2506. else
  2507. {
  2508. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2509. }
  2510. }
  2511. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2512. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2513. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2514. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2515. string name = "";
  2516. foreach (string clientName in nameArray)
  2517. {
  2518. if (!name.Contains(clientName))
  2519. {
  2520. name += clientName + ",";
  2521. }
  2522. }
  2523. if (!string.IsNullOrWhiteSpace(name))
  2524. {
  2525. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2526. }
  2527. else
  2528. {
  2529. table.Range.Bookmarks["ClientName"].Text = "--";
  2530. }
  2531. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2532. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2533. table.Range.Bookmarks["JointTicket"].Text = "--";
  2534. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2535. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2536. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2537. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2538. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2539. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2540. #endregion
  2541. #region 循环数据处理
  2542. List<AirInfo> airs = new List<AirInfo>();
  2543. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2544. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2545. for (int i = 0; i < FlightsCode.Length; i++)
  2546. {
  2547. AirInfo air = new AirInfo();
  2548. string[] tempstr = DayArray[i]
  2549. .Replace("\r\n", string.Empty)
  2550. .Replace("\\r\\n", string.Empty)
  2551. .TrimStart().TrimEnd()
  2552. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2553. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2554. string starCity = "";
  2555. if (star_Three != null)
  2556. {
  2557. starCity = star_Three.AirPort;
  2558. }
  2559. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2560. string EndCity = "";
  2561. if (End_Three != null)
  2562. {
  2563. EndCity = End_Three.AirPort;
  2564. }
  2565. air.Destination = starCity + "/" + EndCity;
  2566. air.Flight = FlightsCode[i];
  2567. air.SeatingClass = item.CTypeName;
  2568. string dateTime = tempstr[2];
  2569. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2570. air.FlightDate = DateTemp;
  2571. air.DepartureTime = tempstr[5];
  2572. air.LandingTime = tempstr[6];
  2573. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2574. air.TicketStatus = "--";
  2575. air.Luggage = "--";
  2576. air.DepartureTerminal = "--";
  2577. air.LandingTerminal = "--";
  2578. airs.Add(air);
  2579. }
  2580. int row = 13;
  2581. for (int i = 0; i < airs.Count; i++)
  2582. {
  2583. if (airs.Count > 2)
  2584. {
  2585. for (int j = 0; j < airs.Count - 2; j++)
  2586. {
  2587. var CopyRow = table.Rows[12].Clone(true);
  2588. table.Rows.Add(CopyRow);
  2589. }
  2590. }
  2591. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2592. int index = 0;
  2593. foreach (PropertyInfo property in properties)
  2594. {
  2595. string value = property.GetValue(airs[i]).ToString();
  2596. Cell ishcel0 = table.Rows[row].Cells[index];
  2597. Paragraph p = new Paragraph(doc);
  2598. string s = value;
  2599. p.AppendChild(new Run(doc, s));
  2600. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2601. ishcel0.AppendChild(p);
  2602. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2603. index++;
  2604. }
  2605. row++;
  2606. }
  2607. #endregion
  2608. Paragraph lastParagraph = new Paragraph(doc);
  2609. //第一个表格末尾加段落
  2610. table.ParentNode.InsertAfter(lastParagraph, table);
  2611. //复制第一个表格
  2612. Table cloneTable = (Table)table.Clone(true);
  2613. //在文档末尾段落后面加入复制的表格
  2614. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2615. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2616. {
  2617. int rownewsIndex = 13;
  2618. for (int i = 0; i < 2; i++)
  2619. {
  2620. var CopyRow = table.Rows[12].Clone(true);
  2621. table.Rows.RemoveAt(13);
  2622. table.Rows.Add(CopyRow);
  2623. rownewsIndex++;
  2624. }
  2625. }
  2626. else
  2627. {
  2628. table.Rows.RemoveAt(12);
  2629. }
  2630. cloneTable.Rows.RemoveAt(12);
  2631. }
  2632. if (_AirTicketReservations.Count != 0)
  2633. {
  2634. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2635. if (FlightsCode.Length != 0)
  2636. {
  2637. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2638. if (_AirCompany != null)
  2639. {
  2640. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2641. }
  2642. else
  2643. {
  2644. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2645. }
  2646. }
  2647. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2648. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2649. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2650. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2651. string name = "";
  2652. foreach (string clientName in nameArray)
  2653. {
  2654. if (!name.Contains(clientName))
  2655. {
  2656. name += clientName + ",";
  2657. }
  2658. }
  2659. if (!string.IsNullOrWhiteSpace(name))
  2660. {
  2661. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2662. }
  2663. else
  2664. {
  2665. table.Range.Bookmarks["ClientName"].Text = "--";
  2666. }
  2667. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2668. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2669. table.Range.Bookmarks["JointTicket"].Text = "--";
  2670. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2671. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2672. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2673. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2674. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2675. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2676. }
  2677. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2678. //保存合并后的文档
  2679. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2680. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2681. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2682. return Ok(JsonView(true, "成功!", rst));
  2683. }
  2684. else
  2685. {
  2686. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2687. DocumentBuilder builder = new DocumentBuilder(doc);
  2688. int tableIndex = 0;//表格索引
  2689. //得到文档中的第一个表格
  2690. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2691. List<string> texts = new List<string>();
  2692. foreach (var item in _AirTicketReservations)
  2693. {
  2694. string[] FlightsCode = item.FlightsCode.Split('/');
  2695. if (FlightsCode.Length != 0)
  2696. {
  2697. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2698. if (_AirCompany != null)
  2699. {
  2700. if (!transDic.ContainsKey(_AirCompany.CnName))
  2701. {
  2702. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2703. }
  2704. }
  2705. else
  2706. {
  2707. if (!transDic.ContainsKey("--"))
  2708. {
  2709. transDic.Add("--", "--");
  2710. }
  2711. }
  2712. }
  2713. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2714. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2715. string name = "";
  2716. foreach (string clientName in nameArray)
  2717. {
  2718. name += clientName + ",";
  2719. }
  2720. if (!texts.Contains(name))
  2721. {
  2722. texts.Add(name);
  2723. }
  2724. List<AirInfo> airs = new List<AirInfo>();
  2725. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2726. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2727. for (int i = 0; i < FlightsCode.Length; i++)
  2728. {
  2729. AirInfo air = new AirInfo();
  2730. string[] tempstr = DayArray[i]
  2731. .Replace("\r\n", string.Empty)
  2732. .Replace("\\r\\n", string.Empty)
  2733. .TrimStart().TrimEnd()
  2734. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2735. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2736. if (star_Three != null)
  2737. {
  2738. if (!transDic.ContainsKey(star_Three.AirPort))
  2739. {
  2740. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2741. }
  2742. }
  2743. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2744. if (End_Three != null)
  2745. {
  2746. if (!transDic.ContainsKey(End_Three.AirPort))
  2747. {
  2748. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2749. }
  2750. }
  2751. if (!texts.Contains(item.CTypeName))
  2752. {
  2753. texts.Add(item.CTypeName);
  2754. }
  2755. }
  2756. }
  2757. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2758. if (transData.Count > 0)
  2759. {
  2760. foreach (TranslateResult item in transData)
  2761. {
  2762. if (!transDic.ContainsKey(item.Query))
  2763. {
  2764. transDic.Add(item.Query, item.Translation);
  2765. }
  2766. }
  2767. }
  2768. foreach (var item in _AirTicketReservations)
  2769. {
  2770. #region 处理固定数据
  2771. string[] FlightsCode = item.FlightsCode.Split('/');
  2772. if (FlightsCode.Length != 0)
  2773. {
  2774. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2775. if (_AirCompany != null)
  2776. {
  2777. string str = "--";
  2778. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2779. if (!string.IsNullOrEmpty(translateResult))
  2780. {
  2781. str = translateResult;
  2782. str = _airTicketResRep.Processing(str);
  2783. }
  2784. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2785. }
  2786. else
  2787. {
  2788. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2789. }
  2790. }
  2791. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2792. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2793. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2794. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2795. string names = "";
  2796. foreach (string clientName in nameArray)
  2797. {
  2798. names += clientName + ",";
  2799. }
  2800. if (!string.IsNullOrWhiteSpace(names))
  2801. {
  2802. string str = "--";
  2803. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2804. if (!string.IsNullOrEmpty(translateResult))
  2805. {
  2806. str = translateResult;
  2807. str = _airTicketResRep.Processing(str);
  2808. }
  2809. table.Range.Bookmarks["ClientName"].Text = str;
  2810. }
  2811. else
  2812. {
  2813. table.Range.Bookmarks["ClientName"].Text = "--";
  2814. }
  2815. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2816. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2817. table.Range.Bookmarks["JointTicket"].Text = "--";
  2818. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2819. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2820. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2821. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2822. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2823. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2824. #endregion
  2825. #region 循环数据处理
  2826. List<AirInfo> airs = new List<AirInfo>();
  2827. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2828. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2829. for (int i = 0; i < FlightsCode.Length; i++)
  2830. {
  2831. AirInfo air = new AirInfo();
  2832. string[] tempstr = DayArray[i]
  2833. .Replace("\r\n", string.Empty)
  2834. .Replace("\\r\\n", string.Empty)
  2835. .TrimStart().TrimEnd()
  2836. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2837. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2838. string starCity = "";
  2839. if (star_Three != null)
  2840. {
  2841. string str2 = "--";
  2842. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2843. if (!string.IsNullOrEmpty(translateResult2))
  2844. {
  2845. str2 = translateResult2;
  2846. str2 = _airTicketResRep.Processing(str2);
  2847. }
  2848. starCity = str2;
  2849. }
  2850. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2851. string EndCity = "";
  2852. if (End_Three != null)
  2853. {
  2854. string str1 = "--";
  2855. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2856. if (!string.IsNullOrEmpty(translateResult1))
  2857. {
  2858. str1 = translateResult1;
  2859. str1 = _airTicketResRep.Processing(str1);
  2860. }
  2861. EndCity = str1;
  2862. }
  2863. air.Destination = starCity + "/" + EndCity;
  2864. air.Flight = FlightsCode[i];
  2865. string str = "--";
  2866. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2867. if (!string.IsNullOrEmpty(translateResult))
  2868. {
  2869. str = translateResult;
  2870. str = _airTicketResRep.Processing(str);
  2871. }
  2872. air.SeatingClass = str;
  2873. string dateTime = tempstr[2];
  2874. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2875. air.FlightDate = DateTemp;
  2876. air.DepartureTime = tempstr[5];
  2877. air.LandingTime = tempstr[6];
  2878. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2879. air.TicketStatus = "--";
  2880. air.Luggage = "--";
  2881. air.DepartureTerminal = "--";
  2882. air.LandingTerminal = "--";
  2883. airs.Add(air);
  2884. }
  2885. int row = 13;
  2886. for (int i = 0; i < airs.Count; i++)
  2887. {
  2888. if (airs.Count > 2)
  2889. {
  2890. for (int j = 0; j < airs.Count - 2; j++)
  2891. {
  2892. var CopyRow = table.Rows[12].Clone(true);
  2893. table.Rows.Add(CopyRow);
  2894. }
  2895. }
  2896. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2897. int index = 0;
  2898. foreach (PropertyInfo property in properties)
  2899. {
  2900. string value = property.GetValue(airs[i]).ToString();
  2901. Cell ishcel0 = table.Rows[row].Cells[index];
  2902. Paragraph p = new Paragraph(doc);
  2903. string s = value;
  2904. p.AppendChild(new Run(doc, s));
  2905. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2906. ishcel0.AppendChild(p);
  2907. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2908. //ishcel0.CellFormat.VerticalAlignment=
  2909. index++;
  2910. }
  2911. row++;
  2912. }
  2913. #endregion
  2914. Paragraph lastParagraph = new Paragraph(doc);
  2915. //第一个表格末尾加段落
  2916. table.ParentNode.InsertAfter(lastParagraph, table);
  2917. //复制第一个表格
  2918. Table cloneTable = (Table)table.Clone(true);
  2919. //在文档末尾段落后面加入复制的表格
  2920. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2921. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2922. {
  2923. int rownewsIndex = 13;
  2924. for (int i = 0; i < 2; i++)
  2925. {
  2926. var CopyRow = table.Rows[12].Clone(true);
  2927. table.Rows.RemoveAt(13);
  2928. table.Rows.Add(CopyRow);
  2929. rownewsIndex++;
  2930. }
  2931. }
  2932. else
  2933. {
  2934. table.Rows.RemoveAt(12);
  2935. }
  2936. cloneTable.Rows.RemoveAt(12);
  2937. }
  2938. if (_AirTicketReservations.Count != 0)
  2939. {
  2940. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2941. if (FlightsCode.Length != 0)
  2942. {
  2943. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2944. if (_AirCompany != null)
  2945. {
  2946. string str = "--";
  2947. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2948. if (!string.IsNullOrEmpty(translateResult))
  2949. {
  2950. str = translateResult;
  2951. str = _airTicketResRep.Processing(str);
  2952. }
  2953. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2954. }
  2955. else
  2956. {
  2957. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2958. }
  2959. }
  2960. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2961. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2962. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2963. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2964. string names = "";
  2965. foreach (string clientName in nameArray)
  2966. {
  2967. names += clientName + ",";
  2968. }
  2969. if (!string.IsNullOrWhiteSpace(names))
  2970. {
  2971. string str = "--";
  2972. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2973. if (!string.IsNullOrEmpty(translateResult))
  2974. {
  2975. str = translateResult;
  2976. str = _airTicketResRep.Processing(str);
  2977. }
  2978. table.Range.Bookmarks["ClientName"].Text = str;
  2979. }
  2980. else
  2981. {
  2982. table.Range.Bookmarks["ClientName"].Text = "--";
  2983. }
  2984. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2985. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2986. table.Range.Bookmarks["JointTicket"].Text = "--";
  2987. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2988. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2989. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2990. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2991. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2992. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2993. }
  2994. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2995. //保存合并后的文档
  2996. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2997. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2998. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2999. return Ok(JsonView(true, "成功!", rst));
  3000. }
  3001. }
  3002. }
  3003. catch (Exception ex)
  3004. {
  3005. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3006. throw;
  3007. }
  3008. }
  3009. #endregion
  3010. #region 团组增减款项 --> 其他款项
  3011. /// <summary>
  3012. /// 团组增减款项下拉框绑定
  3013. /// </summary>
  3014. /// <param name="dto"></param>
  3015. /// <returns></returns>
  3016. [HttpPost]
  3017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3018. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3019. {
  3020. #region 参数验证
  3021. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3022. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3023. #endregion
  3024. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3025. }
  3026. /// <summary>
  3027. /// 根据团组Id查询团组增减款项
  3028. /// </summary>
  3029. /// <param name="dto"></param>
  3030. /// <returns></returns>
  3031. [HttpPost]
  3032. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3033. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3034. {
  3035. #region 参数验证
  3036. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3037. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3038. #endregion
  3039. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3040. }
  3041. /// <summary>
  3042. /// 团组增减款项操作(Status:1.新增,2.修改)
  3043. /// </summary>
  3044. /// <param name="dto"></param>
  3045. /// <returns></returns>
  3046. [HttpPost]
  3047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3048. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3049. {
  3050. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3051. if (groupData.Code != 200)
  3052. {
  3053. return Ok(JsonView(false, groupData.Msg));
  3054. }
  3055. #region 应用推送
  3056. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3057. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3058. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3059. #endregion
  3060. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3061. }
  3062. /// <summary>
  3063. /// 团组增减款项操作 删除
  3064. /// </summary>
  3065. /// <param name="dto"></param>
  3066. /// <returns></returns>
  3067. [HttpPost]
  3068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3069. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3070. {
  3071. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3072. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3073. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3074. if (res.Code == 0)
  3075. {
  3076. return Ok(JsonView(true, "删除成功!"));
  3077. }
  3078. return Ok(JsonView(false, "删除失败!"));
  3079. }
  3080. /// <summary>
  3081. /// 根据团组增减款项Id查询
  3082. /// </summary>
  3083. /// <param name="dto"></param>
  3084. /// <returns></returns>
  3085. [HttpPost]
  3086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3087. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3088. {
  3089. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3090. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3091. }
  3092. /// <summary>
  3093. /// 查询供应商名称
  3094. /// </summary>
  3095. /// <param name="dto"></param>
  3096. /// <returns></returns>
  3097. [HttpPost]
  3098. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3099. {
  3100. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3101. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3102. ?? new List<Grp_DecreasePayments>();
  3103. dbResult = dbResult.Distinct(new
  3104. ProductComparer()).ToList();
  3105. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3106. {
  3107. x.Id,
  3108. x.SupplierAddress,
  3109. x.SupplierArea,
  3110. x.SupplierContact,
  3111. x.SupplierContactNumber,
  3112. x.SupplierEmail,
  3113. x.SupplierName,
  3114. x.SupplierSocialAccount,
  3115. x.SupplierTypeId,
  3116. }).ToList());
  3117. return Ok(jw);
  3118. }
  3119. #endregion
  3120. #region 文件上传、删除
  3121. /// <summary>
  3122. /// region 文件上传 可以带参数
  3123. /// </summary>
  3124. /// <param name="file"></param>
  3125. /// <returns></returns>
  3126. [HttpPost]
  3127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3128. public async Task<IActionResult> UploadProject(IFormFile file)
  3129. {
  3130. //var TypeName = Request.Headers["TypeName"].ToString();
  3131. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3132. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3133. ////文件名称
  3134. //string projectFileName = file.FileName;
  3135. ////上传的文件的路径
  3136. //string filePath = $"{fileDir}/{projectFileName}";
  3137. //if (TypeName == "A")//A代表团组增减款项
  3138. //{
  3139. // filePath = fileDir + $@"\团组增减款项相关文件";
  3140. // if (!Directory.Exists(filePath))
  3141. // {
  3142. // Directory.CreateDirectory(filePath);
  3143. // }
  3144. // //上传的文件的路径
  3145. // filePath += $@"\{projectFileName}";
  3146. //}
  3147. //else if (TypeName == "B")//B代表商邀相关文件
  3148. //{
  3149. // //上传的文件的路径
  3150. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3151. // if (!Directory.Exists(filePath))
  3152. // {
  3153. // Directory.CreateDirectory(filePath);
  3154. // }
  3155. // //上传的文件的路径
  3156. // filePath = $@"\{projectFileName}";
  3157. //}
  3158. //try
  3159. //{
  3160. // using (FileStream fs = System.IO.File.Create(filePath))
  3161. // {
  3162. // file.CopyTo(fs);
  3163. // fs.Flush();
  3164. // }
  3165. //}
  3166. //catch (Exception ex)
  3167. //{
  3168. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3169. //}
  3170. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3171. try
  3172. {
  3173. var TypeName = Request.Headers["TypeName"].ToString();
  3174. if (file != null)
  3175. {
  3176. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3177. //文件名称
  3178. string projectFileName = file.FileName;
  3179. //上传的文件的路径
  3180. string filePath = $"{fileDir}/{projectFileName}";
  3181. if (TypeName == "A")//A代表团组增减款项
  3182. {
  3183. if (!Directory.Exists(fileDir))
  3184. {
  3185. Directory.CreateDirectory(fileDir);
  3186. }
  3187. //上传的文件的路径
  3188. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3189. }
  3190. else if (TypeName == "B")//B代表商邀相关文件
  3191. {
  3192. if (!Directory.Exists(fileDir))
  3193. {
  3194. Directory.CreateDirectory(fileDir);
  3195. }
  3196. //上传的文件的路径
  3197. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3198. }
  3199. using (FileStream fs = System.IO.File.Create(filePath))
  3200. {
  3201. file.CopyTo(fs);
  3202. fs.Flush();
  3203. }
  3204. return Ok(JsonView(true, "上传成功!", projectFileName));
  3205. }
  3206. else
  3207. {
  3208. return Ok(JsonView(false, "上传失败!"));
  3209. }
  3210. }
  3211. catch (Exception ex)
  3212. {
  3213. return Ok(JsonView(false, "程序错误!"));
  3214. }
  3215. }
  3216. /// <summary>
  3217. /// 删除指定文件
  3218. /// </summary>
  3219. /// <param name="dto"></param>
  3220. /// <returns></returns>
  3221. [HttpPost]
  3222. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3223. public async Task<IActionResult> DelFile(DelFileDto dto)
  3224. {
  3225. try
  3226. {
  3227. var TypeName = Request.Headers["TypeName"].ToString();
  3228. string filePath = "";
  3229. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3230. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3231. int id = 0;
  3232. if (TypeName == "A")
  3233. {
  3234. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3235. // 删除该文件
  3236. System.IO.File.Delete(filePath);
  3237. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  3238. }
  3239. else if (TypeName == "B")
  3240. {
  3241. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3242. // 删除该文件
  3243. System.IO.File.Delete(filePath);
  3244. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  3245. }
  3246. if (id != 0)
  3247. {
  3248. return Ok(JsonView(true, "成功!"));
  3249. }
  3250. else
  3251. {
  3252. return Ok(JsonView(false, "失败!"));
  3253. }
  3254. }
  3255. catch (Exception ex)
  3256. {
  3257. return Ok(JsonView(false, "程序错误!"));
  3258. throw;
  3259. }
  3260. }
  3261. #endregion
  3262. #region 商邀费用录入
  3263. /// <summary>
  3264. /// 根据团组Id查询商邀费用列表
  3265. /// </summary>
  3266. /// <param name="dto"></param>
  3267. /// <returns></returns>
  3268. [HttpPost]
  3269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3270. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3271. {
  3272. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3273. if (groupData.Code != 0)
  3274. {
  3275. return Ok(JsonView(false, groupData.Msg));
  3276. }
  3277. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3278. }
  3279. //
  3280. /// <summary>
  3281. /// 商邀费用 Info Page 基础数据源
  3282. /// </summary>
  3283. /// <param name="dto"></param>
  3284. /// <returns></returns>
  3285. [HttpPost]
  3286. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3287. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3288. {
  3289. try
  3290. {
  3291. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3292. if (groupData.Code != 0)
  3293. {
  3294. return Ok(JsonView(false, groupData.Msg));
  3295. }
  3296. return Ok(JsonView(true, "操作成功", groupData.Data));
  3297. }
  3298. catch (Exception ex)
  3299. {
  3300. return Ok(JsonView(false, ex.Message));
  3301. throw;
  3302. }
  3303. }
  3304. /// <summary>
  3305. /// 根据商邀费用ID查询C表和商邀费用数据
  3306. /// </summary>
  3307. /// <param name="dto"></param>
  3308. /// <returns></returns>
  3309. [HttpPost]
  3310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3311. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3312. {
  3313. try
  3314. {
  3315. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3316. if (groupData.Code != 0)
  3317. {
  3318. return Ok(JsonView(false, groupData.Msg));
  3319. }
  3320. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3321. }
  3322. catch (Exception ex)
  3323. {
  3324. return Ok(JsonView(false, ex.Message));
  3325. throw;
  3326. }
  3327. }
  3328. /// <summary>
  3329. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3330. /// </summary>
  3331. /// <param name="dto"></param>
  3332. /// <returns></returns>
  3333. [HttpPost]
  3334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3335. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3336. {
  3337. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3338. if (groupData.Code != 0)
  3339. {
  3340. return Ok(JsonView(false, groupData.Msg));
  3341. }
  3342. #region 应用推送
  3343. try
  3344. {
  3345. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3346. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3347. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3348. }
  3349. catch (Exception ex)
  3350. {
  3351. }
  3352. #endregion
  3353. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3354. }
  3355. /// <summary>
  3356. /// 商邀删除
  3357. /// </summary>
  3358. /// <param name="dto"></param>
  3359. /// <returns></returns>
  3360. [HttpPost]
  3361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3362. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3363. {
  3364. try
  3365. {
  3366. _sqlSugar.BeginTran();
  3367. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3368. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3369. {
  3370. IsDel = 1,
  3371. DeleteUserId = dto.DeleteUserId,
  3372. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3373. })
  3374. .Where(it => it.Id == dto.Id)
  3375. .ExecuteCommand();
  3376. if (res1 > 0)
  3377. {
  3378. int _diId = 0;
  3379. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3380. if (_ioaInfo != null)
  3381. {
  3382. _diId = _ioaInfo.DiId;
  3383. }
  3384. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3385. .SetColumns(a => new Grp_CreditCardPayment()
  3386. {
  3387. IsDel = 1,
  3388. DeleteUserId = dto.DeleteUserId,
  3389. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3390. })
  3391. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3392. .ExecuteCommand();
  3393. if (res2 > 0)
  3394. {
  3395. _sqlSugar.CommitTran();
  3396. return Ok(JsonView(true, "删除成功!"));
  3397. }
  3398. }
  3399. _sqlSugar.RollbackTran();
  3400. return Ok(JsonView(false, "删除失败"));
  3401. }
  3402. catch (Exception ex)
  3403. {
  3404. _sqlSugar.RollbackTran();
  3405. return Ok(JsonView(false, ex.Message));
  3406. }
  3407. }
  3408. /// <summary>
  3409. /// 团组模块文件上传
  3410. /// </summary>
  3411. /// <param name="dto"></param>
  3412. /// <returns></returns>
  3413. [HttpPost]
  3414. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3415. {
  3416. var jw = JsonView(false);
  3417. long M = 1024 * 1024;
  3418. if (dto.Files == null || dto.Files.Count == 0)
  3419. {
  3420. jw.Msg = "无文件信息!";
  3421. return Ok(jw);
  3422. }
  3423. if (dto.Files.Sum(x=>x.Length) > 20 * M)
  3424. {
  3425. jw.Msg = "文件大小超过20M!";
  3426. return Ok(jw);
  3427. }
  3428. //var nameSp = dto.File.FileName.Split(".");
  3429. //if (nameSp.Length < 2)
  3430. //{
  3431. // jw.Msg = "拓展名称有误!";
  3432. // return Ok(jw);
  3433. //}
  3434. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3435. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3436. //{
  3437. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3438. // return Ok(jw);
  3439. //}
  3440. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3441. if (Ctable == null)
  3442. {
  3443. jw.Msg = "Ctable指向有误!";
  3444. return Ok(jw);
  3445. }
  3446. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3447. if (groupInfo == null)
  3448. {
  3449. jw.Msg = "团组信息不存在!";
  3450. return Ok(jw);
  3451. }
  3452. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3453. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3454. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3455. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3456. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3457. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3458. try
  3459. {
  3460. if (!Directory.Exists(fileBase))
  3461. {
  3462. Directory.CreateDirectory(fileBase);
  3463. }
  3464. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3465. foreach (var fileStream in dto.Files)
  3466. {
  3467. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3468. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3469. {
  3470. Cid = dto.Cid,
  3471. CreateTime = DateTime.Now,
  3472. CreateUserId = dto.Userid,
  3473. Ctable = dto.Ctable,
  3474. Diid = dto.Diid,
  3475. IsDel = 0,
  3476. FilePath = saveFilePath,
  3477. FileName = fileStream.FileName
  3478. };
  3479. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3480. {
  3481. fileStream.CopyTo(fs);
  3482. fs.Flush();
  3483. }
  3484. saveArr.Add(file);
  3485. }
  3486. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3487. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3488. jw = JsonView(true, "保存成功!", new
  3489. {
  3490. count = addResult,
  3491. filesName = saveArr.Select(x => x.FileName)
  3492. }) ;
  3493. }
  3494. catch (Exception ex)
  3495. {
  3496. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3497. {
  3498. count = 0,
  3499. filesName = new string[0],
  3500. }) ;
  3501. }
  3502. return Ok(jw);
  3503. }
  3504. /// <summary>
  3505. /// 查询各模块已保存文件
  3506. /// </summary>
  3507. /// <param name="dto"></param>
  3508. /// <returns></returns>
  3509. [HttpPost]
  3510. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3511. {
  3512. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3513. .AndIF(dto.UserId != -1 , x => x.CreateUserId == dto.UserId);
  3514. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x=>x.Id).ToList();
  3515. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3516. {
  3517. expression = Expressionable.Create<Grp_GroupModelFile>()
  3518. .And(x=>visaIds.Contains(x.CreateUserId));
  3519. }
  3520. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3521. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3522. .Where(expression.ToExpression())
  3523. .ToList();
  3524. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3525. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3526. {
  3527. x.FileName,
  3528. x.Id,
  3529. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3530. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3531. })));
  3532. }
  3533. /// <summary>
  3534. /// 下载该团组下的所有文件
  3535. /// </summary>
  3536. /// <param name="dto"></param>
  3537. /// <returns></returns>
  3538. [HttpPost]
  3539. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3540. {
  3541. var jw = JsonView(false);
  3542. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3543. if (groupInfo == null)
  3544. {
  3545. jw.Msg = "团组信息不存在!";
  3546. return Ok(jw);
  3547. }
  3548. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3549. var isModule = Convert.ToBoolean(dto.isModule);
  3550. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3551. IOOperatorHelper io = new IOOperatorHelper();
  3552. if (isModule)
  3553. {
  3554. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3555. foreach (var moduleArr in moduleGroup)
  3556. {
  3557. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3558. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3559. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3560. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3561. foreach (var item in moduleArr)
  3562. {
  3563. if (System.IO.File.Exists(item.FilePath))
  3564. {
  3565. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3566. {
  3567. byte[] bytes = new byte[fileStream.Length];
  3568. fileStream.Read(bytes, 0, bytes.Length);
  3569. fileStream.Close();
  3570. Stream stream = new MemoryStream(bytes);
  3571. chiZips.Add(item.FileName, stream);
  3572. }
  3573. }
  3574. }
  3575. if (chiZips.Count > 0)
  3576. {
  3577. var byts = io.ConvertZipStream(chiZips);
  3578. Stream stream = new MemoryStream(byts);
  3579. Zips.Add(key.Name+"_.zip", stream);
  3580. }
  3581. }
  3582. }
  3583. else
  3584. {
  3585. foreach (var item in dbQuery)
  3586. {
  3587. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3588. {
  3589. byte[] bytes = new byte[fileStream.Length];
  3590. fileStream.Read(bytes, 0, bytes.Length);
  3591. fileStream.Close();
  3592. Stream stream = new MemoryStream(bytes);
  3593. while (Zips.Keys.Contains(item.FileName))
  3594. {
  3595. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3596. }
  3597. Zips.Add(item.FileName, stream);
  3598. }
  3599. }
  3600. }
  3601. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3602. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3603. if (Zips.Count > 0)
  3604. {
  3605. var byts = io.ConvertZipStream(Zips);
  3606. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3607. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  3608. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  3609. }
  3610. else
  3611. {
  3612. jw.Msg = "暂无生成文件!";
  3613. }
  3614. return Ok(jw);
  3615. }
  3616. /// <summary>
  3617. /// 下载该团组下此模块的所有文件
  3618. /// </summary>
  3619. /// <param name="dto"></param>
  3620. /// <returns></returns>
  3621. [HttpPost]
  3622. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  3623. {
  3624. var jw = JsonView(false);
  3625. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3626. if (groupInfo == null)
  3627. {
  3628. jw.Msg = "团组信息不存在!";
  3629. return Ok(jw);
  3630. }
  3631. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  3632. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  3633. && x.IsDel == 0);
  3634. if (key == null)
  3635. {
  3636. jw.Msg = "Ctable指向错误!";
  3637. return Ok(jw);
  3638. }
  3639. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3640. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3641. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3642. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3643. IOOperatorHelper io = new IOOperatorHelper();
  3644. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3645. foreach (var item in dbQuery)
  3646. {
  3647. if (System.IO.File.Exists(item.FilePath))
  3648. {
  3649. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3650. {
  3651. byte[] bytes = new byte[fileStream.Length];
  3652. fileStream.Read(bytes, 0, bytes.Length);
  3653. fileStream.Close();
  3654. Stream stream = new MemoryStream(bytes);
  3655. while (Zips.Keys.Contains(item.FileName))
  3656. {
  3657. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3658. }
  3659. Zips.Add(item.FileName, stream);
  3660. }
  3661. }
  3662. }
  3663. if (Zips.Count > 0)
  3664. {
  3665. var byts = io.ConvertZipStream(Zips);
  3666. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3667. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  3668. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  3669. }
  3670. else
  3671. {
  3672. jw.Msg = "暂无生成文件!";
  3673. }
  3674. return Ok(jw);
  3675. }
  3676. /// <summary>
  3677. /// 删除该团组下的指定文件
  3678. /// </summary>
  3679. /// <param name="dto"></param>
  3680. /// <returns></returns>
  3681. [HttpPost]
  3682. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  3683. {
  3684. var jw = JsonView(false);
  3685. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  3686. if (sing == null)
  3687. {
  3688. jw.Msg = "暂无";
  3689. return Ok(jw);
  3690. }
  3691. if (System.IO.File.Exists(sing.FilePath))
  3692. {
  3693. try
  3694. {
  3695. System.IO.File.Delete(sing.FilePath);
  3696. }
  3697. catch (Exception ex)
  3698. {
  3699. jw.Msg = "删除失败!" + ex.Message;
  3700. return Ok(jw);
  3701. }
  3702. }
  3703. sing.IsDel = 1;
  3704. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  3705. sing.DeleteUserId = dto.UserId;
  3706. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  3707. jw = JsonView(true, "删除成功!");
  3708. return Ok(jw);
  3709. }
  3710. #endregion
  3711. #region 团组英文资料
  3712. /// <summary>
  3713. /// 查询团组英文所有资料
  3714. /// </summary>
  3715. /// <param name="dto"></param>
  3716. /// <returns></returns>
  3717. [HttpPost]
  3718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3719. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3720. {
  3721. try
  3722. {
  3723. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3724. if (groupData.Code != 0)
  3725. {
  3726. return Ok(JsonView(false, groupData.Msg));
  3727. }
  3728. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3729. }
  3730. catch (Exception ex)
  3731. {
  3732. return Ok(JsonView(false, "程序错误!"));
  3733. throw;
  3734. }
  3735. }
  3736. /// <summary>
  3737. /// 团组英文资料操作(Status:1.新增,2.修改)
  3738. /// </summary>
  3739. /// <param name="dto"></param>
  3740. /// <returns></returns>
  3741. [HttpPost]
  3742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3743. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3744. {
  3745. try
  3746. {
  3747. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3748. if (groupData.Code != 0)
  3749. {
  3750. return Ok(JsonView(false, groupData.Msg));
  3751. }
  3752. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3753. }
  3754. catch (Exception ex)
  3755. {
  3756. return Ok(JsonView(false, "程序错误!"));
  3757. throw;
  3758. }
  3759. }
  3760. /// <summary>
  3761. /// 团组英文资料Id查询数据
  3762. /// </summary>
  3763. /// <param name="dto"></param>
  3764. /// <returns></returns>
  3765. [HttpPost]
  3766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3767. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3768. {
  3769. try
  3770. {
  3771. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3772. if (_DelegationEnData != null)
  3773. {
  3774. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3775. }
  3776. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3777. }
  3778. catch (Exception ex)
  3779. {
  3780. return Ok(JsonView(false, "程序错误!"));
  3781. throw;
  3782. }
  3783. }
  3784. /// <summary>
  3785. /// 团组英文资料删除
  3786. /// </summary>
  3787. /// <param name="dto"></param>
  3788. /// <returns></returns>
  3789. [HttpPost]
  3790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3791. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3792. {
  3793. try
  3794. {
  3795. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3796. if (!res)
  3797. {
  3798. return Ok(JsonView(false, "删除失败"));
  3799. }
  3800. return Ok(JsonView(true, "删除成功!"));
  3801. }
  3802. catch (Exception ex)
  3803. {
  3804. return Ok(JsonView(false, "程序错误!"));
  3805. throw;
  3806. }
  3807. }
  3808. #endregion
  3809. #region 导出邀请函
  3810. /// <summary>
  3811. /// 导出邀请函页面初始化
  3812. /// </summary>
  3813. /// <param name="dto"></param>
  3814. /// <returns></returns>
  3815. [HttpPost]
  3816. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3817. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3818. {
  3819. try
  3820. {
  3821. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3822. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3823. if (dto.DiId == 0)
  3824. {
  3825. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3826. }
  3827. else
  3828. {
  3829. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3830. }
  3831. return Ok(JsonView(true, "查询成功!", new
  3832. {
  3833. deleClient = crm_Deles,
  3834. delegations = grp_Delegations
  3835. }));
  3836. }
  3837. catch (Exception ex)
  3838. {
  3839. return Ok(JsonView(false, "程序错误!"));
  3840. throw;
  3841. }
  3842. }
  3843. /// <summary>
  3844. /// 导出邀请函
  3845. /// </summary>
  3846. /// <param name="dto"></param>
  3847. /// <returns></returns>
  3848. [HttpPost]
  3849. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3850. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3851. {
  3852. #region 参数验证
  3853. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3854. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3855. #endregion
  3856. try
  3857. {
  3858. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3859. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3860. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3861. From Grp_TourClientList tcl
  3862. Left Join
  3863. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3864. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3865. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3866. From Crm_DeleClient dc
  3867. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3868. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3869. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3870. Where dc.IsDel = 0) temp
  3871. On temp.DcId =tcl.ClientId
  3872. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3873. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3874. List<string> texts = new List<string>();
  3875. if (datas.Count != 0)
  3876. {
  3877. foreach (TourClientListDetailsView item in datas)
  3878. {
  3879. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3880. {
  3881. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3882. }
  3883. else
  3884. {
  3885. string name = item.LastName + item.FirstName;
  3886. texts.Add(name);
  3887. }
  3888. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3889. {
  3890. if (!transDic.ContainsKey(item.Job))
  3891. {
  3892. texts.Add(item.Job);
  3893. }
  3894. }
  3895. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3896. {
  3897. texts.Add(item.CompanyFullName);
  3898. }
  3899. }
  3900. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3901. if (transData.Count > 0)
  3902. {
  3903. foreach (TranslateResult item in transData)
  3904. {
  3905. if (!transDic.ContainsKey(item.Query))
  3906. {
  3907. transDic.Add(item.Query, item.Translation);
  3908. }
  3909. }
  3910. }
  3911. List<GuestList> list = new List<GuestList>();
  3912. foreach (TourClientListDetailsView dele in datas)
  3913. {
  3914. GuestList guestList = new GuestList();
  3915. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3916. {
  3917. guestList.Name = dele.Pinyin;
  3918. }
  3919. else
  3920. {
  3921. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3922. guestList.Name = Name;
  3923. }
  3924. if (dele.Sex == 0)
  3925. {
  3926. guestList.Sex = "Male";
  3927. }
  3928. else if (dele.Sex == 1)
  3929. {
  3930. guestList.Sex = "Female";
  3931. }
  3932. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3933. if (!string.IsNullOrEmpty(dele.Job))
  3934. {
  3935. guestList.Job = dele.Job;
  3936. }
  3937. list.Add(guestList);
  3938. }
  3939. //载入模板
  3940. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3941. DocumentBuilder builder = new DocumentBuilder(doc);
  3942. //获取word里所有表格
  3943. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3944. //获取所填表格的序数
  3945. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3946. var rowStart = tableOne.Rows[0]; //获取第1行
  3947. //循环赋值
  3948. for (int i = 0; i < list.Count; i++)
  3949. {
  3950. builder.MoveToCell(0, i + 1, 0, 0);
  3951. builder.Write(list[i].Name.ToString());
  3952. builder.MoveToCell(0, i + 1, 1, 0);
  3953. builder.Write(list[i].Sex.ToString());
  3954. builder.MoveToCell(0, i + 1, 2, 0);
  3955. builder.Write(list[i].DOB.ToString());
  3956. builder.MoveToCell(0, i + 1, 3, 0);
  3957. builder.Write(list[i].Job.ToString());
  3958. }
  3959. //删除多余行
  3960. while (tableOne.Rows.Count > list.Count + 1)
  3961. {
  3962. tableOne.Rows.RemoveAt(list.Count + 1);
  3963. }
  3964. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3965. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3966. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3967. doc.Save(filePath);
  3968. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3969. return Ok(JsonView(true, "操作成功!", Url));
  3970. }
  3971. else
  3972. {
  3973. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3974. }
  3975. }
  3976. catch (Exception ex)
  3977. {
  3978. return Ok(JsonView(false, ex.Message));
  3979. throw;
  3980. }
  3981. }
  3982. #endregion
  3983. #region 团组经理模块 出入境费用
  3984. ///// <summary>
  3985. ///// 团组模块 - 出入境费用
  3986. ///// </summary>
  3987. ///// <returns></returns>
  3988. //[HttpPost]
  3989. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3990. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3991. //{
  3992. // try
  3993. // {
  3994. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3995. // if (data.Code != 0)
  3996. // {
  3997. // return Ok(JsonView(false, data.Msg));
  3998. // }
  3999. // return Ok(JsonView(true, "查询成功!"));
  4000. // }
  4001. // catch (Exception ex)
  4002. // {
  4003. // return Ok(JsonView(false, ex.Message));
  4004. // throw;
  4005. // }
  4006. //}
  4007. /// <summary>
  4008. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4009. /// </summary>
  4010. /// <returns></returns>
  4011. [HttpPost]
  4012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4013. public async Task<IActionResult> SetDayAndCostAreaChange()
  4014. {
  4015. try
  4016. {
  4017. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4018. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4019. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4020. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4021. foreach (var item in unite) //处理交集数据
  4022. {
  4023. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4024. }
  4025. foreach (var item in merge) //处理差集数据
  4026. {
  4027. int nationalTravelFeeId = 0;
  4028. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4029. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4030. else
  4031. {
  4032. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4033. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4034. }
  4035. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4036. }
  4037. //只更新dayAndCost 的 nationalTravelFeeId;
  4038. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4039. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4040. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4041. }
  4042. catch (Exception ex)
  4043. {
  4044. return Ok(JsonView(false, ex.Message));
  4045. throw;
  4046. }
  4047. }
  4048. /// <summary>
  4049. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4050. /// </summary>
  4051. /// <returns></returns>
  4052. [HttpPost]
  4053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4054. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4055. {
  4056. try
  4057. {
  4058. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4059. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4060. //SetDataInfoView
  4061. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4062. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4063. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4064. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4065. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4066. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4067. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4068. //默认币种显示
  4069. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4070. {
  4071. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4072. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4073. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4074. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4075. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4076. };
  4077. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4078. if (_currencyRate.Count > 0)
  4079. {
  4080. foreach (var item in _currencyInfos)
  4081. {
  4082. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4083. if (rateInfo != null)
  4084. {
  4085. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4086. rate1 *= 1.035M;
  4087. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4088. }
  4089. }
  4090. }
  4091. return Ok(JsonView(true, "查询成功!", new
  4092. {
  4093. GroupNameData = groupNameData.Data,
  4094. CurrencyData = _CurrencyData,
  4095. WordTypeData = _WordTypeData,
  4096. ExcelTypeData = _ExcelTypeData,
  4097. CurrencyInit = _currencyInfos
  4098. }));
  4099. }
  4100. catch (Exception ex)
  4101. {
  4102. return Ok(JsonView(false, ex.Message));
  4103. throw;
  4104. }
  4105. }
  4106. /// <summary>
  4107. /// 团组模块 - 出入境费用
  4108. /// 实时汇率 tips
  4109. /// 签证费用 tips
  4110. /// </summary>
  4111. /// <returns></returns>
  4112. [HttpPost]
  4113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4114. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4115. {
  4116. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4117. //默认币种显示
  4118. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4119. {
  4120. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4121. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4122. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4123. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4124. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4125. };
  4126. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4127. List<dynamic> reteInfos = new List<dynamic>();
  4128. if (_currencyRate.Count > 0)
  4129. {
  4130. foreach (var item in _currencyInfos)
  4131. {
  4132. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4133. if (rateInfo != null)
  4134. {
  4135. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4136. decimal rate1 = item.Rate;
  4137. rate1 *= 1.03M;
  4138. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4139. reteInfos.Add(new
  4140. {
  4141. currCode = item.CurrencyCode,
  4142. currName = item.CurrencyName,
  4143. rate = rate2,
  4144. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4145. });
  4146. }
  4147. }
  4148. }
  4149. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4150. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4151. return Ok(JsonView(true, "查询成功!", new
  4152. {
  4153. //GroupNameData = groupNameData.Data,
  4154. visaData = visaData.Data,
  4155. airData = airData.Data,
  4156. reteInfos = reteInfos
  4157. }));
  4158. }
  4159. /// <summary>
  4160. /// 团组模块 - 出入境费用 - Info
  4161. /// </summary>
  4162. /// <returns></returns>
  4163. [HttpPost]
  4164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4165. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4166. {
  4167. try
  4168. {
  4169. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  4170. if (data.Code != 0)
  4171. {
  4172. return Ok(JsonView(false, data.Msg));
  4173. }
  4174. return Ok(JsonView(true, "查询成功!", data.Data));
  4175. }
  4176. catch (Exception ex)
  4177. {
  4178. return Ok(JsonView(false, ex.Message));
  4179. }
  4180. }
  4181. /// <summary>
  4182. /// 团组模块 - 出入境费用 - Add And Update
  4183. /// </summary>
  4184. /// <returns></returns>
  4185. [HttpPost]
  4186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4187. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4188. {
  4189. try
  4190. {
  4191. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4192. if (data.Code != 0)
  4193. {
  4194. return Ok(JsonView(false, data.Msg));
  4195. }
  4196. //生成默认文件pdf并且通知人员
  4197. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4198. {
  4199. DiId = dto.DiId,
  4200. ExportType = 1,
  4201. SubTypeId = 1005
  4202. }, "pdf");
  4203. //发送通知
  4204. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4205. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4206. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4207. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign,fileUrl);
  4208. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208","233","21" }, dto.UserId, url);
  4209. return Ok(JsonView(true, data.Msg, data.Data));
  4210. }
  4211. catch (Exception ex)
  4212. {
  4213. return Ok(JsonView(false, ex.Message));
  4214. }
  4215. }
  4216. /// <summary>
  4217. /// 团组模块 - 出入境费用 - Confirm 费用
  4218. /// </summary>
  4219. /// <returns></returns>
  4220. [HttpPost]
  4221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4222. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4223. {
  4224. //TODO:测试完毕需把对应的用户ID更改
  4225. //1、数据表添加字段
  4226. //2、更改字段接口()
  4227. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4228. //3、确认成功 给财务发送消息
  4229. if (_view.Code == 200)
  4230. {
  4231. if (dto.Type == 1)
  4232. {
  4233. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4234. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4235. }
  4236. }
  4237. return Ok(_view);
  4238. }
  4239. /// <summary>
  4240. /// 团组模块 - 出入境费用 - File downlaod
  4241. /// </summary>
  4242. /// <param name="dto"></param>
  4243. /// <returns></returns>
  4244. [HttpPost]
  4245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4246. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4247. {
  4248. try
  4249. {
  4250. if (dto.DiId < 1)
  4251. {
  4252. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4253. }
  4254. if (dto.ExportType < 1)
  4255. {
  4256. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  4257. }
  4258. if (dto.SubTypeId < 1)
  4259. {
  4260. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  4261. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4262. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4263. 3 团组成员名单 1 团组成员名单"));
  4264. }
  4265. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4266. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4267. if (_EnterExitCosts == null)
  4268. {
  4269. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  4270. }
  4271. //数据源
  4272. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4273. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4274. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4275. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4276. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4277. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4278. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4279. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4280. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4281. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4282. .Select((tcl, dc, cc) => new
  4283. {
  4284. Name = dc.LastName + dc.FirstName,
  4285. Sex = dc.Sex,
  4286. Birthday = dc.BirthDay,
  4287. Company = cc.CompanyFullName,
  4288. Job = dc.Job
  4289. })
  4290. .ToList();
  4291. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4292. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4293. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4294. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4295. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4296. if (dto.ExportType == 1) //明细表
  4297. {
  4298. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4299. {
  4300. //获取模板
  4301. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4302. //载入模板
  4303. Document doc = new Document(tempPath);
  4304. DocumentBuilder builder = new DocumentBuilder(doc);
  4305. //利用键值对存放数据
  4306. Dictionary<string, string> dic = new Dictionary<string, string>();
  4307. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4308. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4309. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4310. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4311. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4312. //境内费用(其他费用)
  4313. if (_EnterExitCosts.ChoiceOne == 1)
  4314. {
  4315. string row1_1 = "";
  4316. if (_EnterExitCosts.Visa > 0)
  4317. {
  4318. //insidePayTotal += _EnterExitCosts.Visa;
  4319. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4320. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4321. {
  4322. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4323. }
  4324. }
  4325. string row1_2 = "";
  4326. if (_EnterExitCosts.YiMiao > 0)
  4327. {
  4328. //insidePayTotal += _EnterExitCosts.YiMiao;
  4329. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4330. }
  4331. if (_EnterExitCosts.HeSuan > 0)
  4332. {
  4333. //insidePayTotal += _EnterExitCosts.HeSuan;
  4334. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4335. }
  4336. if (_EnterExitCosts.Service > 0)
  4337. {
  4338. //insidePayTotal += _EnterExitCosts.Service;
  4339. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4340. }
  4341. string row1_3 = "";
  4342. if (_EnterExitCosts.Safe > 0)
  4343. {
  4344. //insidePayTotal += _EnterExitCosts.Safe;
  4345. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4346. }
  4347. if (_EnterExitCosts.Ticket > 0)
  4348. {
  4349. //insidePayTotal += _EnterExitCosts.Ticket;
  4350. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4351. }
  4352. string row1 = "";
  4353. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4354. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4355. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4356. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4357. dic.Add("Row1Str", row1);
  4358. }
  4359. string airTotalStr = string.Empty,
  4360. airPriceStr = string.Empty;
  4361. //经济舱
  4362. if (_EnterExitCosts.SumJJC == 1)
  4363. {
  4364. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4365. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4366. }
  4367. //公务舱
  4368. if (_EnterExitCosts.SumGWC == 1)
  4369. {
  4370. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4371. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4372. }
  4373. //头等舱
  4374. if (_EnterExitCosts.SumTDC == 1)
  4375. {
  4376. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4377. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4378. }
  4379. dic.Add("AirTotalStr", airTotalStr);
  4380. dic.Add("AirPriceStr", airPriceStr);
  4381. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4382. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4383. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4384. int table1Row = 0,
  4385. table2Row = 0,
  4386. table3Row = 0,
  4387. table4Row = 0;
  4388. //住宿费
  4389. if (_EnterExitCosts.ChoiceThree == 1)
  4390. {
  4391. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4392. table1Row = dac1.Count;
  4393. #region 填充word表格内容
  4394. for (int i = 0; i < dac1.Count; i++)
  4395. {
  4396. Grp_DayAndCost dac = dac1[i];
  4397. if (dac == null) continue;
  4398. builder.MoveToCell(0, i, 0, 0);
  4399. builder.Write("第" + dac.Days.ToString() + "晚:");
  4400. builder.MoveToCell(0, i, 1, 0);
  4401. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4402. //builder.Write(dac.Place == null ? "" : dac.Place);
  4403. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4404. builder.MoveToCell(0, i, 2, 0);
  4405. builder.Write("费用标准:");
  4406. string curr = "";
  4407. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4408. if (currData != null)
  4409. {
  4410. curr = currData.Name;
  4411. }
  4412. builder.MoveToCell(0, i, 3, 0);
  4413. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4414. builder.MoveToCell(0, i, 4, 0);
  4415. builder.Write("费用小计:");
  4416. builder.MoveToCell(0, i, 5, 0);
  4417. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4418. }
  4419. #endregion
  4420. }else dic.Add("SubZS","0.00");
  4421. //删除多余行
  4422. while (table1.Rows.Count > table1Row)
  4423. {
  4424. table1.Rows.RemoveAt(table1Row);
  4425. }
  4426. //伙食费
  4427. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4428. if (_EnterExitCosts.ChoiceFour == 1)
  4429. {
  4430. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4431. table2Row = dac2.Count;
  4432. #region 填充word表格内容
  4433. for (int i = 0; i < dac2.Count; i++)
  4434. {
  4435. Grp_DayAndCost dac = dac2[i];
  4436. if (dac == null) continue;
  4437. builder.MoveToCell(1, i, 0, 0);
  4438. builder.Write("第" + dac.Days.ToString() + "天:");
  4439. builder.MoveToCell(1, i, 1, 0);
  4440. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4441. builder.MoveToCell(1, i, 2, 0);
  4442. builder.Write("费用标准:");
  4443. string curr = "";
  4444. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4445. if (currData != null)
  4446. {
  4447. curr = currData.Name;
  4448. }
  4449. builder.MoveToCell(1, i, 3, 0);
  4450. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4451. builder.MoveToCell(1, i, 4, 0);
  4452. builder.Write("费用小计:");
  4453. builder.MoveToCell(1, i, 5, 0);
  4454. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4455. }
  4456. #endregion
  4457. }else dic.Add("SubHS","0.00");
  4458. //删除多余行
  4459. while (table2.Rows.Count > table2Row)
  4460. {
  4461. table2.Rows.RemoveAt(table2Row);
  4462. }
  4463. //公杂费
  4464. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4465. if (_EnterExitCosts.ChoiceFive == 1)
  4466. {
  4467. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4468. table3Row = dac3.Count;
  4469. #region 填充word表格内容
  4470. for (int i = 0; i < dac3.Count; i++)
  4471. {
  4472. Grp_DayAndCost dac = dac3[i];
  4473. if (dac == null) continue;
  4474. builder.MoveToCell(2, i, 0, 0);
  4475. builder.Write("第" + dac.Days.ToString() + "天:");
  4476. builder.MoveToCell(2, i, 1, 0);
  4477. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4478. builder.MoveToCell(2, i, 2, 0);
  4479. builder.Write("费用标准:");
  4480. string curr = "";
  4481. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4482. if (currData != null)
  4483. {
  4484. curr = currData.Name;
  4485. }
  4486. builder.MoveToCell(2, i, 3, 0);
  4487. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4488. builder.MoveToCell(2, i, 4, 0);
  4489. builder.Write("费用小计:");
  4490. builder.MoveToCell(2, i, 5, 0);
  4491. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4492. }
  4493. //删除多余行
  4494. while (table3.Rows.Count > table3Row)
  4495. {
  4496. table3.Rows.RemoveAt(table3Row);
  4497. }
  4498. #endregion
  4499. }else dic.Add("SubGZF", "0.00");
  4500. //删除多余行
  4501. while (table3.Rows.Count > table3Row)
  4502. {
  4503. table3.Rows.RemoveAt(table3Row);
  4504. }
  4505. //培训费
  4506. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4507. if (_EnterExitCosts.ChoiceSix == 1)
  4508. {
  4509. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4510. dic.Add("SubPX", pxStr);
  4511. table4Row = dac4.Count;
  4512. #region 填充word表格内容
  4513. for (int i = 0; i < dac4.Count; i++)
  4514. {
  4515. Grp_DayAndCost dac = dac4[i];
  4516. if (dac == null) continue;
  4517. builder.MoveToCell(3, i, 0, 0);
  4518. builder.Write("第" + dac.Days.ToString() + "天:");
  4519. builder.MoveToCell(3, i, 1, 0);
  4520. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4521. builder.MoveToCell(3, i, 2, 0);
  4522. builder.Write("费用标准:");
  4523. string curr = "";
  4524. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4525. if (currData != null)
  4526. {
  4527. curr = currData.Name;
  4528. }
  4529. builder.MoveToCell(3, i, 3, 0);
  4530. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4531. builder.MoveToCell(3, i, 4, 0);
  4532. builder.Write("费用小计:");
  4533. builder.MoveToCell(3, i, 5, 0);
  4534. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4535. }
  4536. #endregion
  4537. }
  4538. //else dic.Add("SubPX","0.00");
  4539. //删除多余行
  4540. while (table4.Rows.Count > table4Row)
  4541. {
  4542. table4.Rows.RemoveAt(table4Row);
  4543. }
  4544. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
  4545. decimal subJJC = 0.00M,
  4546. subGWC = 0.00M,
  4547. subTDC = 0.00M;
  4548. //经济舱
  4549. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  4550. //公务舱
  4551. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  4552. //头等舱
  4553. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  4554. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4555. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4556. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  4557. #region 填充word模板书签内容
  4558. foreach (var key in dic.Keys)
  4559. {
  4560. builder.MoveToBookmark(key);
  4561. builder.Write(dic[key]);
  4562. }
  4563. #endregion
  4564. //文件名
  4565. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  4566. AsposeHelper.removewatermark_v2180();
  4567. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4568. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4569. return Ok(JsonView(true, "成功", new { Url = url }));
  4570. }
  4571. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4572. {
  4573. //获取模板
  4574. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4575. //载入模板
  4576. Document doc = new Document(tempPath);
  4577. DocumentBuilder builder = new DocumentBuilder(doc);
  4578. Dictionary<string, string> dic = new Dictionary<string, string>();
  4579. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4580. {
  4581. List<string> list = new List<string>();
  4582. try
  4583. {
  4584. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4585. foreach (var item in spilitArr)
  4586. {
  4587. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4588. var depCode = spDotandEmpty[2].Substring(0, 3);
  4589. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4590. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4591. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4592. list.Add(depName);
  4593. list.Add(arrName);
  4594. }
  4595. list = list.Distinct().ToList();
  4596. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4597. }
  4598. catch (Exception)
  4599. {
  4600. dic.Add("ReturnCode", "行程录入不正确!");
  4601. }
  4602. }
  4603. else
  4604. {
  4605. dic.Add("ReturnCode", "未录入行程!");
  4606. }
  4607. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4608. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4609. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4610. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4611. {
  4612. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4613. dic.Add("Day", sp.Days.ToString());
  4614. }
  4615. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4616. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4617. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4618. //dic.Add("Names", Names);
  4619. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4620. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4621. decimal dac1totalPrice = 0.00M;
  4622. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  4623. foreach (var dac in dac1)
  4624. {
  4625. if (dac.SubTotal == 0.00M)
  4626. {
  4627. continue;
  4628. }
  4629. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4630. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4631. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4632. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4633. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4634. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4635. builder.Write(currency);//币种
  4636. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4637. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4638. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4639. builder.Write("");//人数
  4640. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4641. builder.Write("");//天数
  4642. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4643. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4644. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4645. decimal rate = 0.00M;
  4646. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4647. builder.Write(rate.ToString("#0.0000"));//汇率
  4648. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4649. decimal rbmPrice = dac.SubTotal;
  4650. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4651. accommodationStartIndex++;
  4652. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4653. }
  4654. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4655. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  4656. {
  4657. table1.Rows.RemoveAt(i - 1);
  4658. foodandotherStartIndex--;
  4659. }
  4660. if (dac2.Count == dac3.Count)//国家 币种 金额
  4661. {
  4662. for (int i = 0; i < dac2.Count; i++)
  4663. {
  4664. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4665. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4666. }
  4667. }
  4668. decimal dac2totalPrice = 0.00M;
  4669. foreach (var dac in dac2)
  4670. {
  4671. if (dac.SubTotal == 0)
  4672. {
  4673. continue;
  4674. }
  4675. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4676. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4677. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4678. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4679. builder.Write(currency);//币种
  4680. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4681. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4682. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4683. builder.Write("");//人数
  4684. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4685. builder.Write("");//天数
  4686. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4687. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4688. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4689. decimal rate = 0.00M;
  4690. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4691. builder.Write(rate.ToString("#0.0000"));//汇率
  4692. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4693. decimal rbmPrice = dac.SubTotal;
  4694. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4695. foodandotherStartIndex++;
  4696. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4697. }
  4698. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4699. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4700. {
  4701. table1.Rows.RemoveAt(i - 1);
  4702. }
  4703. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4704. string otherFeeStr = "";
  4705. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4706. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4707. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4708. if (otherFeeStr.Length > 0)
  4709. {
  4710. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4711. otherFeeStr = $"({otherFeeStr})";
  4712. dic.Add("OtherFeeStr", otherFeeStr);
  4713. }
  4714. //总计
  4715. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  4716. //国际旅费
  4717. string outsideAir = string.Empty;
  4718. string allPriceAir = string.Empty;
  4719. if (_EnterExitCosts.SumJJC == 1)
  4720. {
  4721. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4722. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  4723. }
  4724. if (_EnterExitCosts.SumGWC == 1)
  4725. {
  4726. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  4727. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4728. }
  4729. if (_EnterExitCosts.SumTDC == 1)
  4730. {
  4731. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  4732. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  4733. }
  4734. dic.Add("InTravelPrice", $"({outsideAir})");
  4735. dic.Add("FinalSumPrice", $"({allPriceAir})");
  4736. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  4737. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  4738. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  4739. foreach (var key in dic.Keys)
  4740. {
  4741. builder.MoveToBookmark(key);
  4742. builder.Write(dic[key]);
  4743. }
  4744. //模板文件名
  4745. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  4746. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4747. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4748. return Ok(JsonView(true, "成功", new { Url = url }));
  4749. }
  4750. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4751. {
  4752. //获取模板
  4753. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4754. //载入模板
  4755. WorkbookDesigner designer = new WorkbookDesigner();
  4756. designer.Workbook = new Workbook(tempPath);
  4757. Dictionary<string, string> dic = new Dictionary<string, string>();
  4758. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4759. {
  4760. List<string> list = new List<string>();
  4761. try
  4762. {
  4763. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4764. foreach (var item in spilitArr)
  4765. {
  4766. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4767. var depCode = spDotandEmpty[2].Substring(0, 3);
  4768. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4769. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4770. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4771. list.Add(depName);
  4772. list.Add(arrName);
  4773. }
  4774. list = list.Distinct().ToList();
  4775. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4776. }
  4777. catch (Exception)
  4778. {
  4779. dic.Add("ReturnCode", "行程录入不正确!");
  4780. }
  4781. }
  4782. else
  4783. {
  4784. dic.Add("ReturnCode", "未录入行程!");
  4785. }
  4786. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4787. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4788. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4789. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4790. {
  4791. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4792. dic.Add("Day", sp.Days.ToString());
  4793. }
  4794. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4795. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4796. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4797. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4798. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4799. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4800. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4801. designer.SetDataSource("Name", Names);
  4802. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4803. designer.SetDataSource("Day", dic["Day"] + "天");
  4804. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4805. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4806. int startIndex = 10;
  4807. const int startIndexcopy = 10;
  4808. if (dac2.Count == dac3.Count)//国家 币种 金额
  4809. {
  4810. for (int i = 0; i < dac2.Count; i++)
  4811. {
  4812. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4813. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4814. }
  4815. }
  4816. DataTable dtdac1 = new DataTable();
  4817. List<string> place = new List<string>();
  4818. dtdac1.Columns.AddRange(new DataColumn[] {
  4819. new DataColumn(){ ColumnName = "city"},
  4820. new DataColumn(){ ColumnName = "curr"},
  4821. new DataColumn(){ ColumnName = "criterion"},
  4822. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4823. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4824. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4825. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4826. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4827. });
  4828. DataTable dtdac2 = new DataTable();
  4829. dtdac2.Columns.AddRange(new DataColumn[] {
  4830. new DataColumn(){ ColumnName = "city"},
  4831. new DataColumn(){ ColumnName = "curr"},
  4832. new DataColumn(){ ColumnName = "criterion"},
  4833. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4834. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4835. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4836. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4837. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4838. });
  4839. dtdac1.TableName = "tb1";
  4840. dtdac2.TableName = "tb2";
  4841. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4842. foreach (var item in dac1)
  4843. {
  4844. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4845. if (place.Contains(item.Place))
  4846. {
  4847. continue;
  4848. }
  4849. DataRow row = dtdac1.NewRow();
  4850. row["city"] = item.Place;
  4851. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4852. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4853. row["curr"] = currency;
  4854. row["rate"] = rate.ToString("#0.0000");
  4855. row["criterion"] = item.Cost.ToString("#0.00");
  4856. row["number"] = 1;
  4857. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4858. //row["costRMB"] = rbmPrice;
  4859. dtdac1.Rows.Add(row);
  4860. place.Add(item.Place);
  4861. }
  4862. place = new List<string>();
  4863. foreach (var item in dac2)
  4864. {
  4865. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4866. if (place.Contains(item.Place))
  4867. {
  4868. continue;
  4869. }
  4870. DataRow row = dtdac2.NewRow();
  4871. row["city"] = item.Place;
  4872. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4873. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4874. row["curr"] = currency;
  4875. row["rate"] = rate.ToString("#0.0000");
  4876. row["criterion"] = item.Cost.ToString("#0.00");
  4877. row["number"] = 1;
  4878. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4879. //row["cost"] = item.SubTotal;
  4880. //row["costRMB"] = rbmPrice;
  4881. dtdac2.Rows.Add(row);
  4882. place.Add(item.Place);
  4883. //dac2totalPrice += rbmPrice;
  4884. }
  4885. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4886. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4887. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4888. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4889. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4890. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4891. string cell4Str1 = string.Empty;
  4892. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  4893. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  4894. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  4895. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  4896. string cellStr = $" 5.其他费用(";
  4897. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4898. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4899. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4900. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4901. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4902. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4903. if (cellStr.Length > 8)
  4904. {
  4905. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4906. }
  4907. cellStr += ")";
  4908. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4909. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  4910. decimal pxFee = dac4.Sum(it => it.Cost);
  4911. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  4912. string celllastStr1 = "";
  4913. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4914. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4915. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4916. celllastStr1 += $",国际旅费 元";
  4917. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4918. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4919. designer.SetDataSource("cell4Str", cell4Str);
  4920. designer.SetDataSource("cellStr", cellStr);
  4921. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4922. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4923. designer.SetDataSource("celllastStr", celllastStr);
  4924. Workbook wb = designer.Workbook;
  4925. var sheet = wb.Worksheets[0];
  4926. //绑定datatable数据集
  4927. designer.SetDataSource(dtdac1);
  4928. designer.SetDataSource(dtdac2);
  4929. designer.Process();
  4930. var rowStart = dtdac1.Rows.Count;
  4931. while (rowStart > 0)
  4932. {
  4933. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4934. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4935. startIndex++;
  4936. rowStart--;
  4937. }
  4938. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4939. startIndex += 1; //总计行
  4940. rowStart = dtdac2.Rows.Count;
  4941. while (rowStart > 0)
  4942. {
  4943. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4944. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4945. startIndex++;
  4946. rowStart--;
  4947. }
  4948. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4949. wb.CalculateFormula(true);
  4950. //模板文件名
  4951. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4952. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4953. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4954. return Ok(JsonView(true, "成功", new { Url = url }));
  4955. }
  4956. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4957. {
  4958. //获取模板
  4959. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4960. //载入模板
  4961. Document doc = new Document(tempPath);
  4962. DocumentBuilder builder = new DocumentBuilder(doc);
  4963. Dictionary<string, string> dic = new Dictionary<string, string>();
  4964. dic.Add("GroupName", _DelegationInfo.TeamName);
  4965. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4966. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4967. string missionLeaderJob = "";//负责人job
  4968. int groupNumber = 0; //团人数
  4969. if (DeleClientList.Count > 0)
  4970. {
  4971. missionLeader = DeleClientList[0]?.Name ?? "";
  4972. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4973. }
  4974. dic.Add("MissionLeader", missionLeader); //团负责人
  4975. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4976. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4977. #region MyRegion
  4978. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4979. //{
  4980. // List<string> list = new List<string>();
  4981. // try
  4982. // {
  4983. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4984. // foreach (var item in spilitArr)
  4985. // {
  4986. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4987. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4988. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4989. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4990. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4991. // list.Add(depName);
  4992. // list.Add(arrName);
  4993. // }
  4994. // list = list.Distinct().ToList();
  4995. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4996. // }
  4997. // catch (Exception)
  4998. // {
  4999. // dic.Add("ReturnCode", "行程录入不正确!");
  5000. // }
  5001. //}
  5002. //else
  5003. //{
  5004. // dic.Add("ReturnCode", "未录入行程!");
  5005. //}
  5006. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5007. dic.Add("ReturnCode", string.Join("、", countrys));
  5008. #endregion
  5009. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5010. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5011. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5012. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5013. //{
  5014. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5015. // dic.Add("Day", sp.Days.ToString());
  5016. //}
  5017. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5018. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5019. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5020. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5021. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5022. //培训人员名单
  5023. int cultivateRowIndex = 7;
  5024. foreach (var item in DeleClientList)
  5025. {
  5026. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5027. builder.Write(item.Name);
  5028. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5029. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5030. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5031. string birthDay = "";
  5032. if (item.Birthday != null)
  5033. {
  5034. DateTime dt = Convert.ToDateTime(item.Birthday);
  5035. birthDay = $"{dt.Year}.{dt.Month}";
  5036. }
  5037. builder.Write(birthDay);
  5038. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5039. builder.Write(item.Company);
  5040. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5041. builder.Write(item.Job);
  5042. cultivateRowIndex++;
  5043. }
  5044. //删除多余行
  5045. //cultivateRowIndex -= 2;
  5046. int delRows = 10 + 7 - cultivateRowIndex;
  5047. if (delRows > 0)
  5048. {
  5049. for (int i = 0; i < delRows; i++)
  5050. {
  5051. table1.Rows.RemoveAt(cultivateRowIndex);
  5052. //cultivateRowIndex++;
  5053. }
  5054. }
  5055. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5056. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5057. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5058. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5059. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5060. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5061. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5062. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5063. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5064. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5065. //其他费用
  5066. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  5067. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5068. //其他费用合计
  5069. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5070. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5071. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5072. //公务舱合计
  5073. //国际旅费
  5074. string outsideJJ = "";
  5075. string allPriceJJ = "";
  5076. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5077. {
  5078. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5079. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5080. }
  5081. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5082. {
  5083. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5084. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5085. }
  5086. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5087. {
  5088. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5089. dic.Add("AirFeeTotal", airFeeTotalStr);
  5090. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5091. dic.Add("FeeTotal", feeTotalStr);
  5092. }
  5093. foreach (var key in dic.Keys)
  5094. {
  5095. builder.MoveToBookmark(key);
  5096. builder.Write(dic[key]);
  5097. }
  5098. //模板文件名
  5099. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5100. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5101. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5102. return Ok(JsonView(true, "成功", new { Url = url }));
  5103. }
  5104. }
  5105. else if (dto.ExportType == 2) //表格
  5106. {
  5107. //利用键值对存放数据
  5108. Dictionary<string, string> dic = new Dictionary<string, string>();
  5109. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5110. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5111. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5112. dic.Add("Day", sp.Days.ToString());
  5113. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5114. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5115. {
  5116. //获取模板
  5117. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5118. //载入模板
  5119. Document doc = new Document(tempPath);
  5120. DocumentBuilder builder = new DocumentBuilder(doc);
  5121. dic.Add("TeamName", _DelegationInfo.TeamName);
  5122. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5123. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5124. string missionLeaderName = "",
  5125. missionLeaderJob = "";
  5126. if (DeleClientList.Count > 0)
  5127. {
  5128. missionLeaderName = DeleClientList[0].Name;
  5129. missionLeaderJob = DeleClientList[0].Job;
  5130. }
  5131. dic.Add("MissionLeaderName", missionLeaderName);
  5132. dic.Add("MissionLeaderJob", missionLeaderJob);
  5133. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5134. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5135. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5136. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5137. int rowCount = 10;//总人数行
  5138. int startRowIndex = 7; //起始行
  5139. for (int i = 0; i < DeleClientList.Count; i++)
  5140. {
  5141. builder.MoveToCell(0, startRowIndex, 0, 0);
  5142. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5143. builder.MoveToCell(0, startRowIndex, 1, 0);
  5144. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5145. builder.Write(sex);//性别
  5146. builder.MoveToCell(0, startRowIndex, 2, 0);
  5147. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5148. builder.MoveToCell(0, startRowIndex, 3, 0);
  5149. builder.Write(DeleClientList[i].Company);//工作单位
  5150. builder.MoveToCell(0, startRowIndex, 4, 0);
  5151. builder.Write(DeleClientList[i].Job);//职务及级别
  5152. builder.MoveToCell(0, startRowIndex, 5, 0);
  5153. builder.Write("");//人员属性
  5154. builder.MoveToCell(0, startRowIndex, 6, 0);
  5155. builder.Write("");//上次出国时间
  5156. startRowIndex++;
  5157. }
  5158. int nullRow = rowCount - DeleClientList.Count;//空行
  5159. for (int i = 0; i < nullRow; i++)
  5160. {
  5161. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5162. }
  5163. foreach (var key in dic.Keys)
  5164. {
  5165. builder.MoveToBookmark(key);
  5166. builder.Write(dic[key]);
  5167. }
  5168. //模板文件名
  5169. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5170. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5171. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5172. return Ok(JsonView(true, "成功", new { Url = url }));
  5173. }
  5174. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5175. {
  5176. //获取模板
  5177. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5178. //载入模板
  5179. Document doc = new Document(tempPath);
  5180. DocumentBuilder builder = new DocumentBuilder(doc);
  5181. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5182. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5183. dic.Add("Names", Names);
  5184. int accommodationRows = 12, foodandotherRows = 12;
  5185. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5186. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5187. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5188. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5189. int accommodationStartIndex = 6;
  5190. decimal dac1totalPrice = 0.00M;
  5191. foreach (var dac in dac1)
  5192. {
  5193. if (dac.SubTotal == 0)
  5194. {
  5195. continue;
  5196. }
  5197. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5198. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5199. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5200. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5201. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5202. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5203. builder.Write(currency);//币种
  5204. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5205. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5206. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5207. builder.Write("");//人数
  5208. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5209. builder.Write("");//天数
  5210. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5211. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5212. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5213. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5214. builder.Write(rate.ToString("#0.0000"));//汇率
  5215. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5216. decimal rbmPrice = rate * dac.SubTotal;
  5217. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5218. accommodationStartIndex++;
  5219. dac1totalPrice += rbmPrice;
  5220. }
  5221. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5222. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5223. builder.Write("小计");
  5224. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5225. builder.Write(dac1totalPrice.ToString("#0.00"));
  5226. accommodationStartIndex++;
  5227. int nullRow = accommodationRows - dac1.Count;
  5228. //删除空行
  5229. //if (nullRow > 0)
  5230. //{
  5231. // int rowIndex = accommodationStartIndex;
  5232. // for (int i = 0; i < nullRow; i++)
  5233. // {
  5234. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5235. // row.Remove();
  5236. // rowIndex++;
  5237. // }
  5238. //}
  5239. if (dac2.Count == dac3.Count)//国家 币种 金额
  5240. {
  5241. for (int i = 0; i < dac2.Count; i++)
  5242. {
  5243. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5244. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5245. }
  5246. }
  5247. int foodandotherStartIndex = 19;//
  5248. decimal dac2totalPrice = 0.00M;
  5249. foreach (var dac in dac2)
  5250. {
  5251. if (dac.SubTotal == 0)
  5252. {
  5253. continue;
  5254. }
  5255. //foodandotherStartIndex = 12;
  5256. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5257. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5258. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5259. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5260. builder.Write(currency);//币种
  5261. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5262. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5263. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5264. builder.Write("");//人数
  5265. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5266. builder.Write("");//天数
  5267. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5268. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5269. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5270. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5271. builder.Write(rate.ToString("#0.0000"));//汇率
  5272. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5273. decimal rbmPrice = rate * dac.SubTotal;
  5274. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5275. foodandotherStartIndex++;
  5276. dac2totalPrice += rbmPrice;
  5277. }
  5278. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5279. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5280. //删除空行
  5281. //if (dac2.Count < foodandotherRows)
  5282. //{
  5283. // while (table2.Rows.Count > dac2.Count)
  5284. // {
  5285. // table2.Rows.RemoveAt(dac2.Count);
  5286. // }
  5287. //}
  5288. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5289. string otherFeeStr = "";
  5290. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5291. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5292. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5293. if (otherFeeStr.Length > 0)
  5294. {
  5295. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5296. otherFeeStr = $"({otherFeeStr})";
  5297. dic.Add("OtherFeeStr", otherFeeStr);
  5298. }
  5299. foreach (var key in dic.Keys)
  5300. {
  5301. builder.MoveToBookmark(key);
  5302. builder.Write(dic[key]);
  5303. }
  5304. //模板文件名
  5305. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5306. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5307. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5308. return Ok(JsonView(true, "成功", new { Url = url }));
  5309. }
  5310. }
  5311. else if (dto.ExportType == 3)
  5312. {
  5313. if (dto.SubTypeId == 1) //团组成员名单
  5314. {
  5315. if (DeleClientList.Count < 1)
  5316. {
  5317. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  5318. }
  5319. //获取模板
  5320. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5321. //载入模板
  5322. Document doc = new Document(tempPath);
  5323. DocumentBuilder builder = new DocumentBuilder(doc);
  5324. //获取word里所有表格
  5325. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5326. //获取所填表格的序数
  5327. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5328. var rowStart = tableOne.Rows[0]; //获取第1行
  5329. //循环赋值
  5330. for (int i = 0; i < DeleClientList.Count; i++)
  5331. {
  5332. builder.MoveToCell(0, i + 1, 0, 0);
  5333. builder.Write(DeleClientList[i].Name);
  5334. builder.MoveToCell(0, i + 1, 1, 0);
  5335. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5336. builder.Write(sex);
  5337. builder.MoveToCell(0, i + 1, 2, 0);
  5338. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5339. builder.MoveToCell(0, i + 1, 3, 0);
  5340. builder.Write(DeleClientList[i].Company);
  5341. builder.MoveToCell(0, i + 1, 4, 0);
  5342. builder.Write(DeleClientList[i].Job);
  5343. }
  5344. //删除多余行
  5345. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5346. {
  5347. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5348. }
  5349. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5350. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5351. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5352. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5353. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5354. return Ok(JsonView(true, "成功", new { Url = url }));
  5355. }
  5356. }
  5357. return Ok(JsonView(false, "操作失败!"));
  5358. }
  5359. catch (Exception ex)
  5360. {
  5361. return Ok(JsonView(false, ex.Message));
  5362. }
  5363. }
  5364. /// <summary>
  5365. /// 获取三公费用标准city
  5366. /// </summary>
  5367. /// <param name="placeData"></param>
  5368. /// <param name="nationalTravelFeeId"></param>
  5369. /// <returns></returns>
  5370. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5371. {
  5372. string _city = string.Empty;
  5373. if (placeData.Count < 1) return _city;
  5374. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5375. if (data == null) return _city;
  5376. string country = data.Country;
  5377. string city = data.City;
  5378. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5379. else _city = city;
  5380. return _city;
  5381. }
  5382. /// <summary>
  5383. /// 团组模块 - 出入境费用 - 明细表导出
  5384. /// </summary>
  5385. /// <returns></returns>
  5386. [HttpPost]
  5387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5388. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5389. {
  5390. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5391. if (data.Code != 0)
  5392. {
  5393. return Ok(JsonView(false, data.Msg));
  5394. }
  5395. return Ok(JsonView(true, data.Msg, data.Data));
  5396. }
  5397. /// <summary>
  5398. /// 团组模块 - 出入境费用 - 一键清空
  5399. /// </summary>
  5400. /// <returns></returns>
  5401. [HttpPost]
  5402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5403. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5404. {
  5405. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5406. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5407. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5408. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5409. if (_view.Code == 0)
  5410. {
  5411. return Ok(JsonView(true, "操作成功"));
  5412. }
  5413. return Ok(JsonView(false, "操作失败"));
  5414. }
  5415. /// <summary>
  5416. /// 团组模块 - 出入境费用 - 子项删除
  5417. /// </summary>
  5418. /// <returns></returns>
  5419. [HttpPost]
  5420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5421. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5422. {
  5423. try
  5424. {
  5425. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5426. if (data.Code != 0)
  5427. {
  5428. return Ok(JsonView(false, data.Msg));
  5429. }
  5430. return Ok(JsonView(true, "操作成功!", data.Data));
  5431. }
  5432. catch (Exception ex)
  5433. {
  5434. return Ok(JsonView(false, ex.Message));
  5435. }
  5436. }
  5437. /// <summary>
  5438. /// 团组模块 - 出入境国家费用标准 List
  5439. /// </summary>
  5440. /// <returns></returns>
  5441. [HttpPost]
  5442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5443. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5444. {
  5445. try
  5446. {
  5447. Stopwatch sw = new Stopwatch();
  5448. sw.Start();
  5449. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5450. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5451. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5452. Where gntf.Isdel = 0");
  5453. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5454. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5455. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  5456. //foreach (var item in nationalTravel)
  5457. //{
  5458. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  5459. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  5460. // if (otherData != null)
  5461. // {
  5462. // cityData.Remove(otherData);
  5463. // cityData.Add(otherData);
  5464. // }
  5465. // nationalTravelFeeData1.Add(new
  5466. // {
  5467. // Country = item.Country,
  5468. // CityData = cityData
  5469. // });
  5470. //}
  5471. sw.Stop();
  5472. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  5473. }
  5474. catch (Exception ex)
  5475. {
  5476. return Ok(JsonView(false, ex.Message));
  5477. throw;
  5478. }
  5479. }
  5480. /// <summary>
  5481. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  5482. /// </summary>
  5483. /// <returns></returns>
  5484. [HttpPost]
  5485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5486. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  5487. {
  5488. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  5489. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  5490. List<string> countryData = new List<string>();
  5491. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  5492. countryData = countryData.Distinct().ToList();
  5493. List<dynamic> dataSource = new List<dynamic>();
  5494. foreach (var item in countryData)
  5495. {
  5496. List<string> cityData1 = new List<string>();
  5497. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  5498. var countryData2 = new
  5499. {
  5500. CountryName = item,
  5501. CityData = cityData1
  5502. };
  5503. dataSource.Add(countryData2);
  5504. }
  5505. return Ok(JsonView(true, "查询成功!", dataSource));
  5506. }
  5507. /// <summary>
  5508. /// 团组模块 - 出入境国家费用标准 Page List
  5509. /// </summary>
  5510. /// <returns></returns>
  5511. [HttpPost]
  5512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5513. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  5514. {
  5515. int portId = dto.PortType;
  5516. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5517. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  5518. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  5519. string whereSql = string.Empty;
  5520. if (!string.IsNullOrEmpty(dto.Country))
  5521. {
  5522. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  5523. }
  5524. if (!string.IsNullOrEmpty(dto.City))
  5525. {
  5526. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  5527. }
  5528. string pageSql = string.Format(@"Select * From (
  5529. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  5530. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  5531. From Grp_NationalTravelFee gntf
  5532. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5533. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5534. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  5535. RefAsync<int> total = 0;
  5536. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  5537. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  5538. }
  5539. /// <summary>
  5540. /// 团组模块 - 出入境国家费用标准 根据城市查询
  5541. /// </summary>
  5542. /// <returns></returns>
  5543. [HttpPost]
  5544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5545. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  5546. {
  5547. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  5548. int portId = dto.PortType;
  5549. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5550. string whereSql = string.Empty;
  5551. if (!string.IsNullOrEmpty(dto.Country))
  5552. {
  5553. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  5554. }
  5555. if (!string.IsNullOrEmpty(dto.City))
  5556. {
  5557. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  5558. }
  5559. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  5560. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  5561. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  5562. From Grp_NationalTravelFee gntf
  5563. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5564. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5565. Where gntf.Isdel = 0 {0} ", whereSql);
  5566. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  5567. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  5568. }
  5569. /// <summary>
  5570. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  5571. /// </summary>
  5572. /// <returns></returns>
  5573. [HttpPost]
  5574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5575. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  5576. {
  5577. try
  5578. {
  5579. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  5580. if (data.Code != 0)
  5581. {
  5582. return Ok(JsonView(false, data.Msg));
  5583. }
  5584. return Ok(JsonView(true, "操作成功!", data.Data));
  5585. }
  5586. catch (Exception ex)
  5587. {
  5588. return Ok(JsonView(false, ex.Message));
  5589. }
  5590. }
  5591. /// <summary>
  5592. /// 团组模块 - 出入境国家费用标准 - Del
  5593. /// </summary>
  5594. /// <returns></returns>
  5595. [HttpPost]
  5596. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5597. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  5598. {
  5599. try
  5600. {
  5601. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  5602. {
  5603. Id = dto.Id,
  5604. DeleteUserId = dto.DeleteUserId,
  5605. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5606. IsDel = 1
  5607. };
  5608. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  5609. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  5610. .WhereColumns(it => new { it.Id })
  5611. .ExecuteCommandAsync();
  5612. if (delStatus <= 0)
  5613. {
  5614. return Ok(JsonView(false, "删除失败!"));
  5615. }
  5616. return Ok(JsonView(true, "操作成功!"));
  5617. }
  5618. catch (Exception ex)
  5619. {
  5620. return Ok(JsonView(false, ex.Message));
  5621. }
  5622. }
  5623. #endregion
  5624. #region 签证费用录入
  5625. /// <summary>
  5626. /// 根据diid查询签证费用列表
  5627. /// </summary>
  5628. /// <param name="dto"></param>
  5629. /// <returns></returns>
  5630. [HttpPost]
  5631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5632. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  5633. {
  5634. try
  5635. {
  5636. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  5637. if (groupData.Code != 0)
  5638. {
  5639. return Ok(JsonView(false, groupData.Msg));
  5640. }
  5641. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5642. }
  5643. catch (Exception ex)
  5644. {
  5645. return Ok(JsonView(false, ex.Message));
  5646. }
  5647. }
  5648. /// <summary>
  5649. /// 根据签证费用Id查询单条数据及c表数据
  5650. /// </summary>
  5651. /// <param name="dto"></param>
  5652. /// <returns></returns>
  5653. [HttpPost]
  5654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5655. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  5656. {
  5657. try
  5658. {
  5659. Result groupData = await _visaPriceRep.PostVisaById(dto);
  5660. if (groupData.Code != 0)
  5661. {
  5662. return Ok(JsonView(false, groupData.Msg));
  5663. }
  5664. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5665. }
  5666. catch (Exception ex)
  5667. {
  5668. return Ok(JsonView(false, ex.Message));
  5669. }
  5670. }
  5671. /// <summary>
  5672. /// 签证费用删除
  5673. /// </summary>
  5674. /// <param name="dto"></param>
  5675. /// <returns></returns>
  5676. [HttpPost]
  5677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5678. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  5679. {
  5680. _sqlSugar.BeginTran();
  5681. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  5682. if (!res)
  5683. {
  5684. _sqlSugar.RollbackTran();
  5685. return Ok(JsonView(false, "删除失败"));
  5686. }
  5687. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5688. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  5689. .SetColumns(a => new Grp_CreditCardPayment()
  5690. {
  5691. IsDel = 1,
  5692. DeleteUserId = dto.DeleteUserId,
  5693. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5694. })
  5695. .ExecuteCommand();
  5696. if (resSub < 1)
  5697. {
  5698. _sqlSugar.RollbackTran();
  5699. return Ok(JsonView(false, "删除失败"));
  5700. }
  5701. _sqlSugar.CommitTran();
  5702. return Ok(JsonView(true, "删除成功!"));
  5703. }
  5704. /// <summary>
  5705. /// 签证费用录入下拉框初始化
  5706. /// </summary>
  5707. /// <returns></returns>
  5708. [HttpPost]
  5709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5710. public async Task<IActionResult> VisaPriceAddSelect()
  5711. {
  5712. //支付方式
  5713. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  5714. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  5715. //币种
  5716. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  5717. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  5718. //乘客类型
  5719. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  5720. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  5721. //卡类型
  5722. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  5723. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  5724. var data = new
  5725. {
  5726. Payment = _Payment,
  5727. CurrencyList = _CurrencyList,
  5728. PassengerType = _PassengerType,
  5729. BankCard = _BankCard
  5730. };
  5731. return Ok(JsonView(true, "查询成功!", data));
  5732. }
  5733. /// <summary>
  5734. /// 签证费用录入操作(Status:1.新增,2.修改)
  5735. /// </summary>
  5736. /// <param name="dto"></param>
  5737. /// <returns></returns>
  5738. [HttpPost]
  5739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5740. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  5741. {
  5742. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  5743. if (groupData.Code != 0)
  5744. {
  5745. return Ok(JsonView(false, groupData.Msg));
  5746. }
  5747. #region 应用推送
  5748. try
  5749. {
  5750. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5751. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5752. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5753. }
  5754. catch (Exception ex)
  5755. {
  5756. }
  5757. #endregion
  5758. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5759. }
  5760. #endregion
  5761. #region 签证提成录入
  5762. /// <summary>
  5763. /// 签证提成录入
  5764. /// 基础数据
  5765. /// </summary>
  5766. /// <param name="_dto"></param>
  5767. /// <returns></returns>
  5768. [HttpGet]
  5769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5770. public async Task<IActionResult> VisaCommissionInit()
  5771. {
  5772. return Ok(await _visaCommissionRep.Init());
  5773. }
  5774. /// <summary>
  5775. /// 签证提成录入
  5776. /// Item
  5777. /// </summary>
  5778. /// <param name="_dto"></param>
  5779. /// <returns></returns>
  5780. [HttpPost]
  5781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5782. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  5783. {
  5784. var validator = new VisaCommissionItemDtoValidator();
  5785. var validatorRes = await validator.ValidateAsync(_dto);
  5786. if (!validatorRes.IsValid)
  5787. {
  5788. StringBuilder sb = new StringBuilder();
  5789. foreach (var item in validatorRes.Errors)
  5790. {
  5791. sb.AppendLine(item.ErrorMessage);
  5792. }
  5793. return Ok(JsonView(false, sb.ToString()));
  5794. }
  5795. return Ok(await _visaCommissionRep.Item(_dto));
  5796. }
  5797. /// <summary>
  5798. /// 签证提成录入
  5799. /// Save
  5800. /// </summary>
  5801. /// <param name="_dto"></param>
  5802. /// <returns></returns>
  5803. [HttpPost]
  5804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5805. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  5806. {
  5807. //参数验证
  5808. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  5809. foreach (var item in _dto.Items)
  5810. {
  5811. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  5812. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  5813. if (string.IsNullOrEmpty( item.Country) ) return Ok(JsonView(false, "国家为空!"));
  5814. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  5815. }
  5816. return Ok(await _visaCommissionRep.Save(_dto));
  5817. }
  5818. /// <summary>
  5819. /// 签证提成录入
  5820. /// Create
  5821. /// </summary>
  5822. /// <param name="_dto"></param>
  5823. /// <returns></returns>
  5824. [HttpPost]
  5825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5826. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  5827. {
  5828. var validator = new VisaCommissionCreateDtoValidator();
  5829. var validatorRes = await validator.ValidateAsync(_dto);
  5830. if (!validatorRes.IsValid)
  5831. {
  5832. StringBuilder sb = new StringBuilder();
  5833. foreach (var item in validatorRes.Errors)
  5834. {
  5835. sb.AppendLine(item.ErrorMessage);
  5836. }
  5837. return Ok(JsonView(false, sb.ToString()));
  5838. }
  5839. return Ok(await _visaCommissionRep.Create(_dto));
  5840. }
  5841. /// <summary>
  5842. /// 签证提成录入
  5843. /// Put(编辑)
  5844. /// </summary>
  5845. /// <param name="id"></param>
  5846. /// <param name="_dto"></param>
  5847. /// <returns></returns>
  5848. [HttpPut]
  5849. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5850. public async Task<IActionResult> VisaCommissionEdit(int id,VisaCommissionCreateDto _dto)
  5851. {
  5852. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  5853. var validator = new VisaCommissionCreateDtoValidator();
  5854. var validatorRes = await validator.ValidateAsync(_dto);
  5855. if (!validatorRes.IsValid)
  5856. {
  5857. StringBuilder sb = new StringBuilder();
  5858. foreach (var item in validatorRes.Errors)
  5859. {
  5860. sb.AppendLine(item.ErrorMessage);
  5861. }
  5862. return Ok(JsonView(false, sb.ToString()));
  5863. }
  5864. return Ok(await _visaCommissionRep.Edit(id,_dto));
  5865. }
  5866. /// <summary>
  5867. /// 签证提成录入
  5868. /// Del
  5869. /// </summary>
  5870. /// <param name="id"></param>
  5871. /// <param name="currUserId"></param>
  5872. /// <returns></returns>
  5873. [HttpPost]
  5874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5875. public async Task<IActionResult> VisaCommissionDel(int id,int currUserId)
  5876. {
  5877. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  5878. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  5879. return Ok(await _visaCommissionRep.Del(id, currUserId));
  5880. }
  5881. #endregion
  5882. #region op费用录入
  5883. /// <summary>
  5884. /// 根据diid查询op费用列表
  5885. /// </summary>
  5886. /// <param name="dto"></param>
  5887. /// <returns></returns>
  5888. [HttpPost]
  5889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5890. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  5891. {
  5892. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  5893. if (groupData.Code != 0)
  5894. {
  5895. return Ok(JsonView(false, groupData.Msg));
  5896. }
  5897. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5898. }
  5899. /// <summary>
  5900. /// 根据op费用Id查询单条数据及c表数据
  5901. /// </summary>
  5902. /// <param name="dto"></param>
  5903. /// <returns></returns>
  5904. [HttpPost]
  5905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5906. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  5907. {
  5908. try
  5909. {
  5910. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  5911. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  5912. var data = new
  5913. {
  5914. CarTouristGuideGround = _groupData,
  5915. CreditCardPayment = _creditCardPayment
  5916. };
  5917. return Ok(JsonView(true, "查询成功!", data));
  5918. }
  5919. catch (Exception ex)
  5920. {
  5921. return Ok(JsonView(false, "程序错误!"));
  5922. }
  5923. }
  5924. /// <summary>
  5925. /// op费用删除
  5926. /// </summary>
  5927. /// <param name="dto"></param>
  5928. /// <returns></returns>
  5929. [HttpPost]
  5930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5931. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  5932. {
  5933. try
  5934. {
  5935. _sqlSugar.BeginTran();
  5936. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5937. if (!res)
  5938. {
  5939. return Ok(JsonView(false, "删除失败"));
  5940. }
  5941. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  5942. {
  5943. IsDel = 1,
  5944. DeleteUserId = dto.DeleteUserId,
  5945. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5946. }).ExecuteCommandAsync();
  5947. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  5948. {
  5949. IsDel = 1,
  5950. DeleteUserId = dto.DeleteUserId,
  5951. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5952. }).ExecuteCommandAsync();
  5953. #region 删除超支相关数据
  5954. //删除导入的超支数据
  5955. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  5956. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  5957. {
  5958. IsDel = 1,
  5959. DeleteUserId = dto.DeleteUserId,
  5960. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5961. }).ExecuteCommand();
  5962. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  5963. {
  5964. IsDel = 1,
  5965. DeleteUserId = dto.DeleteUserId,
  5966. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5967. }).ExecuteCommand() ;
  5968. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x=>x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  5969. {
  5970. IsDel = 1,
  5971. DeleteUserId = dto.DeleteUserId,
  5972. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5973. }).ExecuteCommand();
  5974. #endregion
  5975. _sqlSugar.CommitTran();
  5976. return Ok(JsonView(true, "删除成功!"));
  5977. }
  5978. catch (Exception ex)
  5979. {
  5980. _sqlSugar.RollbackTran();
  5981. return Ok(JsonView(false, "程序错误!" + ex.Message));
  5982. }
  5983. }
  5984. /// <summary>
  5985. /// op费用录入操作(Status:1.新增,2.修改)
  5986. /// </summary>
  5987. /// <param name="dto"></param>
  5988. /// <returns></returns>
  5989. [HttpPost]
  5990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5991. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5992. {
  5993. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5994. if (groupData.Code != 0)
  5995. {
  5996. return Ok(JsonView(false, groupData.Msg));
  5997. }
  5998. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5999. }
  6000. /// <summary>
  6001. /// 填写费用详细页面初始化绑定
  6002. /// </summary>
  6003. /// <param name="dto"></param>
  6004. /// <returns></returns>
  6005. [HttpPost]
  6006. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6007. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  6008. {
  6009. try
  6010. {
  6011. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  6012. if (groupData.Code != 0)
  6013. {
  6014. return Ok(JsonView(false, groupData.Msg));
  6015. }
  6016. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6017. }
  6018. catch (Exception ex)
  6019. {
  6020. return Ok(JsonView(false, ex.Message));
  6021. }
  6022. }
  6023. /// <summary>
  6024. /// 根据op费用Id查询详细数据
  6025. /// </summary>
  6026. /// <param name="dto"></param>
  6027. /// <returns></returns>
  6028. [HttpPost]
  6029. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6030. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  6031. {
  6032. try
  6033. {
  6034. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  6035. if (groupData.Code != 0)
  6036. {
  6037. return Ok(JsonView(false, groupData.Msg));
  6038. }
  6039. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6040. }
  6041. catch (Exception ex)
  6042. {
  6043. return Ok(JsonView(false, ex.Message));
  6044. }
  6045. }
  6046. /// <summary>
  6047. /// OP费用录入填写详情
  6048. /// </summary>
  6049. /// <param name="dto"></param>
  6050. /// <returns></returns>
  6051. [HttpPost]
  6052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6053. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  6054. {
  6055. try
  6056. {
  6057. #region 参数校验
  6058. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  6059. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  6060. if (di == null) return Ok(JsonView(false, "团组错误!"));
  6061. #endregion
  6062. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  6063. if (groupData.Code != 0)
  6064. {
  6065. return Ok(JsonView(false, groupData.Msg));
  6066. }
  6067. //自动审核
  6068. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  6069. #region 应用推送
  6070. try
  6071. {
  6072. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6073. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6074. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6075. }
  6076. catch (Exception ex)
  6077. {
  6078. }
  6079. #endregion
  6080. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6081. }
  6082. catch (Exception ex)
  6083. {
  6084. return Ok(JsonView(false, ex.Message));
  6085. }
  6086. }
  6087. /// <summary>
  6088. /// 获取三公详细所有城市
  6089. /// </summary>
  6090. /// <returns></returns>
  6091. [HttpGet]
  6092. public IActionResult OpCarCityResult()
  6093. {
  6094. var jw = JsonView(false);
  6095. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  6096. {
  6097. x.Id,
  6098. x.Country,
  6099. x.City,
  6100. }).ToList();
  6101. if (data.Count > 0)
  6102. {
  6103. jw = JsonView(true, "获取成功!", data);
  6104. }
  6105. else
  6106. {
  6107. jw.Msg = "城市数据为空!";
  6108. jw.Data = new string[0];
  6109. }
  6110. return Ok(jw);
  6111. }
  6112. /// <summary>
  6113. /// 导出地接费用明细
  6114. /// </summary>
  6115. /// <param name="dto"></param>
  6116. /// <returns></returns>
  6117. [HttpPost]
  6118. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  6119. {
  6120. var jw = JsonView(false);
  6121. if (dto.Diid < 1)
  6122. {
  6123. jw.Msg = "请输入正确的diid!";
  6124. return Ok(jw);
  6125. }
  6126. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6127. if (group == null)
  6128. {
  6129. jw.Msg = "未找到团组信息!";
  6130. return Ok(jw);
  6131. }
  6132. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  6133. if (localGuideArr.Count == 0)
  6134. {
  6135. jw.Msg = "该团组暂无地接信息!";
  6136. return Ok(jw);
  6137. }
  6138. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  6139. var overspendSoure = new Dictionary<int, int>
  6140. {
  6141. { 91, 982 }, //车
  6142. { 92 , 1059} ,//导游
  6143. { 994 , 1073}, //翻译
  6144. { 988 , 1074 }, //早餐
  6145. { 93 , 1075 }, //午餐
  6146. { 989 , 1076 }, //晚餐
  6147. };
  6148. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  6149. foreach (var groupArr in localGroup)
  6150. {
  6151. var keyValue = groupArr.Key;
  6152. if (int.TryParse(keyValue, out int cityid))
  6153. {
  6154. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  6155. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  6156. }
  6157. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  6158. foreach (var item in groupArr)
  6159. {
  6160. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  6161. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  6162. new Grp_CarTouristGuideGroundReservationsContentExtend
  6163. {
  6164. Count = a.Count,
  6165. CreateTime = a.CreateTime,
  6166. CreateUserId = a.CreateUserId,
  6167. CTGGRId = a.CTGGRId,
  6168. Currency = a.Currency,
  6169. DatePrice = a.DatePrice,
  6170. DeleteTime = a.DeleteTime,
  6171. DeleteUserId = a.DeleteUserId,
  6172. DiId = a.DiId,
  6173. Id = a.Id,
  6174. IsDel = a.IsDel,
  6175. Price = a.Price,
  6176. PriceContent = a.PriceContent,
  6177. Remark = a.Remark,
  6178. SId = a.SId,
  6179. SidName = b.Name,
  6180. Units = a.Units,
  6181. }
  6182. ).ToList();
  6183. if (content.Count > 0)
  6184. {
  6185. contentArr.Add(content);
  6186. }
  6187. }
  6188. //open excel
  6189. //set excel
  6190. //save excel
  6191. try
  6192. {
  6193. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  6194. IWorkbook workbook;
  6195. if (Path.GetExtension(filePath).ToLower() == ".xls")
  6196. {
  6197. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6198. }
  6199. else
  6200. {
  6201. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6202. }
  6203. ISheet sheet = workbook.GetSheetAt(0);
  6204. var rowStartIndex = 2;
  6205. var clounmCount = 10;
  6206. var initStyleRow = sheet.GetRow(2);
  6207. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  6208. //var overspendArrDetail =
  6209. var existsId = new List<CarCompare>();
  6210. var lastElem = arr.Last();
  6211. var thisSid = -1;
  6212. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  6213. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  6214. {
  6215. Name = "未知币种!",
  6216. Remark = "未知币种!",
  6217. };
  6218. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  6219. Action cloneRowFn = () =>
  6220. {
  6221. rowStartIndex++;
  6222. var cloneRow = sheet.CreateRow(rowStartIndex);
  6223. // 复制样式
  6224. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  6225. {
  6226. ICell sourceCell = initStyleRow.GetCell(i);
  6227. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  6228. // 确保单元格存在样式
  6229. if (sourceCell.CellStyle != null)
  6230. {
  6231. targetCell.CellStyle = sourceCell.CellStyle;
  6232. }
  6233. }
  6234. };
  6235. var mergeRow = () =>
  6236. {
  6237. for (int i = 2; i < sheet.LastRowNum; i++)
  6238. {
  6239. var row = sheet.GetRow(i);
  6240. var cellFirst = row.GetCell(0);
  6241. var thisIndex = i + 1;
  6242. while (thisIndex < sheet.LastRowNum)
  6243. {
  6244. var nextRow = sheet.GetRow(thisIndex);
  6245. var nextCellFirst = nextRow.GetCell(0);
  6246. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  6247. {
  6248. thisIndex++;
  6249. }
  6250. else
  6251. {
  6252. break;
  6253. }
  6254. }
  6255. thisIndex--;
  6256. if (thisIndex != i)
  6257. {
  6258. //合并row
  6259. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6260. i, // 起始行索引(0-based)
  6261. thisIndex, // 结束行索引(0-based)
  6262. 0, // 起始列索引(0-based)
  6263. 0 // 结束列索引(0-based)
  6264. );
  6265. sheet.AddMergedRegion(cellRangeAddress);
  6266. i = thisIndex;
  6267. }
  6268. }
  6269. };
  6270. var chaoshiNumber = 0;
  6271. var totalNumber = 0.00M;
  6272. string lastStr = "";
  6273. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  6274. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  6275. {
  6276. b.IsAuditGM,
  6277. x.Id,
  6278. x.Area,
  6279. b.PayPercentage,
  6280. b.PayMoney,
  6281. }).ToList();
  6282. string yesPayment = "", noPayment = "";
  6283. foreach (var item in queryCarArrByCityAndDiid)
  6284. {
  6285. if (item.IsAuditGM == 1)
  6286. {
  6287. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6288. }
  6289. else
  6290. {
  6291. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6292. }
  6293. }
  6294. lastStr = yesPayment + noPayment;
  6295. foreach (var item in arr)
  6296. {
  6297. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  6298. {
  6299. if (thisSid != item.SId)
  6300. {
  6301. if (thisSid == -1)
  6302. {
  6303. thisSid = item.SId;
  6304. }
  6305. else
  6306. {
  6307. //合并小计行
  6308. //创建合并区域的实例
  6309. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6310. rowStartIndex, // 起始行索引(0-based)
  6311. rowStartIndex, // 结束行索引(0-based)
  6312. 0, // 起始列索引(0-based)
  6313. 3 // 结束列索引(0-based)
  6314. );
  6315. sheet.AddMergedRegion(cellRangeAddress);
  6316. var CellStyle = workbook.CreateCellStyle();
  6317. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6318. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6319. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6320. for (int i = 0; i <= clounmCount; i++)
  6321. {
  6322. if (i > 6)
  6323. {
  6324. var CellStyle1 = workbook.CreateCellStyle();
  6325. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6326. IFont Font = workbook.CreateFont(); // 创建字体
  6327. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6328. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6329. CellStyle1.SetFont(Font);
  6330. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6331. }
  6332. else
  6333. {
  6334. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6335. }
  6336. }
  6337. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6338. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6339. //超时合计
  6340. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6341. //超时数
  6342. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6343. //超时合计费用
  6344. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6345. thisSid = item.SId;
  6346. cloneRowFn();
  6347. chaoshiNumber = 0;
  6348. totalNumber = 0;
  6349. }
  6350. }
  6351. IRow row = sheet.GetRow(rowStartIndex);
  6352. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6353. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6354. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6355. if (isOpenOverspendSoure)
  6356. {
  6357. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6358. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6359. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6360. }
  6361. for (int i = 0; i <= clounmCount; i++)
  6362. {
  6363. var cell = row.GetCell(i);
  6364. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6365. if (cell == null)
  6366. {
  6367. cell = row.CreateCell(i);
  6368. }
  6369. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6370. fontRed.CloneStyleFrom(cell.CellStyle);
  6371. IFont Font = workbook.CreateFont(); // 创建字体
  6372. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6373. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6374. fontRed.SetFont(Font);
  6375. byte[] rgb = new byte[3] { 255, 242, 204 };
  6376. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6377. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6378. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6379. if (workbook is XSSFWorkbook)
  6380. {
  6381. BackgroundColor255_242_204.FillForegroundColor = 0;
  6382. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6383. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6384. }
  6385. else
  6386. {
  6387. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6388. }
  6389. if (i == 1 || i > 6)
  6390. {
  6391. if (i > 6)
  6392. {
  6393. fontRed.FillForegroundColor = 0;
  6394. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6395. fontRed.FillPattern = FillPattern.SolidForeground;
  6396. }
  6397. cell.CellStyle = fontRed;
  6398. }
  6399. if (i > 2 && i < 7)
  6400. {
  6401. cell.CellStyle = BackgroundColor255_242_204;
  6402. }
  6403. cell.SetCellValue(setCellValue); //写入单元格
  6404. }
  6405. if (overspendSoure.ContainsKey(thisSid))
  6406. {
  6407. var overspendId = overspendSoure[thisSid];
  6408. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6409. }
  6410. cloneRowFn();
  6411. existsId.Add(new CarCompare
  6412. {
  6413. DataPrice = item.DatePrice.ObjToDate(),
  6414. Sid = item.SId
  6415. });
  6416. }
  6417. if (item.Equals(lastElem))
  6418. {
  6419. //合并小计行
  6420. //创建合并区域的实例
  6421. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6422. rowStartIndex, // 起始行索引(0-based)
  6423. rowStartIndex, // 结束行索引(0-based)
  6424. 0, // 起始列索引(0-based)
  6425. 3 // 结束列索引(0-based)
  6426. );
  6427. sheet.AddMergedRegion(cellRangeAddress);
  6428. var CellStyle = workbook.CreateCellStyle();
  6429. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6430. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6431. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6432. for (int i = 0; i <= clounmCount; i++)
  6433. {
  6434. if (i > 6)
  6435. {
  6436. var CellStyle1 = workbook.CreateCellStyle();
  6437. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6438. IFont Font = workbook.CreateFont(); // 创建字体
  6439. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6440. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6441. CellStyle1.SetFont(Font);
  6442. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6443. }
  6444. else
  6445. {
  6446. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6447. }
  6448. }
  6449. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6450. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6451. //超时合计
  6452. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6453. //超时数
  6454. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6455. //超时合计费用
  6456. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6457. cloneRowFn();
  6458. // 创建合并区域的实例
  6459. cellRangeAddress = new CellRangeAddress(
  6460. rowStartIndex, // 起始行索引(0-based)
  6461. rowStartIndex, // 结束行索引(0-based)
  6462. 0, // 起始列索引(0-based)
  6463. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  6464. );
  6465. // 添加合并区域
  6466. sheet.AddMergedRegion(cellRangeAddress);
  6467. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  6468. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  6469. }
  6470. }
  6471. mergeRow();
  6472. // 保存修改后的Excel文件到新文件
  6473. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  6474. // new FileStream(newFilePath, FileMode.CreateNew)
  6475. using (var stream = new MemoryStream())
  6476. {
  6477. workbook.Write(stream, true);
  6478. stream.Flush();
  6479. stream.Seek(0, SeekOrigin.Begin);
  6480. MemoryStream memoryStream = new MemoryStream();
  6481. stream.CopyTo(memoryStream);
  6482. memoryStream.Seek(0, SeekOrigin.Begin);
  6483. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  6484. }
  6485. workbook.Close();
  6486. workbook.Dispose();
  6487. }
  6488. catch (Exception ex)
  6489. {
  6490. jw.Msg = "出现异常!" + ex.Message;
  6491. return Ok(jw);
  6492. }
  6493. }
  6494. if (Zips.Count > 0)
  6495. {
  6496. IOOperatorHelper io = new IOOperatorHelper();
  6497. var byts = io.ConvertZipStream(Zips);
  6498. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  6499. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  6500. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  6501. }
  6502. else
  6503. {
  6504. jw.Msg = "暂无生成文件!";
  6505. }
  6506. return Ok(jw);
  6507. }
  6508. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  6509. {
  6510. string outStr = string.Empty;
  6511. switch (i)
  6512. {
  6513. case 0:
  6514. outStr = arr[0].SidName;
  6515. break;
  6516. case 1:
  6517. outStr = arr[0].DataPriceStr;
  6518. break;
  6519. case 2:
  6520. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  6521. break;
  6522. case 4:
  6523. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  6524. break;
  6525. case 7:
  6526. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6527. {
  6528. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  6529. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  6530. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  6531. }
  6532. break;
  6533. case 8:
  6534. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6535. {
  6536. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  6537. }
  6538. break;
  6539. case 9:
  6540. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6541. {
  6542. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  6543. }
  6544. break;
  6545. case 10:
  6546. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6547. {
  6548. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  6549. }
  6550. break;
  6551. }
  6552. return outStr;
  6553. }
  6554. #region OP行程单
  6555. /// <summary>
  6556. /// OP行程单初始化
  6557. /// </summary>
  6558. /// <param name="dto"></param>
  6559. /// <returns></returns>
  6560. [HttpPost]
  6561. public IActionResult InitOpTravel(InitOpTravelDto dto)
  6562. {
  6563. var jw = JsonView(false);
  6564. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  6565. var group = groupList.First();
  6566. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  6567. if (group == null)
  6568. {
  6569. jw.Msg = "暂无团组!";
  6570. return Ok(jw);
  6571. }
  6572. group = groupList.Find(x => x.Id == diid);
  6573. if (group == null)
  6574. {
  6575. jw.Msg = "请输入正确的团组ID!";
  6576. return Ok(jw);
  6577. }
  6578. string city = string.Empty;
  6579. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  6580. if (blackCode.Count > 0)
  6581. {
  6582. var black = blackCode.First();
  6583. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  6584. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  6585. if (blackSp.Length > 0)
  6586. {
  6587. try
  6588. {
  6589. var cityArrCode = new List<string>(20);
  6590. foreach (var item in blackSp)
  6591. {
  6592. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  6593. var IndexSelect = itemSp[2];
  6594. var cityArrCodeLength = cityArrCode.Count - 1;
  6595. var startCity = IndexSelect.Substring(0, 3);
  6596. if (cityArrCodeLength > 0)
  6597. {
  6598. var arrEndCity = cityArrCode[cityArrCodeLength];
  6599. if (arrEndCity != startCity)
  6600. {
  6601. cityArrCode.Add(startCity.ToUpper());
  6602. }
  6603. }
  6604. else
  6605. {
  6606. cityArrCode.Add(startCity.ToUpper());
  6607. }
  6608. var endCity = IndexSelect.Substring(3, 3);
  6609. cityArrCode.Add(endCity.ToUpper());
  6610. }
  6611. var cityThree = string.Empty;
  6612. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  6613. cityThree = cityThree.TrimEnd(',');
  6614. if (string.IsNullOrWhiteSpace(cityThree))
  6615. {
  6616. throw new
  6617. Exception("error");
  6618. }
  6619. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  6620. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  6621. foreach (var item in cityArrCode)
  6622. {
  6623. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  6624. if (find != null)
  6625. {
  6626. city += find.City + "/";
  6627. }
  6628. else
  6629. {
  6630. city += item + "三字码未收入/";
  6631. }
  6632. }
  6633. city = city.TrimEnd('/');
  6634. }
  6635. catch (Exception e)
  6636. {
  6637. city = "黑屏代码格式不正确!";
  6638. }
  6639. }
  6640. }
  6641. else
  6642. {
  6643. city = "未录入黑屏代码";
  6644. }
  6645. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  6646. {
  6647. Date = x.Date,
  6648. Days = x.Days,
  6649. Diffgroup = x.Diffgroup,
  6650. Diid = x.Diid,
  6651. Traffic_First = x.Traffic_First,
  6652. Traffic_Second = x.Traffic_Second,
  6653. Trip = x.Trip,
  6654. WeekDay = x.WeekDay,
  6655. Id = x.Id
  6656. }).ToList();
  6657. jw.Data = new
  6658. {
  6659. groupList = groupList.Select(x => new
  6660. {
  6661. x.Id,
  6662. x.TeamName,
  6663. x.TourCode
  6664. }).ToList(),
  6665. groupInfo = new
  6666. {
  6667. group.VisitDays,
  6668. group.TourCode,
  6669. group.VisitPNumber,
  6670. group.TeamName,
  6671. city
  6672. },
  6673. OpTravelList
  6674. };
  6675. jw.Code = 200;
  6676. jw.Msg = "操作成功!";
  6677. return Ok(jw);
  6678. }
  6679. /// <summary>
  6680. /// 删除团组行程单
  6681. /// </summary>
  6682. /// <returns></returns>
  6683. [HttpPost]
  6684. public IActionResult DelTravel(DelOpTravelDto dto)
  6685. {
  6686. var jw = JsonView(false);
  6687. if (dto.UserId <= 0 || dto.Diid <= 0)
  6688. {
  6689. jw.Msg = "请输入正确的参数!";
  6690. return Ok(jw);
  6691. }
  6692. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  6693. .SetColumns(x => new Grp_TravelList
  6694. {
  6695. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6696. DeleteUserId = dto.UserId,
  6697. IsDel = 1,
  6698. }).ExecuteCommand();
  6699. jw = JsonView(true);
  6700. return Ok(jw);
  6701. }
  6702. /// <summary>
  6703. /// 行程单保存
  6704. /// </summary>
  6705. /// <returns></returns>
  6706. [HttpPost]
  6707. public IActionResult TravelSave(TravelSaveDto dto)
  6708. {
  6709. var jw = JsonView(false);
  6710. if (dto.Arr.Count > 0)
  6711. {
  6712. try
  6713. {
  6714. _sqlSugar.BeginTran();
  6715. foreach (var item in dto.Arr)
  6716. {
  6717. if (item.Id == 0)
  6718. {
  6719. throw new Exception("请传入正确的Id");
  6720. }
  6721. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  6722. .SetColumns(x => new Grp_TravelList
  6723. {
  6724. Trip = item.Trip
  6725. }).ExecuteCommand();
  6726. }
  6727. _sqlSugar.CommitTran();
  6728. jw = JsonView(true);
  6729. }
  6730. catch (Exception ex)
  6731. {
  6732. _sqlSugar.RollbackTran();
  6733. jw.Msg = "程序异常!" + ex.Message;
  6734. }
  6735. }
  6736. else
  6737. {
  6738. jw.Msg = "请传入正确的参数!";
  6739. }
  6740. return Ok(jw);
  6741. }
  6742. /// <summary>
  6743. /// 导出行程单
  6744. /// </summary>
  6745. /// <param name="dto"></param>
  6746. /// <returns></returns>
  6747. [HttpPost]
  6748. public IActionResult ExportTravel(ExportTravelDto dto)
  6749. {
  6750. var jw = JsonView(false);
  6751. jw.Data = "";
  6752. int diid = 0;
  6753. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  6754. if (Find == null)
  6755. {
  6756. jw.Msg = "请选择正确的团组!";
  6757. return Ok(jw);
  6758. }
  6759. else
  6760. {
  6761. diid = Find.Id;
  6762. }
  6763. //数据源
  6764. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  6765. DataTable dtBlack = null;
  6766. try
  6767. {
  6768. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  6769. }
  6770. catch (Exception)
  6771. {
  6772. jw.Msg = "机票黑屏代码有误!";
  6773. return Ok(jw);
  6774. }
  6775. string CityStr = string.Empty;
  6776. if (dtBlack.Rows.Count == 0)
  6777. {
  6778. jw.Msg = "机票黑屏代码有误!";
  6779. return Ok(jw);
  6780. }
  6781. else
  6782. {
  6783. foreach (DataRow row in dtBlack.Rows)
  6784. {
  6785. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  6786. {
  6787. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  6788. return Ok(jw);
  6789. }
  6790. }
  6791. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  6792. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  6793. }
  6794. //创建数据源Table
  6795. DataTable dtSource = new DataTable();
  6796. dtSource.Columns.Add("Days", typeof(string));
  6797. dtSource.Columns.Add("Date", typeof(string));
  6798. dtSource.Columns.Add("Week", typeof(string));
  6799. dtSource.Columns.Add("Traffic", typeof(string));
  6800. dtSource.Columns.Add("Trip", typeof(string));
  6801. //获取数据,放到datatable
  6802. foreach (var item in _travelList)
  6803. {
  6804. DataRow dr = dtSource.NewRow();
  6805. dr["Days"] = item.Days;
  6806. dr["Date"] = item.Date;
  6807. dr["Week"] = item.WeekDay;
  6808. dr["Traffic"] = item.Traffic_First
  6809. + "\r\n"
  6810. + item.Traffic_Second;
  6811. dr["Trip"] = item.Trip;
  6812. dtSource.Rows.Add(dr);
  6813. }
  6814. Dictionary<string, string> dic = new Dictionary<string, string>();
  6815. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  6816. dic.Add("City", CityStr);
  6817. dic.Add("Days", Find.VisitDays.ToString());
  6818. dic.Add("DeleCode", Find.TourCode);
  6819. dic.Add("Pnum", Find.VisitPNumber.ToString());
  6820. //模板路径
  6821. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  6822. //载入模板
  6823. Document doc = null;
  6824. DocumentBuilder builder = null;
  6825. try
  6826. {
  6827. //载入模板
  6828. doc = new Document(tempPath);
  6829. builder = new DocumentBuilder(doc);
  6830. }
  6831. catch (Exception)
  6832. {
  6833. jw.Msg = "模板位置不存在!";
  6834. return Ok(jw);
  6835. }
  6836. foreach (var key in dic.Keys)
  6837. {
  6838. Bookmark bookmark = doc.Range.Bookmarks[key];
  6839. if (bookmark != null)
  6840. {
  6841. builder.MoveToBookmark(key);
  6842. builder.Write(dic[key]);
  6843. }
  6844. }
  6845. //获取word里所有表格
  6846. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6847. //获取所填表格的序数
  6848. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6849. try
  6850. {
  6851. //循环赋值
  6852. for (int i = 0; i < dtSource.Rows.Count; i++)
  6853. {
  6854. builder.MoveToCell(0, i + 1, 0, 0);
  6855. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6856. builder.MoveToCell(0, i + 1, 1, 0);
  6857. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6858. builder.MoveToCell(0, i + 1, 2, 0);
  6859. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6860. var trip = dtSource.Rows[i]["Trip"].ToString();
  6861. builder.MoveToCell(0, i + 1, 3, 0);
  6862. builder.Write(trip);
  6863. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6864. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6865. // 获取特定索引的段落
  6866. Paragraph paragraph = (Paragraph)paragraphs[0];
  6867. Run run = paragraph.Runs[0];
  6868. Aspose.Words.Font font = run.Font;
  6869. font.Name = "黑体";
  6870. //设置双休红色
  6871. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6872. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6873. paragraph = (Paragraph)paragraphs[1];
  6874. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6875. {
  6876. run = paragraph.Runs[0];
  6877. font = run.Font;
  6878. font.Color = Color.Red;
  6879. }
  6880. }
  6881. }
  6882. catch (Exception ex)
  6883. {
  6884. }
  6885. //删除多余行
  6886. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6887. {
  6888. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6889. }
  6890. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6891. if (!Directory.Exists(savePath))
  6892. {
  6893. try
  6894. {
  6895. Directory.CreateDirectory(savePath);
  6896. }
  6897. catch
  6898. {
  6899. }
  6900. }
  6901. string path = savePath + Find.TeamName + "出访日程";
  6902. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  6903. try
  6904. {
  6905. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  6906. string postfix = ".docx";
  6907. if (dto.IsPDF == 1)
  6908. {
  6909. saveFormat = Aspose.Words.SaveFormat.Pdf;
  6910. postfix = ".pdf";
  6911. }
  6912. doc.Save(path + postfix, saveFormat);
  6913. jw = JsonView(true, "导出成功", ftpPath + postfix);
  6914. }
  6915. catch (Exception)
  6916. {
  6917. jw = JsonView(false);
  6918. }
  6919. return Ok(jw);
  6920. }
  6921. /// <summary>
  6922. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6923. /// </summary>
  6924. /// <param name="num"></param>
  6925. /// <returns></returns>
  6926. string GetNum(string num)
  6927. {
  6928. string str = "";
  6929. switch (num)
  6930. {
  6931. case "1":
  6932. str = "一";
  6933. break;
  6934. case "2":
  6935. str = "二";
  6936. break;
  6937. case "3":
  6938. str = "三";
  6939. break;
  6940. case "4":
  6941. str = "四";
  6942. break;
  6943. case "5":
  6944. str = "五";
  6945. break;
  6946. case "6":
  6947. str = "六";
  6948. break;
  6949. case "7":
  6950. str = "七";
  6951. break;
  6952. case "8":
  6953. str = "八";
  6954. break;
  6955. case "9":
  6956. str = "九";
  6957. break;
  6958. case "10":
  6959. str = "十";
  6960. break;
  6961. case "11":
  6962. str = "十一";
  6963. break;
  6964. case "12":
  6965. str = "十二";
  6966. break;
  6967. case "一":
  6968. str = "1";
  6969. break;
  6970. case "二":
  6971. str = "2";
  6972. break;
  6973. case "三":
  6974. str = "3";
  6975. break;
  6976. case "四":
  6977. str = "4";
  6978. break;
  6979. case "五":
  6980. str = "5";
  6981. break;
  6982. case "六":
  6983. str = "6";
  6984. break;
  6985. case "七":
  6986. str = "7";
  6987. break;
  6988. case "八":
  6989. str = "8";
  6990. break;
  6991. case "九":
  6992. str = "9";
  6993. break;
  6994. case "十":
  6995. str = "10";
  6996. break;
  6997. case "十一":
  6998. str = "11";
  6999. break;
  7000. case "十二":
  7001. str = "12";
  7002. break;
  7003. }
  7004. return str;
  7005. }
  7006. #endregion
  7007. #endregion
  7008. #region 团组成本
  7009. /// <summary>
  7010. /// 团组成本数据初始化
  7011. /// </summary>
  7012. /// <param name="dto"></param>
  7013. /// <returns></returns>
  7014. [HttpPost]
  7015. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  7016. {
  7017. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  7018. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  7019. WHEN COUNT(*) >= 0 THEN 'True'
  7020. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  7021. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  7022. ").ToList(); //团组列表
  7023. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  7024. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  7025. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  7026. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  7027. if (groupinfoValue != null)
  7028. {
  7029. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  7030. var spArr = new string[1] { countryArr };
  7031. if (countryArr.Contains("|"))
  7032. {
  7033. spArr = countryArr.Split("|");
  7034. }
  7035. else if (countryArr.Contains("、"))
  7036. {
  7037. spArr = countryArr.Split("、");
  7038. }
  7039. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  7040. {
  7041. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  7042. if (dbQueryCountry != null)
  7043. {
  7044. visaCountryInfoArr.Add(dbQueryCountry);
  7045. }
  7046. }
  7047. }
  7048. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  7049. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  7050. var create = _GroupCostRepository.
  7051. CreateGroupCostByBlackCode(dto.Diid);
  7052. if (groupCost.Count == 0 && create.Code == 0)
  7053. {
  7054. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  7055. }
  7056. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  7057. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  7058. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  7059. groupCostMap = groupCostMap.Select(x =>
  7060. {
  7061. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  7062. {
  7063. x.Date = dataForamt.ToString("yyyy-MM-dd");
  7064. }
  7065. return x;
  7066. }).ToList();
  7067. //GroupCostParameter.Add(new
  7068. // Grp_GroupCostParameter());
  7069. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  7070. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  7071. return Ok(JsonView(new
  7072. {
  7073. groupList,
  7074. groupInfo,
  7075. groupChecks,
  7076. groupCost = groupCostMap,
  7077. hotelNumber,
  7078. GroupCostParameter = GroupCostParameterMap,
  7079. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  7080. {
  7081. x.VisaCountry,
  7082. x.VisaPrice,
  7083. x.Id,
  7084. }).ToList(),
  7085. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  7086. blackCodeIsTrue = create.Code == 0 ? true : false,
  7087. hotelIsTrue = hotelIsTrue,
  7088. }));
  7089. }
  7090. /// <summary>
  7091. /// 团组成本信息保存
  7092. /// </summary>
  7093. /// <param name="dto"></param>
  7094. /// <returns></returns>
  7095. [HttpPost]
  7096. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  7097. {
  7098. if (dto.Diid <= 0 || dto.Userid <= 0)
  7099. {
  7100. return Ok(JsonView(false));
  7101. }
  7102. JsonView jw = null;
  7103. bool isTrue = false;
  7104. #region 复制团组成本
  7105. //if (dto.Diid == 2581)
  7106. //{
  7107. // dto.Diid = 2599;
  7108. // dto.CheckBoxs.ForEach(x =>
  7109. // {
  7110. // x.Diid = 2599;
  7111. // });
  7112. // dto.GroupCosts.ForEach(x =>
  7113. // {
  7114. // x.Diid = 2599;
  7115. // });
  7116. // dto.CostTypeHotelNumbers.ForEach(x =>
  7117. // {
  7118. // x.Diid = 2599;
  7119. // });
  7120. // dto.GroupCostParameters.ForEach(x =>
  7121. // {
  7122. // x.DiId = 2599;
  7123. // });
  7124. //}
  7125. #endregion
  7126. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  7127. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  7128. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  7129. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  7130. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  7131. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  7132. try
  7133. {
  7134. _sqlSugar.BeginTran();
  7135. isTrue = await _GroupCostRepository.
  7136. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  7137. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  7138. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  7139. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  7140. _sqlSugar.CommitTran();
  7141. jw = JsonView(true, "保存成功!", isTrue);
  7142. }
  7143. catch (Exception)
  7144. {
  7145. _sqlSugar.RollbackTran();
  7146. jw = JsonView(false);
  7147. }
  7148. return Ok(jw);
  7149. }
  7150. /// <summary>
  7151. /// 司兼导数据
  7152. /// </summary>
  7153. /// <param name="dto"></param>
  7154. /// <returns></returns>
  7155. [HttpPost]
  7156. public IActionResult GetCarGuides(CarGuidesDto dto)
  7157. {
  7158. JsonView jw = null;
  7159. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  7160. jw = JsonView(true, "获取成功!", Data);
  7161. return Ok(jw);
  7162. }
  7163. /// <summary>
  7164. /// 导游数据
  7165. /// </summary>
  7166. /// <param name="dto"></param>
  7167. /// <returns></returns>
  7168. [HttpPost]
  7169. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  7170. {
  7171. JsonView jw = null;
  7172. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  7173. // 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
  7174. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  7175. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  7176. jw = JsonView(true, "获取成功!", Data);
  7177. return Ok(jw);
  7178. }
  7179. /// <summary>
  7180. /// 成本车数据
  7181. /// </summary>
  7182. /// <param name="dto"></param>
  7183. /// <returns></returns>
  7184. [HttpPost]
  7185. public IActionResult GetCarInfo(CarGuidesDto dto)
  7186. {
  7187. JsonView jw = null;
  7188. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  7189. jw = JsonView(true, "获取成功!", Data);
  7190. return Ok(jw);
  7191. }
  7192. /// <summary>
  7193. /// 景点数据
  7194. /// </summary>
  7195. /// <param name="dto"></param>
  7196. /// <returns></returns>
  7197. [HttpPost]
  7198. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  7199. {
  7200. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  7201. return Ok(JsonView(true, "获取成功!", Data));
  7202. }
  7203. /// <summary>
  7204. /// 成本通知
  7205. /// </summary>
  7206. /// <param name="dto"></param>
  7207. /// <returns></returns>
  7208. [HttpPost]
  7209. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  7210. {
  7211. if (dto.Diid < 0)
  7212. {
  7213. return Ok(JsonView(false));
  7214. }
  7215. JsonView jw = null;
  7216. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  7217. if (GroupCostParameter != null)
  7218. {
  7219. int IsShare = 0;
  7220. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  7221. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  7222. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  7223. string msg = string.Empty;
  7224. if (isTrue)
  7225. {
  7226. if (IsShare == 0)
  7227. {
  7228. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  7229. }
  7230. else
  7231. {
  7232. #region 企微通知对应岗位用户
  7233. try
  7234. {
  7235. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  7236. }
  7237. catch (Exception ex)
  7238. {
  7239. }
  7240. #endregion
  7241. msg = "通知成功,其他模块操作人员可见此成本信息!";
  7242. }
  7243. jw = JsonView(isTrue, msg, new { IsShare });
  7244. }
  7245. else
  7246. {
  7247. msg = "修改失败!";
  7248. jw = JsonView(isTrue, msg);
  7249. }
  7250. }
  7251. else
  7252. {
  7253. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  7254. }
  7255. return Ok(jw);
  7256. }
  7257. /// <summary>
  7258. /// 导出报价单
  7259. /// </summary>
  7260. /// <param name="dto"></param>
  7261. /// <returns></returns>
  7262. [HttpPost]
  7263. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  7264. {
  7265. if (dto.Diid == 0)
  7266. {
  7267. return Ok(JsonView(false, "请传递团组id"));
  7268. }
  7269. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7270. if (deleInfo.Code != 0)
  7271. {
  7272. return Ok(JsonView(false, "团组信息查询失败!"));
  7273. }
  7274. var di = deleInfo.Data as DelegationInfoWebView;
  7275. if (di != null)
  7276. {
  7277. di.TeamName = di.TeamName.Replace("|","、");
  7278. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  7279. //文件名
  7280. string strFileName = di.TeamName + "-收款账单.doc";
  7281. //获取模板
  7282. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  7283. //载入模板
  7284. Document doc = new Document(tmppath);
  7285. decimal TotalPrice = 0.00M;
  7286. string itemStr = string.Empty;
  7287. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  7288. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7289. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7290. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7291. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7292. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7293. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7294. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7295. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7296. foreach (var cost in groupCostType)
  7297. {
  7298. var List = cost.ToList();
  7299. if (cost.Key == "A")
  7300. {
  7301. foreach (var ListItem in List)
  7302. {
  7303. if (ListItem.number > 0)
  7304. {
  7305. if (ListItem.code.Contains("TBR"))
  7306. {
  7307. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7308. }
  7309. else
  7310. {
  7311. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7312. }
  7313. TotalPrice += (ListItem.number * ListItem.price);
  7314. }
  7315. }
  7316. }
  7317. else
  7318. {
  7319. itemStr = itemStr.Insert(0, "A段\r\n");
  7320. itemStr += "B段\r\n";
  7321. foreach (var ListItem in List)
  7322. {
  7323. if (ListItem.number > 0)
  7324. {
  7325. if (ListItem.code.Contains("TBR"))
  7326. {
  7327. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7328. }
  7329. else
  7330. {
  7331. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7332. }
  7333. TotalPrice += (ListItem.number * ListItem.price);
  7334. }
  7335. }
  7336. }
  7337. }
  7338. #region 替换Word模板书签内容
  7339. Dictionary<string, string> marks = new Dictionary<string, string>();
  7340. marks.Add("To", di.ClientUnit);//付款方
  7341. marks.Add("ToTel", di.TellPhone);//付款方电话
  7342. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7343. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7344. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7345. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7346. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7347. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7348. marks.Add("PayItemContent", itemStr);//详细信息
  7349. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7350. #endregion
  7351. ////注
  7352. //if (doc.Range.Bookmarks["Attention"] != null)
  7353. //{
  7354. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7355. // mark.Text = frList[0].Attention;
  7356. //}
  7357. foreach (var item in marks.Keys)
  7358. {
  7359. if (doc.Range.Bookmarks[item] != null)
  7360. {
  7361. Bookmark mark = doc.Range.Bookmarks[item];
  7362. mark.Text = marks[item];
  7363. }
  7364. }
  7365. byte[] bytes = null;
  7366. using (MemoryStream stream = new MemoryStream())
  7367. {
  7368. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7369. bytes = stream.ToArray();
  7370. }
  7371. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7372. return Ok(JsonView(true, "", new
  7373. {
  7374. Data = bytes,
  7375. strFileName,
  7376. }));
  7377. }
  7378. else
  7379. {
  7380. return Ok(JsonView(false, "团组信息不存在!"));
  7381. }
  7382. }
  7383. /// <summary>
  7384. /// 导出团组成本
  7385. /// </summary>
  7386. /// <param name="dto"></param>
  7387. /// <returns></returns>
  7388. [HttpPost]
  7389. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7390. {
  7391. var jw = JsonView(false);
  7392. if (dto.Diid == 0)
  7393. {
  7394. return Ok(JsonView(false, "请传递团组id"));
  7395. }
  7396. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7397. if (deleInfo.Code != 0)
  7398. {
  7399. return Ok(JsonView(false, "团组信息查询失败!"));
  7400. }
  7401. var di = deleInfo.Data as DelegationInfoWebView;
  7402. if (di == null)
  7403. {
  7404. return Ok(JsonView(false, "团组信息查询失败!"));
  7405. }
  7406. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7407. WorkbookDesigner designer = new WorkbookDesigner();
  7408. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7409. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7410. for (int i = 0; i < List_GC.Count; i++)
  7411. {
  7412. GroupCost_Excel gc = new GroupCost_Excel();
  7413. gc.Id = List_GC[i].Id;
  7414. gc.Diid = List_GC[i].Diid.ToString();
  7415. gc.DAY = List_GC[i].DAY;
  7416. string week = "";
  7417. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7418. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7419. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7420. gc.ITIN = List_GC[i].ITIN;
  7421. gc.CarType = List_GC[i].CarType;
  7422. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7423. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7424. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7425. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7426. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7427. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7428. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7429. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7430. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7431. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7432. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7433. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7434. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7435. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7436. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7437. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7438. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7439. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7440. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7441. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7442. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7443. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7444. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7445. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7446. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7447. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7448. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7449. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7450. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7451. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7452. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7453. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7454. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7455. List_GC1.Add(gc);
  7456. }
  7457. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7458. dt.TableName = "TB";
  7459. //报表标题等不用dt的值
  7460. designer.SetDataSource("TeamName", dto.title.TeamName);
  7461. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7462. designer.SetDataSource("Tax", dto.title.Tax);
  7463. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7464. designer.SetDataSource("Currency", dto.title.Currency);
  7465. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7466. designer.SetDataSource("Rate", dto.title.Rate);
  7467. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7468. var Aparams = hotels.Find(x => x.Type == "Default");
  7469. if (Aparams == null)
  7470. {
  7471. return Ok(jw);
  7472. }
  7473. //酒店数量
  7474. var txtSGRNumber = Aparams.SGR.ToString();
  7475. var txtTBRNumber = Aparams.TBR.ToString();
  7476. var txtJSESNumber = Aparams.JSES.ToString();
  7477. var txtSUITENumbe = Aparams.SUITE.ToString();
  7478. if (dto.costType == "B")
  7479. {
  7480. Aparams = hotels.Find(x => x.Type == "A");
  7481. var Bparams = hotels.Find(x => x.Type == "B");
  7482. if (Aparams == null || Bparams == null)
  7483. {
  7484. return Ok(jw);
  7485. }
  7486. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7487. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7488. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7489. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7490. }
  7491. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7492. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7493. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7494. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7495. var ws = designer.Workbook.Worksheets[0];
  7496. int Row = List_GC.Count;
  7497. int startIndex = 11;
  7498. int HideRows = 0;
  7499. List<int> hideRowsList = new List<int>();
  7500. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7501. #region A段left数据
  7502. var left = dto.leftInfo.Find(x => x.Type == "A");
  7503. if (left == null)
  7504. {
  7505. return Ok(jw);
  7506. }
  7507. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7508. if (leftBindData != null)
  7509. {
  7510. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7511. designer.SetDataSource("VisaRS", leftBindData.rs);
  7512. designer.SetDataSource("VisaXS", leftBindData.xs);
  7513. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7514. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7515. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7516. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7517. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7518. }
  7519. else
  7520. {
  7521. hideRowsList.Add(Row + startIndex + HideRows);
  7522. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7523. }
  7524. HideRows += 2;
  7525. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7526. if (leftBindData != null)
  7527. {
  7528. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7529. designer.SetDataSource("BXRS", leftBindData.rs);
  7530. designer.SetDataSource("BXXS", leftBindData.xs);
  7531. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7532. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7533. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7534. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7535. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7536. }
  7537. else
  7538. {
  7539. hideRowsList.Add(Row + startIndex + HideRows);
  7540. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7541. }
  7542. HideRows += 2;
  7543. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7544. if (leftBindData != null)
  7545. {
  7546. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7547. designer.SetDataSource("HSRS", leftBindData.rs);
  7548. designer.SetDataSource("HSXS", leftBindData.xs);
  7549. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7550. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7551. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7552. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7553. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7554. }
  7555. else
  7556. {
  7557. hideRowsList.Add(Row + startIndex + HideRows);
  7558. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7559. }
  7560. HideRows += 2;
  7561. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7562. if (leftBindData != null)
  7563. {
  7564. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7565. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7566. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7567. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7568. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7569. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7570. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7571. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7572. }
  7573. else
  7574. {
  7575. hideRowsList.Add(Row + startIndex + HideRows);
  7576. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7577. }
  7578. HideRows += 2;
  7579. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7580. if (leftBindData != null)
  7581. {
  7582. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7583. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7584. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7585. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7586. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7587. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7588. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7589. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7590. }
  7591. else
  7592. {
  7593. hideRowsList.Add(Row + startIndex + HideRows);
  7594. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7595. }
  7596. HideRows += 2;
  7597. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7598. if (leftBindData != null)
  7599. {
  7600. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  7601. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  7602. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  7603. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7604. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7605. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7606. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7607. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7608. }
  7609. else
  7610. {
  7611. hideRowsList.Add(Row + startIndex + HideRows);
  7612. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7613. }
  7614. HideRows += 2;
  7615. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7616. if (leftBindData != null)
  7617. {
  7618. ////TBR
  7619. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7620. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7621. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7622. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7623. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7624. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7625. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7626. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7627. }
  7628. else
  7629. {
  7630. hideRowsList.Add(Row + startIndex + HideRows);
  7631. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7632. }
  7633. HideRows += 2;
  7634. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7635. if (leftBindData != null)
  7636. {
  7637. ////SGR
  7638. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7639. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7640. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7641. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7642. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7643. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7644. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7645. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7646. }
  7647. else
  7648. {
  7649. hideRowsList.Add(Row + startIndex + HideRows);
  7650. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7651. }
  7652. HideRows += 2;
  7653. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7654. if (leftBindData != null)
  7655. {
  7656. ////JS/ES
  7657. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7658. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7659. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7660. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7661. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7662. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7663. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7664. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7665. }
  7666. else
  7667. {
  7668. hideRowsList.Add(Row + startIndex + HideRows);
  7669. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7670. }
  7671. HideRows += 2;
  7672. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7673. if (leftBindData != null)
  7674. {
  7675. ////SUITE
  7676. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7677. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7678. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7679. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7680. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7681. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7682. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7683. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7684. }
  7685. else
  7686. {
  7687. hideRowsList.Add(Row + startIndex + HideRows);
  7688. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7689. }
  7690. HideRows += 2;
  7691. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7692. if (leftBindData != null)
  7693. {
  7694. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7695. designer.SetDataSource("DJRS", leftBindData.rs);
  7696. designer.SetDataSource("DJXS", leftBindData.xs);
  7697. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7698. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7699. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7700. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7701. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7702. }
  7703. else
  7704. {
  7705. hideRowsList.Add(Row + startIndex + HideRows);
  7706. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7707. }
  7708. HideRows += 2;
  7709. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7710. if (leftBindData != null)
  7711. {
  7712. designer.SetDataSource("HCPCB", leftBindData.cb);
  7713. designer.SetDataSource("HCPRS", leftBindData.rs);
  7714. designer.SetDataSource("HCPXS", leftBindData.xs);
  7715. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7716. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7717. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7718. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7719. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7720. }
  7721. else
  7722. {
  7723. hideRowsList.Add(Row + startIndex + HideRows);
  7724. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7725. }
  7726. HideRows += 2;
  7727. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7728. if (leftBindData != null)
  7729. {
  7730. designer.SetDataSource("CPCB", leftBindData.cb);
  7731. designer.SetDataSource("CPRS", leftBindData.rs);
  7732. designer.SetDataSource("CPXS", leftBindData.xs);
  7733. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7734. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7735. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7736. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7737. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7738. }
  7739. else
  7740. {
  7741. hideRowsList.Add(Row + startIndex + HideRows);
  7742. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7743. }
  7744. HideRows += 2;
  7745. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7746. if (leftBindData != null)
  7747. {
  7748. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7749. designer.SetDataSource("GWRS", leftBindData.rs);
  7750. designer.SetDataSource("GWXS", leftBindData.xs);
  7751. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7752. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7753. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7754. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7755. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7756. }
  7757. else
  7758. {
  7759. hideRowsList.Add(Row + startIndex + HideRows);
  7760. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7761. }
  7762. HideRows += 2;
  7763. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7764. if (leftBindData != null)
  7765. {
  7766. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7767. designer.SetDataSource("LYJRS", leftBindData.rs);
  7768. designer.SetDataSource("LYJXS", leftBindData.xs);
  7769. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7770. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7771. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7772. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7773. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7774. }
  7775. else
  7776. {
  7777. hideRowsList.Add(Row + startIndex + HideRows);
  7778. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7779. }
  7780. #endregion
  7781. #region A段Right信息
  7782. var right = dto.rightInfo.Find(x => x.Type == "A");
  7783. if (right == null)
  7784. {
  7785. return Ok(jw);
  7786. }
  7787. HideRows += 4;
  7788. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7789. if (rightBindData != null)
  7790. {
  7791. //经济舱 + 双人间 TBR
  7792. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7793. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7794. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7795. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7796. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7797. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7798. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7799. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7800. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7801. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7802. }
  7803. else
  7804. {
  7805. hideRowsList.Add(Row + startIndex + HideRows);
  7806. }
  7807. HideRows += 2;
  7808. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7809. if (rightBindData != null)
  7810. {
  7811. //经济舱 + 单人间 SGR
  7812. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7813. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7814. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7815. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7816. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7817. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7818. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7819. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7820. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7821. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7822. }
  7823. else
  7824. {
  7825. hideRowsList.Add(Row + startIndex + HideRows);
  7826. }
  7827. HideRows += 2;
  7828. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7829. if (rightBindData != null)
  7830. {
  7831. //公务舱 + 单人间 SGR
  7832. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7833. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7834. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7835. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7836. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7837. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7838. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7839. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7840. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7841. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7842. }
  7843. else
  7844. {
  7845. hideRowsList.Add(Row + startIndex + HideRows);
  7846. }
  7847. HideRows += 2;
  7848. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7849. if (rightBindData != null)
  7850. {
  7851. //公务舱 + 小套房 JSES
  7852. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7853. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7854. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7855. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7856. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7857. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7858. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7859. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7860. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7861. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7862. }
  7863. else
  7864. {
  7865. hideRowsList.Add(Row + startIndex + HideRows);
  7866. }
  7867. HideRows += 2;
  7868. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7869. if (rightBindData != null)
  7870. {
  7871. //公务舱 + 小套房 JSES
  7872. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7873. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7874. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7875. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7876. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7877. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7878. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7879. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7880. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7881. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7882. }
  7883. else
  7884. {
  7885. hideRowsList.Add(Row + startIndex + HideRows);
  7886. }
  7887. HideRows += 2;
  7888. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7889. if (rightBindData != null)
  7890. {
  7891. //经济舱 + 大套房
  7892. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7893. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7894. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7895. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7896. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7897. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7898. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7899. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7900. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7901. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7902. }
  7903. else
  7904. {
  7905. hideRowsList.Add(Row + startIndex + HideRows);
  7906. }
  7907. HideRows += 2;
  7908. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  7909. if (rightBindData != null)
  7910. {
  7911. //头等舱 + 小套房 JSES
  7912. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  7913. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  7914. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7915. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  7916. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7917. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7918. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7919. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7920. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7921. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7922. }
  7923. else
  7924. {
  7925. hideRowsList.Add(Row + startIndex + HideRows);
  7926. }
  7927. HideRows += 2;
  7928. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  7929. if (rightBindData != null)
  7930. {
  7931. //头等舱 + 大套房
  7932. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  7933. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  7934. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7935. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  7936. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7937. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7938. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7939. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7940. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7941. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7942. }
  7943. else
  7944. {
  7945. hideRowsList.Add(Row + startIndex + HideRows);
  7946. }
  7947. #endregion
  7948. #region B段标题清空
  7949. designer.SetDataSource("CostBDRCB", "");
  7950. designer.SetDataSource("CostBRS", "");
  7951. designer.SetDataSource("CostBXS", "");
  7952. designer.SetDataSource("CostBZCB", "");
  7953. designer.SetDataSource("CostBDRBJ", "");
  7954. designer.SetDataSource("CostBZBJ", "");
  7955. designer.SetDataSource("CostBDRLR", "");
  7956. designer.SetDataSource("CostBZLR", "");
  7957. designer.SetDataSource("CostBDRCBOM", "");
  7958. designer.SetDataSource("CostBRSOM", "");
  7959. designer.SetDataSource("CostBZCBOM", "");
  7960. designer.SetDataSource("CostBDRBJOM", "");
  7961. designer.SetDataSource("CostBZBJOM", "");
  7962. designer.SetDataSource("CostBDRLROM", "");
  7963. designer.SetDataSource("CostBZLROM", "");
  7964. #endregion
  7965. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7966. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7967. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7968. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7969. designer.SetDataSource("DJName", "地接(CNY)");
  7970. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7971. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7972. designer.SetDataSource("GWName", "公务(CNY)");
  7973. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7974. designer.SetDataSource("LYJName", "零用金(CNY)");
  7975. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7976. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7977. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7978. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  7979. designer.SetDataSource("BXName", "保险(CNY)");
  7980. designer.SetDataSource("VisaName", "签证(CNY)");
  7981. #region B段基本数据
  7982. if (dto.costType == "B")
  7983. {
  7984. left = dto.leftInfo.Find(x => x.Type == "B");
  7985. if (left == null)
  7986. {
  7987. return Ok(jw);
  7988. }
  7989. #region B段left数据
  7990. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7991. if (leftBindData != null)
  7992. {
  7993. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7994. designer.SetDataSource("BHSRS", leftBindData.rs);
  7995. designer.SetDataSource("BHSXS", leftBindData.xs);
  7996. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7997. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7998. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7999. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8000. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8001. }
  8002. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8003. if (leftBindData != null)
  8004. {
  8005. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  8006. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  8007. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  8008. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8009. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8010. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8011. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8012. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8013. }
  8014. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8015. if (leftBindData != null)
  8016. {
  8017. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  8018. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  8019. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  8020. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8021. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8022. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8023. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8024. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8025. }
  8026. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8027. if (leftBindData != null)
  8028. {
  8029. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  8030. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  8031. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  8032. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8033. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8034. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8035. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8036. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8037. }
  8038. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8039. if (leftBindData != null)
  8040. {
  8041. designer.SetDataSource("BHCPCB", leftBindData.cb);
  8042. designer.SetDataSource("BHCPRS", leftBindData.rs);
  8043. designer.SetDataSource("BHCPXS", leftBindData.xs);
  8044. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8045. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8046. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8047. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8048. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8049. }
  8050. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8051. if (leftBindData != null)
  8052. {
  8053. designer.SetDataSource("BCPCB", leftBindData.cb);
  8054. designer.SetDataSource("BCPRS", leftBindData.rs);
  8055. designer.SetDataSource("BCPXS", leftBindData.xs);
  8056. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8057. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8058. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8059. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8060. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8061. }
  8062. //TBR
  8063. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8064. if (leftBindData != null)
  8065. {
  8066. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  8067. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  8068. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  8069. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8070. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8071. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8072. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8073. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8074. }
  8075. //SGR
  8076. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8077. if (leftBindData != null)
  8078. {
  8079. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  8080. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  8081. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  8082. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8083. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8084. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8085. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8086. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8087. }
  8088. //JS/ES
  8089. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8090. if (leftBindData != null)
  8091. {
  8092. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  8093. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  8094. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  8095. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8096. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8097. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8098. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8099. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8100. }
  8101. //SUITE
  8102. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8103. if (leftBindData != null)
  8104. {
  8105. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  8106. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  8107. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  8108. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8109. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8110. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8111. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8112. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8113. }
  8114. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8115. if (leftBindData != null)
  8116. {
  8117. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  8118. designer.SetDataSource("BDJRS", leftBindData.rs);
  8119. designer.SetDataSource("BDJXS", leftBindData.xs);
  8120. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8121. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8122. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8123. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8124. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8125. }
  8126. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8127. if (leftBindData != null)
  8128. {
  8129. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  8130. designer.SetDataSource("BGWRS", leftBindData.rs);
  8131. designer.SetDataSource("BGWXS", leftBindData.xs);
  8132. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8133. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8134. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8135. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8136. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8137. }
  8138. #region 优化方案
  8139. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  8140. //excelBind.Add("零用金", new {
  8141. //cb="",
  8142. //rs="",
  8143. //xs ="",
  8144. //zcb = "",
  8145. //});
  8146. #endregion
  8147. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8148. if (leftBindData != null)
  8149. {
  8150. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  8151. designer.SetDataSource("BLYJRS", leftBindData.rs);
  8152. designer.SetDataSource("BLYJXS", leftBindData.xs);
  8153. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8154. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8155. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8156. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8157. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8158. }
  8159. #endregion
  8160. #region B段Right信息
  8161. right = dto.rightInfo.Find(x => x.Type == "B");
  8162. if (right == null)
  8163. {
  8164. return Ok(jw);
  8165. }
  8166. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8167. if (rightBindData != null)
  8168. {
  8169. //经济舱 + 双人间 TBR
  8170. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  8171. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  8172. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8173. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  8174. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8175. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8176. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8177. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8178. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8179. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8180. }
  8181. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8182. if (rightBindData != null)
  8183. {
  8184. //经济舱 + 单人间 SGR
  8185. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  8186. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  8187. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8188. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  8189. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8190. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8191. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8192. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8193. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8194. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8195. }
  8196. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8197. if (rightBindData != null)
  8198. {
  8199. //公务舱 + 单人间 SGR
  8200. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  8201. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  8202. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8203. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  8204. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8205. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8206. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8207. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8208. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8209. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8210. }
  8211. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8212. if (rightBindData != null)
  8213. {
  8214. //公务舱 + 小套房 JSES
  8215. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  8216. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  8217. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8218. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  8219. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8220. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8221. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8222. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8223. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8224. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8225. }
  8226. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8227. if (rightBindData != null)
  8228. {
  8229. //公务舱 + 小套房 JSES
  8230. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  8231. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  8232. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8233. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  8234. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8235. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8236. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8237. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8238. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8239. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8240. }
  8241. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8242. if (rightBindData != null)
  8243. {
  8244. //经济舱 + 大套房
  8245. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  8246. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  8247. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8248. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  8249. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8250. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8251. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8252. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8253. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8254. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8255. }
  8256. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8257. if (rightBindData != null)
  8258. {
  8259. //头等舱 + 小套房 JSES
  8260. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  8261. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  8262. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8263. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  8264. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8265. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8266. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8267. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8268. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8269. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8270. }
  8271. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8272. if (rightBindData != null)
  8273. {
  8274. //头等舱 + 大套房
  8275. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  8276. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  8277. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8278. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  8279. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8280. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8281. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8282. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8283. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8284. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8285. }
  8286. #endregion
  8287. #region 标题
  8288. designer.SetDataSource("CostBDRCB", "单人成本");
  8289. designer.SetDataSource("CostBRS", "人数");
  8290. designer.SetDataSource("CostBXS", "系数");
  8291. designer.SetDataSource("CostBZCB", "总成本");
  8292. designer.SetDataSource("CostBDRBJ", "单人报价");
  8293. designer.SetDataSource("CostBZBJ", "总报价");
  8294. designer.SetDataSource("CostBDRLR", "单人利润");
  8295. designer.SetDataSource("CostBZLR", "总利润");
  8296. designer.SetDataSource("CostBDRCBOM", "单人成本");
  8297. designer.SetDataSource("CostBRSOM", "人数");
  8298. designer.SetDataSource("CostBZCBOM", "总成本");
  8299. designer.SetDataSource("CostBDRBJOM", "单人报价");
  8300. designer.SetDataSource("CostBZBJOM", "总报价");
  8301. designer.SetDataSource("CostBDRLROM", "单人利润");
  8302. designer.SetDataSource("CostBZLROM", "总利润");
  8303. #endregion
  8304. }
  8305. #endregion
  8306. designer.SetDataSource("TzZCB2", TzZCB2);
  8307. designer.SetDataSource("TzZBJ2", TzZBJ2);
  8308. designer.SetDataSource("TzZLR2", TzZLR2);
  8309. string[] dataSourceKeys = new string[]
  8310. {
  8311. "VF",
  8312. "TGS",
  8313. "TGOF",
  8314. "TGM",
  8315. "TGA",
  8316. "TGTF",
  8317. "TGEF",
  8318. "CFM",
  8319. "CFOF",
  8320. "B",
  8321. "L",
  8322. "D",
  8323. "TBR",
  8324. "SGR",
  8325. "JSES",
  8326. "Suite",
  8327. "TV",
  8328. "1L",
  8329. "IF",
  8330. "EF",
  8331. "BRF",
  8332. "TE",
  8333. "TGT",
  8334. "DRVT",
  8335. "PC",
  8336. "TLF",
  8337. "ECT"
  8338. };
  8339. foreach (var item in dataSourceKeys)
  8340. {
  8341. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8342. if (find != null)
  8343. {
  8344. designer.SetDataSource(item, find.text);
  8345. }
  8346. else
  8347. {
  8348. designer.SetDataSource(item, 0);
  8349. }
  8350. }
  8351. designer.SetDataSource(dt);
  8352. //根据数据源处理生成报表内容
  8353. designer.Process();
  8354. designer.Workbook.Worksheets[0].Name = "清单";
  8355. Worksheet sheet = designer.Workbook.Worksheets[0];
  8356. foreach (var Rowindex in hideRowsList)
  8357. {
  8358. ws.Cells.HideRows(Rowindex, 2);
  8359. }
  8360. byte[] bytes = null;
  8361. string strFileName = di.TeamName + "-团组-成本.xls";
  8362. using (MemoryStream stream = new MemoryStream())
  8363. {
  8364. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8365. bytes = stream.ToArray();
  8366. }
  8367. return Ok(JsonView(true, "", new
  8368. {
  8369. Data = bytes,
  8370. strFileName,
  8371. }));
  8372. }
  8373. /// <summary>
  8374. /// 导出客户报表
  8375. /// </summary>
  8376. /// <returns></returns>
  8377. [HttpPost]
  8378. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8379. {
  8380. var jw = JsonView(false);
  8381. if (dto.Diid == 0)
  8382. {
  8383. return Ok(JsonView(false, "请传递团组id"));
  8384. }
  8385. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8386. if (deleInfo.Code != 0)
  8387. {
  8388. return Ok(JsonView(false, "团组信息查询失败!"));
  8389. }
  8390. var di = deleInfo.Data as DelegationInfoWebView;
  8391. if (di == null)
  8392. {
  8393. return Ok(JsonView(false, "团组信息查询失败!"));
  8394. }
  8395. //文件名
  8396. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8397. //获取模板
  8398. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8399. //载入模板
  8400. Document doc = new Document(tmppath);
  8401. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8402. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8403. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8404. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8405. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8406. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8407. if (AParameter == null)
  8408. {
  8409. return Ok(JsonView(false, "系数不存在!"));
  8410. }
  8411. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8412. , TzAirDesc, TzZCost;
  8413. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8414. = TzAirDesc = TzZCost = string.Empty;
  8415. TzNumber = AParameter.CostTypenumber.ToString();
  8416. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8417. CarGuides1 = dto.CarGuides1;
  8418. Meal = dto.Meal;
  8419. SubsidizedMeals = dto.SubsidizedMeals;
  8420. NightRepair = dto.NightRepair;
  8421. AttractionsTickets = dto.AttractionsTickets;
  8422. MiscellaneousFees = dto.MiscellaneousFees;
  8423. ATip = dto.ATip;
  8424. TzHotelDesc = "";
  8425. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8426. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8427. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8428. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8429. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8430. TzAirDesc = "";
  8431. TzZCost = dto.TzZCost;
  8432. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8433. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8434. var index = 1;
  8435. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8436. foreach (var item in TzHotelDescArr)
  8437. {
  8438. if (AinfoArr != null)
  8439. {
  8440. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8441. if (Ainfo != null)
  8442. {
  8443. if (int.Parse(Ainfo.rs) <= 0)
  8444. {
  8445. continue;
  8446. }
  8447. var hotelText = string.Empty;
  8448. switch (item)
  8449. {
  8450. case "SGR":
  8451. hotelText = "单人间";
  8452. break;
  8453. case "JSES":
  8454. hotelText = "小套房";
  8455. break;
  8456. case "SUITE":
  8457. hotelText = "套房";
  8458. break;
  8459. case "TBR":
  8460. hotelText = "双人间";
  8461. break;
  8462. }
  8463. if (item != "TBR")
  8464. {
  8465. 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";
  8466. }
  8467. else
  8468. {
  8469. 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";
  8470. }
  8471. index++;
  8472. }
  8473. }
  8474. }
  8475. index = 1;
  8476. foreach (var item in TzAirDescArr)
  8477. {
  8478. if (AinfoArr != null)
  8479. {
  8480. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8481. if (Ainfo != null)
  8482. {
  8483. if (int.Parse(Ainfo.rs) <= 0)
  8484. {
  8485. continue;
  8486. }
  8487. 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";
  8488. index++;
  8489. }
  8490. }
  8491. }
  8492. if (dto.costType == "B")
  8493. {
  8494. if (BParameter == null)
  8495. {
  8496. return Ok(JsonView(false, "B段系数不存在!"));
  8497. }
  8498. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8499. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8500. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8501. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8502. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8503. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8504. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8505. foreach (var item in TzHotelDescArr)
  8506. {
  8507. if (AinfoArr != null)
  8508. {
  8509. TzHotelDesc += "B段信息 \r\n";
  8510. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8511. if (Ainfo != null)
  8512. {
  8513. if (int.Parse(Ainfo.rs) <= 0)
  8514. {
  8515. continue;
  8516. }
  8517. var hotelText = string.Empty;
  8518. switch (item)
  8519. {
  8520. case "SGR":
  8521. hotelText = "单人间";
  8522. break;
  8523. case "JSES":
  8524. hotelText = "小套房";
  8525. break;
  8526. case "SUITE":
  8527. hotelText = "套房";
  8528. break;
  8529. case "TBR":
  8530. hotelText = "双人间";
  8531. break;
  8532. }
  8533. if (item != "TBR")
  8534. {
  8535. 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";
  8536. }
  8537. else
  8538. {
  8539. 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";
  8540. }
  8541. index++;
  8542. }
  8543. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8544. }
  8545. }
  8546. index = 1;
  8547. foreach (var item in TzAirDescArr)
  8548. {
  8549. if (AinfoArr != null)
  8550. {
  8551. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8552. if (Ainfo != null)
  8553. {
  8554. if (int.Parse(Ainfo.rs) <= 0)
  8555. {
  8556. continue;
  8557. }
  8558. 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";
  8559. index++;
  8560. }
  8561. }
  8562. }
  8563. }
  8564. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8565. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8566. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8567. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8568. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8569. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8570. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8571. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8572. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8573. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8574. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8575. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8576. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8577. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8578. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8579. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8580. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8581. DickeyValue.Add("TzZCost", TzZCost);
  8582. foreach (var key in DickeyValue.Keys)
  8583. {
  8584. if (doc.Range.Bookmarks[key] != null)
  8585. {
  8586. Bookmark mark = doc.Range.Bookmarks[key];
  8587. mark.Text = DickeyValue[key];
  8588. }
  8589. }
  8590. byte[] bytes = null;
  8591. string strFileName = di.TeamName + "-客户报价.doc";
  8592. using (MemoryStream stream = new MemoryStream())
  8593. {
  8594. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8595. bytes = stream.ToArray();
  8596. }
  8597. return Ok(JsonView(true, "", new
  8598. {
  8599. Data = bytes,
  8600. strFileName,
  8601. }));
  8602. }
  8603. /// <summary>
  8604. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8605. /// </summary>
  8606. /// <param name="dto"></param>
  8607. /// <returns></returns>
  8608. [HttpPost]
  8609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8610. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8611. {
  8612. try
  8613. {
  8614. #region 参数验证
  8615. if (dto.DiId < 0)
  8616. {
  8617. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8618. }
  8619. List<int> cTableIds = new List<int>() {
  8620. 76 ,//酒店预订
  8621. 77 ,//行程
  8622. 79 ,//车/导游地接
  8623. 80 ,//签证
  8624. 81 ,//邀请/公务活
  8625. 82 ,//团组客户保险
  8626. 85 ,//机票预订
  8627. 98 ,//其他款项
  8628. 285 ,//收款退还
  8629. 751 ,//酒店早餐
  8630. 1015 // 超支费用
  8631. };
  8632. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8633. {
  8634. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8635. }
  8636. #endregion
  8637. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8638. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8639. if (_GroupCostParameters.Count <= 0)
  8640. {
  8641. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8642. }
  8643. if (_GroupCostParameters[0].IsShare == 0)
  8644. {
  8645. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8646. }
  8647. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8648. //处理date为空问题
  8649. if (_GroupCosts.Count > 0)
  8650. {
  8651. for (int i = 0; i < _GroupCosts.Count; i++)
  8652. {
  8653. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8654. {
  8655. if (i > 0)
  8656. {
  8657. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8658. }
  8659. }
  8660. }
  8661. }
  8662. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8663. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8664. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8665. string currCode = "";
  8666. #region currCode 验证
  8667. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8668. if (isInt)
  8669. {
  8670. var currData = currDatas.Find(it => it.Id == intCurrency);
  8671. if (currData != null)
  8672. {
  8673. currCode = currData.Name;
  8674. }
  8675. }
  8676. else
  8677. {
  8678. currCode = _GroupCostParameters[0].Currency.Trim();
  8679. }
  8680. #endregion
  8681. //op,酒店单段模式存储
  8682. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8683. {
  8684. CurrencyCode = currCode,
  8685. Rate = _GroupCostParameters[0].Rate,
  8686. CostType = _GroupCostParameters[0].CostType,
  8687. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8688. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8689. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8690. };
  8691. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8692. if (_GroupCostParameters.Count == 2)
  8693. {
  8694. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8695. }
  8696. foreach (var item in _GroupCostParameters)
  8697. {
  8698. decimal _rate = 1;
  8699. decimal _rate1 = item.Rate;
  8700. decimal _scale = 1;
  8701. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8702. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8703. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8704. //if (userInfo != null)
  8705. //{
  8706. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8707. // {
  8708. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8709. // {
  8710. // _scale = 1.00M;
  8711. // }
  8712. // }
  8713. //}
  8714. #endregion
  8715. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8716. {
  8717. CurrencyCode = currCode,
  8718. Rate = _rate1,
  8719. CostType = item.CostType,
  8720. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8721. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8722. CostTypeNumber = item.CostTypenumber
  8723. };
  8724. if (_GroupCostParameters.Count > 1)
  8725. {
  8726. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8727. }
  8728. else
  8729. {
  8730. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8731. }
  8732. if (dto.CTable == 79)//
  8733. {
  8734. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8735. modulePromptInfo.TotalCost = item.DJCB;
  8736. }
  8737. List<string> costTypes = new List<string>() { "A", "B" };
  8738. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8739. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8740. if (_GroupCostsDuplicates.Count() == 1)
  8741. {
  8742. _GroupCostsTypeData = _GroupCosts;
  8743. }
  8744. else
  8745. {
  8746. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8747. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8748. }
  8749. /*
  8750. * 76 酒店预订
  8751. * 77 行程
  8752. * 79 车/导游地接
  8753. * 80 签证
  8754. * 81 邀请/公务活动
  8755. * 82 团组客户保险
  8756. * 85 机票预订
  8757. * 98 其他款项
  8758. * 285 收款退还
  8759. * 751 酒店早餐
  8760. * 1015 超支费用
  8761. */
  8762. switch (dto.CTable)
  8763. {
  8764. case 76: // 酒店预订
  8765. _ModuleSubPromptInfo.AddRange(
  8766. _GroupCostsTypeData.Select(it => new
  8767. {
  8768. it.DAY,
  8769. it.Date,
  8770. it.ACCON,
  8771. it.ITIN,
  8772. it.SGR,
  8773. it.TBR,
  8774. it.JS_ES,
  8775. it.Suite
  8776. })
  8777. );
  8778. break;
  8779. case 79: // 车/导游地接
  8780. _ModuleSubPromptInfo.AddRange(
  8781. _GroupCostsTypeData.Select(it => new
  8782. {
  8783. Date = it.Date, //日期
  8784. CarFee = it.CarCost * _rate * _scale, //车费用
  8785. CarType = it.CarType, //车型
  8786. DriverFee = it.CFS * _rate * _scale, //司机工资
  8787. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  8788. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  8789. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  8790. GuideFee = it.TGS * _rate * _scale, //导游费用
  8791. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  8792. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  8793. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  8794. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  8795. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  8796. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  8797. Breakfast = it.B * _rate * _scale, //早餐费
  8798. Lunch = it.L * _rate * _scale, //午餐费
  8799. Dinner = it.D * _rate * _scale, //晚餐费
  8800. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  8801. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  8802. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  8803. TicketFee = it.EF * _rate * _scale, //门票费
  8804. TicketRemark = it.EFR, //门票费描述
  8805. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8806. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8807. SpentCash = it.PC * _rate * _scale, //零用金
  8808. LeadersFee = it.TLF * _rate * _scale, //领队费
  8809. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  8810. })
  8811. );
  8812. break;
  8813. case 85: // 机票
  8814. List<dynamic> datas = new List<dynamic>();
  8815. datas.Add(
  8816. new
  8817. {
  8818. AirType = "经济舱",
  8819. AirNum = item.JJCRS,
  8820. AirDRCB = item.JJCCB,
  8821. AirZCB = (item.JJCRS * item.JJCCB)
  8822. }
  8823. );
  8824. datas.Add(
  8825. new
  8826. {
  8827. AirType = "公务舱",
  8828. AirNum = item.GWCRS,
  8829. AirDRCB = item.GWCCB,
  8830. AirZCB = (item.GWCRS * item.GWCCB)
  8831. }
  8832. );
  8833. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8834. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8835. modulePromptInfo.Data = new
  8836. {
  8837. airFeeData = datas,
  8838. airInitData = initDatas
  8839. };
  8840. _ModulePromptInfos.Add(modulePromptInfo);
  8841. break;
  8842. default:
  8843. break;
  8844. }
  8845. }
  8846. if (dto.CTable != 85)
  8847. {
  8848. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8849. _ModulePromptInfos.Add(_ModulePromptInfo);
  8850. }
  8851. _view.ModulePromptInfos = _ModulePromptInfos;
  8852. return Ok(JsonView(true, "操作成功!", _view));
  8853. }
  8854. catch (Exception ex)
  8855. {
  8856. return Ok(JsonView(false, ex.Message));
  8857. }
  8858. }
  8859. /// <summary>
  8860. /// 根据黑屏代码重新生成行程
  8861. /// </summary>
  8862. /// <param name="dto"></param>
  8863. /// <returns></returns>
  8864. [HttpPost]
  8865. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8866. {
  8867. var jw = JsonView(false);
  8868. var Create = _GroupCostRepository.
  8869. CreateGroupCostByBlackCode(dto.Diid);
  8870. jw.Msg = Create.Msg;
  8871. if (Create.Code == 0)
  8872. {
  8873. jw.Code = 200;
  8874. jw.Data = new
  8875. {
  8876. groupCost = Create.Data,
  8877. blackCodeIsTrue = true
  8878. };
  8879. }
  8880. else
  8881. {
  8882. jw.Code = 400;
  8883. jw.Data = new
  8884. {
  8885. groupCost = Create.Data,
  8886. blackCodeIsTrue = false,
  8887. };
  8888. }
  8889. return Ok(jw);
  8890. }
  8891. /// <summary>
  8892. /// 成本获取OP历史车费用
  8893. /// </summary>
  8894. /// <param name="dto"></param>
  8895. /// <returns></returns>
  8896. [HttpPost]
  8897. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8898. {
  8899. var jw = JsonView(false);
  8900. try
  8901. {
  8902. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8903. //获取现有所有车的数据
  8904. if (!dto.Param.IsNullOrWhiteSpace())
  8905. {
  8906. string sql = $@"
  8907. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8908. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8909. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8910. 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
  8911. AND gctggr.ServiceEndTime is not NULL
  8912. ORDER by gctggrc.id DESC
  8913. ";
  8914. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8915. var numeberResult = await Task.Run(() =>
  8916. {
  8917. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8918. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8919. return numberArr;
  8920. });
  8921. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8922. foreach (var item in numeberResult)
  8923. {
  8924. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8925. {
  8926. Country = "数据异常!",
  8927. City = string.Empty,
  8928. };
  8929. item.Area = find.Country + " " + find.City;
  8930. }
  8931. dbResult.AddRange(numeberResult);
  8932. if (dto.Param.Contains("、"))
  8933. {
  8934. var sp = dto.Param.Split("、");
  8935. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8936. .Where(x =>
  8937. {
  8938. return System.Array.Exists(sp, e =>
  8939. {
  8940. bool where = false;
  8941. if (x.Area != null)
  8942. {
  8943. where = x.Area.Contains(e);
  8944. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8945. {
  8946. return false;
  8947. }
  8948. }
  8949. if (x.PriceName != null && !where)
  8950. {
  8951. where = x.PriceName.Contains(e);
  8952. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8953. {
  8954. return false;
  8955. }
  8956. }
  8957. return where;
  8958. });
  8959. }).ToList();
  8960. }
  8961. else
  8962. {
  8963. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8964. .Where(x =>
  8965. {
  8966. bool where = false;
  8967. if (x.Area != null)
  8968. {
  8969. where = x.Area.Contains(dto.Param);
  8970. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8971. {
  8972. return false;
  8973. }
  8974. }
  8975. if (x.PriceName != null && !where)
  8976. {
  8977. where = x.PriceName.Contains(dto.Param);
  8978. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8979. {
  8980. return false;
  8981. }
  8982. }
  8983. return where;
  8984. }
  8985. )
  8986. .ToList();
  8987. }
  8988. }
  8989. var view = dbResult.Select(x =>
  8990. {
  8991. decimal dp = 0.00M;
  8992. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8993. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8994. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8995. {
  8996. if (startB && endB)
  8997. {
  8998. var timesp = endD.Subtract(startD);
  8999. if ((timesp.Days + 1) != 0)
  9000. {
  9001. dp = x.Price / (timesp.Days + 1);
  9002. }
  9003. }
  9004. }
  9005. else
  9006. {
  9007. dp = x.Price;
  9008. }
  9009. return new
  9010. {
  9011. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  9012. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  9013. x.Area,
  9014. x.id,
  9015. price = x.Price.ToString("F2"),
  9016. x.PriceName,
  9017. x.PriceContent,
  9018. x.TeamName,
  9019. x.DatePrice,
  9020. dayPrice = dp.ToString("F2"),
  9021. };
  9022. }).OrderByDescending(x => x.id).ToList();
  9023. jw = JsonView(true, "获取成功!", view);
  9024. }
  9025. catch (Exception e)
  9026. {
  9027. jw = JsonView(false, e.Message);
  9028. }
  9029. return Ok(jw);
  9030. }
  9031. #endregion
  9032. #region 酒店预订 新 雷怡 2023-12-28 17:45
  9033. /// <summary>
  9034. /// 酒店预订
  9035. /// 酒店费用列表 根据团组Id查询
  9036. /// </summary>
  9037. /// <param name="_dto"></param>
  9038. /// <returns></returns>
  9039. [HttpPost]
  9040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9041. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  9042. {
  9043. #region 参数验证
  9044. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9045. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9046. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9047. #region 团组操作权限验证 76 酒店预定模块
  9048. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9049. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9050. #endregion
  9051. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9052. #region 页面操作权限验证
  9053. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9054. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9055. #endregion
  9056. #endregion
  9057. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  9058. }
  9059. /// <summary>
  9060. /// 酒店预订
  9061. /// 基础数据
  9062. /// </summary>
  9063. /// <param name="_dto"></param>
  9064. /// <returns></returns>
  9065. [HttpPost]
  9066. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9067. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  9068. {
  9069. #region 参数验证
  9070. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9071. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9072. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9073. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9074. #region 页面操作权限验证
  9075. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9076. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9077. #endregion
  9078. #region 团组操作权限验证 76 酒店预定模块
  9079. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9080. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9081. #endregion
  9082. #endregion
  9083. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  9084. }
  9085. /// <summary>
  9086. /// 酒店预订
  9087. /// 创建 入住卷号码
  9088. /// </summary>
  9089. /// <param name="_dto"></param>
  9090. /// <returns></returns>
  9091. [HttpPost]
  9092. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9093. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  9094. {
  9095. #region 参数验证
  9096. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9097. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9098. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9099. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9100. #region 页面操作权限验证
  9101. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9102. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9103. #endregion
  9104. #region 团组操作权限验证 76 酒店预定模块
  9105. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9106. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9107. #endregion
  9108. #endregion
  9109. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  9110. if (data.Code != 0)
  9111. {
  9112. return Ok(JsonView(false, data.Msg));
  9113. }
  9114. return Ok(JsonView(true, data.Msg, data.Data));
  9115. }
  9116. /// <summary>
  9117. /// 酒店预订
  9118. /// 详情
  9119. /// </summary>
  9120. /// <param name="_dto"></param>
  9121. /// <returns></returns>
  9122. [HttpPost]
  9123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9124. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  9125. {
  9126. #region 参数验证
  9127. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  9128. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9129. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  9130. #region 团组操作权限验证 76 酒店预定模块
  9131. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9132. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9133. #endregion
  9134. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9135. #region 页面操作权限验证
  9136. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9137. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9138. #endregion
  9139. #endregion
  9140. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  9141. }
  9142. /// <summary>
  9143. /// 酒店预订
  9144. /// Add Or Edit
  9145. /// </summary>
  9146. /// <param name="_dto"></param>
  9147. /// <returns></returns>
  9148. [HttpPost]
  9149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9150. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  9151. {
  9152. #region 参数验证
  9153. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9154. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9155. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9156. #region 团组操作权限验证 76 酒店预定模块
  9157. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9158. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9159. #endregion
  9160. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9161. #region 页面操作权限验证
  9162. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9163. if (_dto.Id == 0) // Add
  9164. {
  9165. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9166. }
  9167. else if (_dto.Id > 1) // Edit
  9168. {
  9169. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9170. }
  9171. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  9172. #endregion
  9173. #endregion
  9174. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  9175. if (_view.Code != 200)
  9176. {
  9177. return Ok(_view);
  9178. }
  9179. #region 应用推送
  9180. try
  9181. {
  9182. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9183. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9184. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9185. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9186. //自动审核
  9187. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  9188. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  9189. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  9190. }
  9191. catch (Exception ex)
  9192. {
  9193. }
  9194. #endregion
  9195. return Ok(_view);
  9196. }
  9197. /// <summary>
  9198. /// 酒店自动审核测试
  9199. /// Add Or Edit
  9200. /// </summary>
  9201. /// <param name="_dto"></param>
  9202. /// <returns></returns>
  9203. [HttpPost]
  9204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9205. public async Task<IActionResult> PostHotelAutoAuditTest(int diid,int dataId)
  9206. {
  9207. #region 应用推送
  9208. try
  9209. {
  9210. //自动审核
  9211. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  9212. }
  9213. catch (Exception ex)
  9214. {
  9215. return Ok(JsonView(false, "操作失败"));
  9216. }
  9217. #endregion
  9218. return Ok(JsonView(false,"操作成功"));
  9219. }
  9220. /// <summary>
  9221. /// 酒店预订
  9222. /// Del
  9223. /// </summary>
  9224. /// <param name="_dto"></param>
  9225. /// <returns></returns>
  9226. [HttpPost]
  9227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9228. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  9229. {
  9230. #region 参数验证
  9231. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9232. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9233. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9234. #region 团组操作权限验证 76 酒店预定模块
  9235. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9236. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9237. #endregion
  9238. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9239. #region 页面操作权限验证
  9240. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9241. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9242. #endregion
  9243. #endregion
  9244. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  9245. }
  9246. /// <summary>
  9247. /// 酒店预订
  9248. /// 生成VOUCHER
  9249. /// 2024.05.06 之前版本
  9250. /// </summary>
  9251. /// <param name="_dto"></param>
  9252. /// <returns></returns>
  9253. [HttpPost]
  9254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9255. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  9256. {
  9257. try
  9258. {
  9259. #region 参数验证
  9260. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9261. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9262. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9263. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  9264. #region 团组操作权限验证 76 酒店预定模块
  9265. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9266. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9267. #endregion
  9268. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9269. #region 页面操作权限验证
  9270. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9271. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9272. #endregion
  9273. #endregion
  9274. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  9275. //判断数据是否完整
  9276. if (hr != null)
  9277. {
  9278. if (!string.IsNullOrEmpty(hr.DetermineNo))
  9279. {
  9280. string strFileName = "HotelStatement/";
  9281. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9282. if (dele != null)
  9283. strFileName += dele.TourCode;
  9284. //载入模板
  9285. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  9286. Document doc = new Document(sss);
  9287. DocumentBuilder builder = new DocumentBuilder(doc);
  9288. #region 替换Word模板书签内容
  9289. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9290. //入住卷预定号码
  9291. if (doc.Range.Bookmarks["VNO"] != null)
  9292. {
  9293. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9294. mark.Text = hr.CheckNumber;
  9295. }
  9296. //酒店时间
  9297. if (doc.Range.Bookmarks["Date"] != null)
  9298. {
  9299. Bookmark mark = doc.Range.Bookmarks["Date"];
  9300. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9301. }
  9302. //团号
  9303. if (doc.Range.Bookmarks["TNo"] != null)
  9304. {
  9305. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9306. mark.Text = dele.TourCode;
  9307. }
  9308. //预定号码
  9309. if (doc.Range.Bookmarks["BookingId"] != null)
  9310. {
  9311. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9312. mark.Text = hr.ReservationsNo;
  9313. }
  9314. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9315. {
  9316. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9317. mark.Text = hr.DetermineNo;
  9318. }
  9319. //酒店城市
  9320. if (doc.Range.Bookmarks["City"] != null)
  9321. {
  9322. Bookmark mark = doc.Range.Bookmarks["City"];
  9323. mark.Text = hr.City;
  9324. }
  9325. //酒店名称
  9326. if (doc.Range.Bookmarks["HName"] != null)
  9327. {
  9328. Bookmark mark = doc.Range.Bookmarks["HName"];
  9329. mark.Text = hr.HotelName;
  9330. }
  9331. //酒店地址
  9332. if (doc.Range.Bookmarks["Address"] != null)
  9333. {
  9334. Bookmark mark = doc.Range.Bookmarks["Address"];
  9335. mark.Text = hr.HotelAddress;
  9336. }
  9337. //酒店电话
  9338. if (doc.Range.Bookmarks["Tel"] != null)
  9339. {
  9340. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9341. mark.Text = hr.HotelTel;
  9342. }
  9343. //酒店传真
  9344. if (doc.Range.Bookmarks["Fax"] != null)
  9345. {
  9346. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9347. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9348. {
  9349. mark.Text = hr.HotelFax;
  9350. }
  9351. }
  9352. //入住时间
  9353. if (doc.Range.Bookmarks["CIn"] != null)
  9354. {
  9355. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9356. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9357. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9358. }
  9359. //退房时间
  9360. if (doc.Range.Bookmarks["COut"] != null)
  9361. {
  9362. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9363. Bookmark mark = doc.Range.Bookmarks["COut"];
  9364. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9365. }
  9366. //客户名称
  9367. if (doc.Range.Bookmarks["GName"] != null)
  9368. {
  9369. string guestName = "";
  9370. string[] clients = new string[] { };
  9371. if (hr.GuestName.Contains(","))
  9372. {
  9373. clients = hr.GuestName.Split(",");
  9374. }
  9375. else
  9376. {
  9377. clients = new string[] { hr.GuestName };
  9378. }
  9379. List<int> clientIds_int = new List<int>();
  9380. if (clients.Length > 0)
  9381. {
  9382. foreach (var item in clients)
  9383. {
  9384. if (item.IsNumeric())
  9385. {
  9386. clientIds_int.Add(int.Parse(item));
  9387. }
  9388. }
  9389. }
  9390. if (clientIds_int.Count > 0)
  9391. {
  9392. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9393. foreach (var client in _clientDatas)
  9394. {
  9395. //男
  9396. if (client.Sex == 0) guestName += $"Mr.";
  9397. //女
  9398. else if (client.Sex == 1) guestName += $"Ms.";
  9399. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9400. {
  9401. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9402. }
  9403. //guestName += $"{client.Pinyin},";
  9404. }
  9405. if (guestName.Length > 0)
  9406. {
  9407. guestName = guestName.Substring(0, guestName.Length - 1);
  9408. }
  9409. }
  9410. else
  9411. {
  9412. guestName = hr.GuestName;
  9413. }
  9414. Bookmark mark = doc.Range.Bookmarks["GName"];
  9415. mark.Text = guestName;
  9416. }
  9417. //房间介绍
  9418. if (doc.Range.Bookmarks["ROOM"] != null)
  9419. {
  9420. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9421. mark.Text = hr.RoomExplanation;
  9422. }
  9423. //报价描述
  9424. if (doc.Range.Bookmarks["NOTE"] != null)
  9425. {
  9426. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9427. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9428. if (ss != null)
  9429. mark.Text = ss.Name;
  9430. }
  9431. //入住时间
  9432. if (doc.Range.Bookmarks["CheckIn"] != null)
  9433. {
  9434. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9435. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9436. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9437. }
  9438. //退房时间
  9439. if (doc.Range.Bookmarks["CheckOut"] != null)
  9440. {
  9441. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9442. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9443. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9444. }
  9445. //日期
  9446. if (doc.Range.Bookmarks["DT"] != null)
  9447. {
  9448. Bookmark mark = doc.Range.Bookmarks["DT"];
  9449. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9450. }
  9451. //名称
  9452. if (doc.Range.Bookmarks["VName"] != null)
  9453. {
  9454. Bookmark mark = doc.Range.Bookmarks["VName"];
  9455. mark.Text = hr.HotelName;
  9456. }
  9457. //号码
  9458. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9459. {
  9460. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9461. mark.Text = hr.CheckNumber;
  9462. }
  9463. #endregion
  9464. strFileName += "VOUCHER.doc";
  9465. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9466. doc.Save(fileDir);
  9467. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9468. return Ok(JsonView(true, "操作成功!", Url));
  9469. }
  9470. else
  9471. {
  9472. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9473. }
  9474. }
  9475. else
  9476. {
  9477. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9478. }
  9479. }
  9480. catch (Exception ex)
  9481. {
  9482. return Ok(JsonView(false, ex.Message));
  9483. }
  9484. }
  9485. /// <summary>
  9486. /// 酒店预订
  9487. /// 生成VOUCHER
  9488. /// 2024.05.06 之后版本
  9489. /// </summary>
  9490. /// <param name="_dto"></param>
  9491. /// <returns></returns>
  9492. [HttpPost]
  9493. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9494. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9495. {
  9496. #region 参数验证
  9497. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9498. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9499. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9500. #region 团组操作权限验证 76 酒店预定模块
  9501. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9502. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9503. #endregion
  9504. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9505. #region 页面操作权限验证
  9506. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9507. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9508. #endregion
  9509. #endregion
  9510. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9511. //判断数据是否完整
  9512. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9513. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9514. string strFileName = "HotelStatement/";
  9515. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9516. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9517. #region 数据处理
  9518. List<int> guestIds = new List<int>();
  9519. int index = 0;
  9520. foreach (var item in hrDtas)
  9521. {
  9522. if (item.GuestName.Contains(","))
  9523. {
  9524. string[] guestIdArr = item.GuestName.Split(',');
  9525. foreach (var guestIdStr in guestIdArr)
  9526. {
  9527. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9528. if (guestBool)
  9529. {
  9530. guestIds.Add(guestId);
  9531. }
  9532. }
  9533. }
  9534. else guestNames += item.GuestName;
  9535. var voucherInfo = new HotelVoucherInfoView()
  9536. {
  9537. HotelName = item.HotelName,
  9538. CheckInDate = item.CheckInDate,
  9539. CheckOutDate = item.CheckOutDate,
  9540. ConfirmationNumber = item.DetermineNo.Trim(),
  9541. RoomType = item.RoomExplanation
  9542. };
  9543. vouchers.Add(voucherInfo);
  9544. }
  9545. if (guestIds.Count > 0)
  9546. {
  9547. guestIds = guestIds.Distinct().ToList();
  9548. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9549. if (guestDatas.Count > 0)
  9550. {
  9551. guestNames = "";
  9552. foreach (var guest in guestDatas)
  9553. {
  9554. string guestName = "";
  9555. if (guest.Sex == 0) guestName += @"MR.";
  9556. else if (guest.Sex == 1) guestName += @"MS.";
  9557. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9558. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9559. guestNames += @$"{guestName.Trim()}、";
  9560. }
  9561. if (guestNames.Length > 0)
  9562. {
  9563. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9564. }
  9565. }
  9566. }
  9567. #endregion
  9568. //载入模板
  9569. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9570. Document doc = new Document(sss);
  9571. DocumentBuilder builder = new DocumentBuilder(doc);
  9572. if (doc.Range.Bookmarks["GuestName"] != null)
  9573. {
  9574. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9575. mark.Text = guestNames;
  9576. }
  9577. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9578. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9579. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9580. for (int i = 1; i <= vouchers.Count; i++)
  9581. {
  9582. HotelVoucherInfoView hviv = vouchers[i - 1];
  9583. builder.MoveToCell(0, i, 0, 0);
  9584. builder.Write(hviv.HotelName);
  9585. builder.MoveToCell(0, i, 1, 0);
  9586. builder.Write(hviv.CheckInDate);
  9587. builder.MoveToCell(0, i, 2, 0);
  9588. builder.Write(hviv.CheckOutDate);
  9589. builder.MoveToCell(0, i, 3, 0);
  9590. builder.Write(hviv.RoomType);
  9591. builder.MoveToCell(0, i, 4, 0);
  9592. builder.Write(hviv.ConfirmationNumber);
  9593. }
  9594. //删除多余行
  9595. int currRowIndex = vouchers.Count + 1;
  9596. int delRows = 21 - currRowIndex;
  9597. if (delRows > 0)
  9598. {
  9599. for (int i = 0; i < delRows; i++)
  9600. {
  9601. table.Rows.RemoveAt(currRowIndex);
  9602. //cultivateRowIndex++;
  9603. }
  9604. }
  9605. strFileName += "VOUCHER.docx";
  9606. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9607. doc.Save(fileDir);
  9608. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9609. return Ok(JsonView(true, "操作成功!", Url));
  9610. }
  9611. /// <summary>
  9612. /// 酒店预订
  9613. /// 生成VOUCHER 批量生成
  9614. /// New
  9615. /// </summary>
  9616. /// <param name="_dto"></param>
  9617. /// <returns></returns>
  9618. [HttpPost]
  9619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9620. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  9621. {
  9622. #region 参数验证
  9623. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9624. if (_dto.PageId < 1) _dto.PageId = 28;
  9625. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9626. #region 团组操作权限验证 76 酒店预定模块
  9627. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9628. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9629. #endregion
  9630. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9631. #region 页面操作权限验证
  9632. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9633. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9634. #endregion
  9635. #endregion
  9636. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  9637. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  9638. .OrderBy(x => x.CreateTime)
  9639. .ToListAsync();
  9640. //判断数据是否完整
  9641. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9642. string strFileName = "HotelStatement/";
  9643. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9644. if (dele != null)
  9645. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  9646. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  9647. for (int i = 0; i < hrDtas.Count; i++)
  9648. {
  9649. string guestNames = string.Empty;
  9650. List<int> guestIds = new List<int>();
  9651. var item = hrDtas[i];
  9652. //处理客户姓名
  9653. if (item.GuestName.Contains(","))
  9654. {
  9655. string[] guestIdArr = item.GuestName.Split(',');
  9656. foreach (var guestIdStr in guestIdArr)
  9657. if (int.TryParse(guestIdStr, out int guestId))
  9658. guestIds.Add(guestId);
  9659. }
  9660. else {
  9661. //NaN
  9662. if (item.GuestName.Contains("NaN"))
  9663. {
  9664. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  9665. }
  9666. }
  9667. if (guestIds.Count > 0)
  9668. {
  9669. guestIds = guestIds.Distinct().ToList();
  9670. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  9671. if (guestDatas1.Count > 0)
  9672. {
  9673. guestNames = "";
  9674. foreach (var guest in guestDatas1)
  9675. {
  9676. string guestName = "";
  9677. if (guest.Sex == 0) guestName += @"MR.";
  9678. else if (guest.Sex == 1) guestName += @"MS.";
  9679. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9680. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9681. guestNames += @$"{guestName.Trim()}、";
  9682. }
  9683. if (guestNames.Length > 0)
  9684. {
  9685. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9686. }
  9687. }
  9688. }
  9689. //if (!string.IsNullOrEmpty(guestNames))
  9690. //{
  9691. hrDtas[i].GuestName = guestNames;
  9692. //}
  9693. }
  9694. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9695. Document doc = new Document();
  9696. DocumentBuilder builder = new DocumentBuilder(doc);
  9697. try
  9698. {
  9699. builder.MoveToDocumentStart();
  9700. foreach (var item in hrDtas)
  9701. {
  9702. //标题
  9703. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9704. builder.ParagraphFormat.LineSpacing = 1;
  9705. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9706. builder.ParagraphFormat.Style.Font.Size = 9;
  9707. builder.ParagraphFormat.Style.Font.Bold = true;
  9708. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9709. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  9710. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9711. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9712. builder.ParagraphFormat.LineSpacing = 1;
  9713. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9714. builder.ParagraphFormat.Style.Font.Size = 9;
  9715. builder.ParagraphFormat.Style.Font.Bold = true;
  9716. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  9717. builder.StartTable();
  9718. // 设置边框颜色
  9719. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  9720. //设置边框样式
  9721. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  9722. //表格
  9723. #region 第一行
  9724. builder.InsertCell();
  9725. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9726. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9727. //builder.CellFormat.AllowAutoFit = false;
  9728. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9729. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9730. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9731. builder.CellFormat.WrapText = true; //自动换行
  9732. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9733. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  9734. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9735. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9736. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9737. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9738. builder.Write("TOUR NO:");
  9739. builder.InsertCell();
  9740. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9741. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9742. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9743. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9744. builder.ParagraphFormat.Style.Font.Bold = false;
  9745. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9746. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9747. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9748. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9749. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9750. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9751. builder.Write($"{dele?.TourCode ?? "-"}");
  9752. builder.InsertCell();
  9753. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9754. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9755. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9756. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9757. builder.ParagraphFormat.Style.Font.Bold = false;
  9758. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9759. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9760. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9761. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9762. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9763. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9764. builder.Write($"CITY:");
  9765. builder.InsertCell();
  9766. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9767. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9768. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9769. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9770. builder.ParagraphFormat.Style.Font.Bold = false;
  9771. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9772. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9773. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9774. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9775. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9776. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9777. builder.Write($"{item.City}");
  9778. builder.EndRow();
  9779. #endregion
  9780. #region 第二行
  9781. builder.InsertCell();
  9782. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9783. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9784. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9785. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9786. builder.ParagraphFormat.Style.Font.Bold = false;
  9787. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9788. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9789. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9790. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9791. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9792. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9793. builder.Write("CONFIRMATION NO:");
  9794. builder.InsertCell();
  9795. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9796. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9797. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9798. builder.ParagraphFormat.Style.Font.Bold = false;
  9799. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9800. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9801. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9802. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9803. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9804. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9805. builder.CellFormat.VerticalMerge = CellMerge.None;
  9806. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9807. builder.Write($"{item.DetermineNo}");
  9808. builder.InsertCell();
  9809. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9810. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9811. builder.InsertCell();
  9812. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9813. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9814. builder.EndRow();
  9815. #endregion
  9816. #region 第三行
  9817. builder.InsertCell();
  9818. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9819. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9820. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9821. builder.ParagraphFormat.Style.Font.Bold = false;
  9822. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9823. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9824. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9825. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9826. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9827. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9828. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9829. builder.Write($"HOTEL NAME:");
  9830. builder.InsertCell();
  9831. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9832. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9833. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9834. builder.ParagraphFormat.Style.Font.Bold = false;
  9835. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9836. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9837. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9838. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9839. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9840. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9841. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9842. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9843. builder.Write($"{item.HotelName}");
  9844. builder.InsertCell();
  9845. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9846. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9847. builder.InsertCell();
  9848. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9849. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9850. builder.EndRow();
  9851. #endregion
  9852. #region 第四行
  9853. builder.InsertCell();
  9854. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9855. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9856. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9857. builder.ParagraphFormat.Style.Font.Bold = false;
  9858. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9859. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9860. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9861. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9862. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9863. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9864. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9865. builder.Write($"HOTEL ADDRESS:");
  9866. builder.InsertCell();
  9867. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9868. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9869. builder.ParagraphFormat.Style.Font.Size = 8;
  9870. builder.ParagraphFormat.Style.Font.Bold = false;
  9871. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9872. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9873. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9874. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9875. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9876. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9877. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9878. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9879. builder.Write($"{item.HotelAddress}");
  9880. builder.InsertCell();
  9881. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9882. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9883. builder.InsertCell();
  9884. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9885. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9886. builder.EndRow();
  9887. #endregion
  9888. #region 第五行
  9889. builder.InsertCell();
  9890. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9891. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9892. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9893. builder.ParagraphFormat.Style.Font.Bold = false;
  9894. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9895. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9896. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9897. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9898. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9899. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9900. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9901. builder.Write("TEL:");
  9902. builder.InsertCell();
  9903. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9904. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9905. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9906. builder.ParagraphFormat.Style.Font.Bold = false;
  9907. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9908. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9909. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9910. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9911. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9912. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9913. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9914. builder.Write($"{item.HotelTel}");
  9915. builder.InsertCell();
  9916. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9917. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9918. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9919. builder.ParagraphFormat.Style.Font.Bold = false;
  9920. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9921. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9922. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9923. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9924. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9925. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9926. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9927. builder.Write($"FAX:");
  9928. builder.InsertCell();
  9929. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9930. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9931. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9932. builder.ParagraphFormat.Style.Font.Bold = false;
  9933. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9934. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9935. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9936. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9937. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9938. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9939. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9940. builder.Write($"{item.HotelFax}");
  9941. builder.EndRow();
  9942. #endregion
  9943. #region 第六行
  9944. builder.InsertCell();
  9945. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9946. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9947. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9948. builder.ParagraphFormat.Style.Font.Bold = false;
  9949. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9950. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9951. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9952. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9953. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9954. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9955. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9956. builder.Write("CHECK IN:");
  9957. builder.InsertCell();
  9958. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9959. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9960. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9961. builder.ParagraphFormat.Style.Font.Bold = false;
  9962. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9963. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9964. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9965. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9966. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9967. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9968. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9969. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  9970. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9971. builder.Write($"{checkInStr}");
  9972. builder.InsertCell();
  9973. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9974. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9975. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9976. builder.ParagraphFormat.Style.Font.Bold = false;
  9977. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9978. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9979. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9980. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9981. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9982. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9983. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9984. builder.Write($"CHECK OUT:");
  9985. builder.InsertCell();
  9986. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9987. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9988. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9989. builder.ParagraphFormat.Style.Font.Bold = false;
  9990. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9991. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9992. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9993. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9994. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9995. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9996. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9997. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  9998. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  9999. builder.Write($"{checkOutStr}");
  10000. builder.EndRow();
  10001. #endregion
  10002. #region 第七行
  10003. builder.InsertCell();
  10004. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10005. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10006. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10007. builder.ParagraphFormat.Style.Font.Bold = false;
  10008. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10009. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10010. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10011. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10012. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10013. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10014. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10015. builder.Write($"GUEST NAME:");
  10016. builder.InsertCell();
  10017. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10018. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10019. builder.ParagraphFormat.Style.Font.Size = 8;
  10020. builder.ParagraphFormat.Style.Font.Bold = false;
  10021. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10022. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10023. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10024. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10025. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10026. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10027. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10028. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10029. builder.Write($"{item.GuestName}");
  10030. builder.InsertCell();
  10031. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10032. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10033. builder.InsertCell();
  10034. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10035. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10036. builder.EndRow();
  10037. #endregion
  10038. #region 第八行
  10039. builder.InsertCell();
  10040. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10041. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10042. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10043. builder.ParagraphFormat.Style.Font.Bold = false;
  10044. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10045. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10046. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10047. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10048. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10049. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10050. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10051. builder.Write($"ROOM TYPE:");
  10052. builder.InsertCell();
  10053. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10054. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10055. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10056. builder.ParagraphFormat.Style.Font.Bold = false;
  10057. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10058. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10059. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10060. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10061. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10062. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10063. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10064. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10065. builder.Write($"{item.RoomExplanation}");
  10066. builder.InsertCell();
  10067. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10068. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10069. builder.InsertCell();
  10070. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10071. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10072. builder.EndRow();
  10073. #endregion
  10074. #region 第九行
  10075. builder.InsertCell();
  10076. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10077. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10078. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10079. builder.ParagraphFormat.Style.Font.Bold = false;
  10080. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10081. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10082. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10083. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10084. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10085. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10086. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10087. builder.Write($"NOTE:");
  10088. builder.InsertCell();
  10089. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10090. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10091. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10092. builder.ParagraphFormat.Style.Font.Bold = false;
  10093. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10094. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10095. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10096. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10097. 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.");
  10098. builder.InsertCell();
  10099. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10100. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10101. builder.InsertCell();
  10102. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10103. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10104. builder.EndRow();
  10105. #endregion
  10106. builder.EndTable();
  10107. //换行
  10108. builder.Writeln("");
  10109. builder.Writeln("");
  10110. }
  10111. #region 获取文档中的所有表格 设置文字自适应
  10112. // 获取文档中的所有表格。
  10113. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  10114. {
  10115. // 遍历表格中的所有行。
  10116. foreach (Aspose.Words.Tables.Row row in table.Rows)
  10117. {
  10118. foreach (Cell cell in row.Cells)
  10119. {
  10120. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  10121. cellFormat.Width = 0;
  10122. }
  10123. }
  10124. }
  10125. #endregion
  10126. #region 设置页眉
  10127. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  10128. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  10129. if (System.IO.File.Exists(voucherHeaderPath))
  10130. {
  10131. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  10132. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  10133. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  10134. Shape shape = builder.InsertImage(imageBytes);
  10135. // 调整图片位置
  10136. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  10137. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  10138. shape.Top = 50; // 将图片距离页眉上边缘的距离
  10139. shape.Left = 0; // 将图片距离页面左边缘的距离
  10140. shape.Width = 81; // 设置图片宽度
  10141. shape.Height = 36; // 设置图片高度
  10142. }
  10143. //靠右
  10144. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  10145. //// 设置页脚上下边距
  10146. //builder.PageSetup.HeaderDistance = 42;
  10147. // 添加页眉线
  10148. Aspose.Words.Border borderHeader = null;
  10149. try
  10150. {
  10151. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  10152. }
  10153. catch (Exception e)
  10154. {
  10155. // TODO Auto-generated catch block
  10156. //e.printStackTrace();
  10157. }
  10158. borderHeader.Shadow = true;
  10159. borderHeader.DistanceFromText = 2;
  10160. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  10161. #endregion
  10162. }
  10163. catch (Exception ex)
  10164. {
  10165. }
  10166. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10167. doc.Save(fileDir);
  10168. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10169. return Ok(JsonView(true, "操作成功!", Url));
  10170. }
  10171. /// <summary>
  10172. /// 酒店预订
  10173. /// 生成 预定成本 Excel
  10174. /// </summary>
  10175. /// <param name="_dto"></param>
  10176. /// <returns></returns>
  10177. [HttpPost]
  10178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10179. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  10180. {
  10181. #region 参数验证
  10182. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  10183. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  10184. if (!vadalitorRes.IsValid)
  10185. {
  10186. var errors = new StringBuilder();
  10187. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  10188. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  10189. }
  10190. #region 团组操作权限验证 76 酒店预定模块
  10191. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10192. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10193. #endregion
  10194. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10195. #region 页面操作权限验证
  10196. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10197. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10198. #endregion
  10199. #endregion
  10200. decimal _rate = 1.00M;
  10201. string _currency = "";
  10202. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  10203. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  10204. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  10205. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  10206. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  10207. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  10208. {
  10209. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  10210. }
  10211. _currency = _GroupCostParameter.Currency;
  10212. bool isIntType = int.TryParse(_currency, out int currId);
  10213. if (isIntType)
  10214. {
  10215. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  10216. }
  10217. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  10218. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  10219. if (currInfo == null)
  10220. {
  10221. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  10222. }
  10223. if (!_currency.ToUpper().Equals("CNY"))
  10224. {
  10225. _rate = _GroupCostParameter.Rate;
  10226. }
  10227. _rate = currInfo.Rate;
  10228. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10229. string strFileName = "HotelStatement/";
  10230. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10231. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  10232. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10233. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  10234. #region 数据处理
  10235. foreach (var item in hrDtas)
  10236. {
  10237. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  10238. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  10239. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  10240. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  10241. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  10242. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  10243. string singleRoomFeeStr = string.Empty,
  10244. doubleRoomFeeStr = string.Empty,
  10245. suiteRoomFeeStr = string.Empty,
  10246. otherRoomFeeStr = string.Empty,
  10247. payMoneyStr = string.Empty,
  10248. cardPriceStr = string.Empty;
  10249. if (roomCurr.Equals(_currency))
  10250. {
  10251. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  10252. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  10253. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  10254. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  10255. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  10256. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  10257. }
  10258. else
  10259. {
  10260. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10261. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10262. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10263. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10264. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  10265. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  10266. }
  10267. string breakfastPriceStr = string.Empty,
  10268. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  10269. governmentRentStr = string.Empty,
  10270. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  10271. cityTaxStrStr = string.Empty,
  10272. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  10273. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  10274. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  10275. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  10276. int payDId = roomInfo?.PayDId ?? 0;
  10277. pcfds.Add(new HotelReservations_PCFD_View()
  10278. {
  10279. City = item.City,
  10280. HotelName = item.HotelName,
  10281. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  10282. // SingleRoomCount = item.SingleRoomCount,
  10283. SingleRoomPrice = singleRoomFeeStr,
  10284. // DoubleRoomCount = item.DoubleRoomCount,
  10285. DoubleRoomPrice = doubleRoomFeeStr,
  10286. //SuiteRoomCount = item.SuiteRoomCount,
  10287. SuiteRoomPrice = suiteRoomFeeStr,
  10288. OtherRoomPrice = otherRoomFeeStr,
  10289. //OtherRoomCount = item.OtherRoomCount,
  10290. BreakfastPrice = breakfastPriceStr,
  10291. GovernmentRent = governmentRentStr,
  10292. CityTax = cityTaxStrStr,
  10293. RoomExplanation = item.RoomExplanation,
  10294. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  10295. PayTime = roomInfo?.ConsumptionDate,
  10296. BankNo = roomInfo?.BankNo,
  10297. PayMoney = payMoneyStr,
  10298. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  10299. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  10300. CardPrice = cardPriceStr,
  10301. Remark = ccpInfo.Remark
  10302. });
  10303. }
  10304. #endregion
  10305. //载入模板
  10306. WorkbookDesigner designer = new WorkbookDesigner();
  10307. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  10308. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  10309. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  10310. designer.SetDataSource("TourNo", groupInfo.TourCode);
  10311. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  10312. designer.SetDataSource("Opertor", userInfo.CnName);
  10313. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  10314. dt.TableName = "ViewMyHotelReservations";
  10315. designer.SetDataSource(dt);
  10316. designer.Process();
  10317. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/","").Replace(@"\", "").Trim()}_酒店预订成本_{ DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10318. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  10319. designer.Workbook.Save(serverPath);
  10320. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  10321. #region 删除指定行
  10322. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  10323. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  10324. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  10325. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  10326. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  10327. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  10328. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  10329. cssIndex = dt.Columns["CityTax"].Ordinal,
  10330. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  10331. remarkIndex = dt.Columns["Remark"].Ordinal;
  10332. //删除指定列
  10333. foreach (DataRow item in dt.Rows)
  10334. {
  10335. string singleStr = item["SingleRoomPrice"].ToString();
  10336. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  10337. if (containsDigitButNotZero1) singleDel = false;
  10338. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  10339. string doubleStr = item["DoubleRoomPrice"].ToString();
  10340. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10341. if (containsDigitButNotZero2) doubleDel = false;
  10342. string suiteStr = item["SuiteRoomPrice"].ToString();
  10343. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10344. if (containsDigitButNotZero3) suiteDel = false;
  10345. string otherStr = item["OtherRoomPrice"].ToString();
  10346. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  10347. if (containsDigitButNotZero4) otherDel = false;
  10348. string zcStr = item["BreakfastPrice"].ToString();
  10349. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  10350. if (containsDigitButNotZero5) zcDel = false;
  10351. string dsStr = item["GovernmentRent"].ToString();
  10352. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  10353. if (containsDigitButNotZero6) dsDel = false;
  10354. string cssStr = item["CityTax"].ToString();
  10355. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  10356. if (containsDigitButNotZero7) cssDel = false;
  10357. string cpStr = item["ConsumptionPatterns"].ToString();
  10358. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  10359. string remarkStr = item["Remark"].ToString();
  10360. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  10361. }
  10362. DeleteColumn(serverPath, remarkIndex, remarkDel);
  10363. DeleteColumn(serverPath, cpIndex, cpDel);
  10364. DeleteColumn(serverPath, dsIndex, dsDel);
  10365. DeleteColumn(serverPath, cssIndex, cssDel);
  10366. DeleteColumn(serverPath, zcIndex, zcDel);
  10367. DeleteColumn(serverPath, otherIndex, otherDel);
  10368. DeleteColumn(serverPath, suiteIndex, suiteDel);
  10369. DeleteColumn(serverPath, doubleIndex, doubleDel);
  10370. DeleteColumn(serverPath, singleIndex, singleDel);
  10371. #endregion
  10372. //只保留第一个表格
  10373. DeleteSheet(serverPath);
  10374. return Ok(JsonView(true, "操作成功", url = rst));
  10375. }
  10376. /// <summary>
  10377. /// 删除指定列
  10378. /// </summary>
  10379. /// <param name="file"></param>
  10380. /// <param name="columnIndex"></param>
  10381. /// <param name="isDel"></param>
  10382. private void DeleteColumn(string file, int columnIndex, bool isDel)
  10383. {
  10384. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10385. //wb.Save(file);
  10386. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  10387. if (sheet1 != null)
  10388. {
  10389. if (isDel)
  10390. {
  10391. Cells cells = sheet1.Cells;
  10392. cells.DeleteColumn(columnIndex);
  10393. }
  10394. }
  10395. wb.Save(file);
  10396. }
  10397. /// <summary>
  10398. /// 删除sheet
  10399. /// </summary>
  10400. /// <param name="file"></param>
  10401. /// <param name="sheetName"></param>
  10402. private void DeleteSheet(string file, string sheetName = "")
  10403. {
  10404. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10405. //wb.Save(file);
  10406. List<string> sheets = new List<string>();
  10407. foreach (var item in wb.Worksheets)
  10408. {
  10409. sheets.Add(item.Name);
  10410. }
  10411. if (sheets.Count > 0)
  10412. {
  10413. sheets.RemoveAt(0);//不删除第一个sheet
  10414. foreach (var item in sheets)
  10415. {
  10416. wb.Worksheets.RemoveAt(item);
  10417. }
  10418. }
  10419. wb.Save(file);
  10420. }
  10421. /// <summary>
  10422. /// 酒店预订
  10423. /// 确认单
  10424. /// </summary>
  10425. /// <param name="_dto"></param>
  10426. /// <returns></returns>
  10427. [HttpPost]
  10428. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10429. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  10430. {
  10431. try
  10432. {
  10433. #region 参数验证
  10434. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10435. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10436. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10437. #region 团组操作权限验证 76 酒店预定模块
  10438. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10439. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10440. #endregion
  10441. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10442. #region 页面操作权限验证
  10443. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10444. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10445. #endregion
  10446. #endregion
  10447. //团组信息
  10448. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  10449. //酒店数据
  10450. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  10451. if (listhoteldata.Count < 0)
  10452. {
  10453. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  10454. }
  10455. //利datatable存储
  10456. DataTable dt = new DataTable();
  10457. dt.Columns.Add("CheckInDate", typeof(string));
  10458. dt.Columns.Add("City", typeof(string));
  10459. dt.Columns.Add("Hotel", typeof(string));
  10460. dt.Columns.Add("Room", typeof(string));
  10461. for (int i = 0; i < listhoteldata.Count; i++)
  10462. {
  10463. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  10464. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  10465. while (dayStart < dayEnd)
  10466. {
  10467. string temp = "";
  10468. DataRow row = dt.NewRow();
  10469. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  10470. row["City"] = listhoteldata[i].City;
  10471. row["Hotel"] = listhoteldata[i].HotelName;
  10472. if (listhoteldata[i].SingleRoomCount > 0)
  10473. {
  10474. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  10475. }
  10476. if (listhoteldata[i].DoubleRoomCount > 0)
  10477. {
  10478. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  10479. }
  10480. if (listhoteldata[i].SuiteRoomCount > 0)
  10481. {
  10482. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  10483. }
  10484. if (listhoteldata[i].OtherRoomCount > 0)
  10485. {
  10486. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  10487. }
  10488. row["Room"] = temp;
  10489. dt.Rows.Add(row);
  10490. dayStart = dayStart.AddDays(1);
  10491. }
  10492. }
  10493. Dictionary<string, string> dic = new Dictionary<string, string>();
  10494. dic.Add("Dele", di.TeamName);
  10495. dic.Add("City", di.VisitCountry);
  10496. //模板路径
  10497. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  10498. //载入模板
  10499. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  10500. DocumentBuilder builder = new DocumentBuilder(doc);
  10501. foreach (var key in dic.Keys)
  10502. {
  10503. builder.MoveToBookmark(key);
  10504. builder.Write(dic[key]);
  10505. }
  10506. //获取word里所有表格
  10507. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10508. //获取所填表格的序数
  10509. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10510. var rowStart = tableOne.Rows[0]; //获取第1行
  10511. //循环赋值
  10512. for (int i = 0; i < dt.Rows.Count; i++)
  10513. {
  10514. builder.MoveToCell(0, i + 1, 0, 0);
  10515. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  10516. builder.MoveToCell(0, i + 1, 1, 0);
  10517. builder.Write(dt.Rows[i]["City"].ToString());
  10518. builder.MoveToCell(0, i + 1, 2, 0);
  10519. builder.Write(dt.Rows[i]["Hotel"].ToString());
  10520. builder.MoveToCell(0, i + 1, 3, 0);
  10521. builder.Write(dt.Rows[i]["Room"].ToString());
  10522. }
  10523. //删除多余行
  10524. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  10525. {
  10526. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  10527. }
  10528. string strFileName = di.TeamName + "酒店确认单.doc";
  10529. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  10530. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  10531. return Ok(JsonView(true, "成功", url));
  10532. }
  10533. catch (Exception ex)
  10534. {
  10535. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  10536. }
  10537. }
  10538. #endregion
  10539. #region 团组状态
  10540. /// <summary>
  10541. /// 团组状态列表 Page
  10542. /// </summary>
  10543. /// <param name="dto">团组列表请求dto</param>
  10544. /// <returns></returns>
  10545. [HttpPost]
  10546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10547. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  10548. {
  10549. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10550. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  10551. {
  10552. string sqlWhere = string.Empty;
  10553. if (dto.IsSure == 0) //未完成
  10554. {
  10555. sqlWhere += string.Format(@" And IsSure = 0");
  10556. }
  10557. else if (dto.IsSure == 1) //已完成
  10558. {
  10559. sqlWhere += string.Format(@" And IsSure = 1");
  10560. }
  10561. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  10562. {
  10563. string tj = dto.SearchCriteria;
  10564. 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}%')",
  10565. tj, tj, tj, tj, tj);
  10566. }
  10567. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  10568. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  10569. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  10570. From (
  10571. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  10572. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  10573. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  10574. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  10575. From Grp_DelegationInfo gdi
  10576. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  10577. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  10578. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  10579. Where gdi.IsDel = 0 {0}
  10580. ) temp ", sqlWhere);
  10581. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  10582. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  10583. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  10584. }
  10585. else
  10586. {
  10587. return Ok(JsonView(false, "查询失败"));
  10588. }
  10589. }
  10590. /// <summary>
  10591. /// 团组状态
  10592. /// 设置操作完成
  10593. /// </summary>
  10594. /// <param name="dto">团组列表请求dto</param>
  10595. /// <returns></returns>
  10596. [HttpPost]
  10597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10598. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  10599. {
  10600. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10601. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  10602. {
  10603. Id = dto.Id,
  10604. IsSure = 1
  10605. };
  10606. var result = await _sqlSugar.Updateable(_DelegationInfo)
  10607. .UpdateColumns(it => new { it.IsSure })
  10608. .WhereColumns(it => new { it.Id })
  10609. .ExecuteCommandAsync();
  10610. if (result > 0)
  10611. {
  10612. return Ok(JsonView(true, "操作完成!"));
  10613. }
  10614. return Ok(JsonView(false, "操作失败!"));
  10615. }
  10616. #endregion
  10617. #region 保险费用录入
  10618. /// <summary>
  10619. /// 根据团组Id查询保险费用列表
  10620. /// </summary>
  10621. /// <param name="dto"></param>
  10622. /// <returns></returns>
  10623. [HttpPost]
  10624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10625. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  10626. {
  10627. try
  10628. {
  10629. Result groupData = await _customersRep.CustomersByDiId(dto);
  10630. if (groupData.Code != 0)
  10631. {
  10632. return Ok(JsonView(false, groupData.Msg));
  10633. }
  10634. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10635. }
  10636. catch (Exception ex)
  10637. {
  10638. return Ok(JsonView(false, ex.Message));
  10639. }
  10640. }
  10641. /// <summary>
  10642. /// 根据保险费用Id查询保险费用详细
  10643. /// </summary>
  10644. /// <param name="dto"></param>
  10645. /// <returns></returns>
  10646. [HttpPost]
  10647. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10648. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  10649. {
  10650. try
  10651. {
  10652. Result groupData = await _customersRep.CustomersById(dto);
  10653. if (groupData.Code != 0)
  10654. {
  10655. return Ok(JsonView(false, groupData.Msg));
  10656. }
  10657. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10658. }
  10659. catch (Exception ex)
  10660. {
  10661. return Ok(JsonView(false, ex.Message));
  10662. }
  10663. }
  10664. /// <summary>
  10665. /// 保险费用录入页面初始化绑定
  10666. /// </summary>
  10667. /// <param name="dto"></param>
  10668. /// <returns></returns>
  10669. [HttpPost]
  10670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10671. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  10672. {
  10673. try
  10674. {
  10675. Result groupData = await _customersRep.CustomersInitialize(dto);
  10676. if (groupData.Code != 0)
  10677. {
  10678. return Ok(JsonView(false, groupData.Msg));
  10679. }
  10680. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10681. }
  10682. catch (Exception ex)
  10683. {
  10684. return Ok(JsonView(false, ex.Message));
  10685. }
  10686. }
  10687. /// <summary>
  10688. /// 保险费用操作(Status:1.新增,2.修改)
  10689. /// </summary>
  10690. /// <param name="dto"></param>
  10691. /// <returns></returns>
  10692. [HttpPost]
  10693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10694. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  10695. {
  10696. Result groupData = await _customersRep.OpCustomers(dto);
  10697. if (groupData.Code != 0)
  10698. {
  10699. return Ok(JsonView(false, groupData.Msg));
  10700. }
  10701. #region 应用推送
  10702. try
  10703. {
  10704. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10705. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10706. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10707. }
  10708. catch (Exception ex)
  10709. {
  10710. }
  10711. #endregion
  10712. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10713. }
  10714. /// <summary>
  10715. /// 保险文件上传
  10716. /// </summary>
  10717. /// <param name="file"></param>
  10718. /// <returns></returns>
  10719. [HttpPost]
  10720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10721. public async Task<IActionResult> UploadCus(IFormFile file)
  10722. {
  10723. try
  10724. {
  10725. if (file != null)
  10726. {
  10727. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10728. //文件名称
  10729. string projectFileName = file.FileName;
  10730. //上传的文件的路径
  10731. string filePath = "";
  10732. if (!Directory.Exists(fileDir))
  10733. {
  10734. Directory.CreateDirectory(fileDir);
  10735. }
  10736. //上传的文件的路径
  10737. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  10738. using (FileStream fs = System.IO.File.Create(filePath))
  10739. {
  10740. file.CopyTo(fs);
  10741. fs.Flush();
  10742. }
  10743. return Ok(JsonView(true, "上传成功!", projectFileName));
  10744. }
  10745. else
  10746. {
  10747. return Ok(JsonView(false, "上传失败!"));
  10748. }
  10749. }
  10750. catch (Exception ex)
  10751. {
  10752. return Ok(JsonView(false, "程序错误!"));
  10753. throw;
  10754. }
  10755. }
  10756. /// <summary>
  10757. /// 保险删除指定文件
  10758. /// </summary>
  10759. /// <param name="dto"></param>
  10760. /// <returns></returns>
  10761. [HttpPost]
  10762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10763. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  10764. {
  10765. try
  10766. {
  10767. string filePath = "";
  10768. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10769. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  10770. //int id = 0;
  10771. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  10772. // 删除该文件
  10773. try
  10774. {
  10775. System.IO.File.Delete(filePath);
  10776. 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()
  10777. {
  10778. Attachment = "",
  10779. }).ExecuteCommandAsync();
  10780. if (result != 0)
  10781. {
  10782. return Ok(JsonView(true, "成功!"));
  10783. }
  10784. else
  10785. {
  10786. return Ok(JsonView(false, "失败!"));
  10787. }
  10788. }
  10789. catch (Exception)
  10790. {
  10791. 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()
  10792. {
  10793. Attachment = "",
  10794. }).ExecuteCommandAsync();
  10795. if (result != 0)
  10796. {
  10797. return Ok(JsonView(true, "成功!"));
  10798. }
  10799. else
  10800. {
  10801. return Ok(JsonView(false, "失败!"));
  10802. }
  10803. }
  10804. }
  10805. catch (Exception ex)
  10806. {
  10807. return Ok(JsonView(false, "程序错误!"));
  10808. throw;
  10809. }
  10810. }
  10811. /// <summary>
  10812. /// 保险费用操作(删除)
  10813. /// </summary>
  10814. /// <param name="dto"></param>
  10815. /// <returns></returns>
  10816. [HttpPost]
  10817. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10818. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  10819. {
  10820. try
  10821. {
  10822. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  10823. if (!res)
  10824. {
  10825. return Ok(JsonView(false, "删除失败"));
  10826. }
  10827. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  10828. {
  10829. IsDel = 1,
  10830. DeleteUserId = dto.DeleteUserId,
  10831. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10832. }).ExecuteCommandAsync();
  10833. return Ok(JsonView(true, "删除成功!"));
  10834. }
  10835. catch (Exception ex)
  10836. {
  10837. return Ok(JsonView(false, "程序错误!"));
  10838. throw;
  10839. }
  10840. }
  10841. #endregion
  10842. #region 接团客户名单 PageId 104
  10843. /// <summary>
  10844. /// 接团客户名单
  10845. /// 迁移数据(慎用!)
  10846. /// </summary>
  10847. /// <param name="dto"></param>
  10848. /// <returns></returns>
  10849. [HttpPost]
  10850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10851. public async Task<IActionResult> PostTourClientListChange()
  10852. {
  10853. try
  10854. {
  10855. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  10856. //var groupClinetData1
  10857. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  10858. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  10859. int updateCount = 0;
  10860. if (oldOAClientList.Count > 0)
  10861. {
  10862. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  10863. _sqlSugar.BeginTran();
  10864. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  10865. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  10866. foreach (var item in oldOAClientList)
  10867. {
  10868. int comId = 0;
  10869. string format = "yyyy-MM-dd HH:mm:ss";
  10870. string data11 = "1990-01-01 00:00";
  10871. var data1 = IsValidDate(item.OPdate, format);
  10872. if (data1) data11 = item.OPdate;
  10873. //客户公司验证
  10874. if (!string.IsNullOrEmpty(item.Company))
  10875. {
  10876. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  10877. if (clientComInfo == null) // add
  10878. {
  10879. var addInfo = new Crm_CustomerCompany()
  10880. {
  10881. CompanyAbbreviation = "",
  10882. CompanyFullName = item.Company,
  10883. Address = "",
  10884. PostCodes = "",
  10885. LastedOpUserId = item.OPer,
  10886. LastedOpDt = Convert.ToDateTime(data11),
  10887. CreateUserId = item.OPer,
  10888. CreateTime = Convert.ToDateTime(data11),
  10889. IsDel = 0
  10890. };
  10891. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  10892. if (comId1 > 0) comId = comId1;
  10893. }
  10894. else comId = clientComInfo.Id;
  10895. }
  10896. //客户人员验证
  10897. int clientId = 0;
  10898. string name = item.LastName + item.Name;
  10899. if (!string.IsNullOrEmpty(name))
  10900. {
  10901. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  10902. if (clientInfo == null)
  10903. {
  10904. DateTime? dateTime = null;
  10905. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  10906. if (isDt) dateTime = birthDayDt;
  10907. var addInfo1 = new Crm_DeleClient()
  10908. {
  10909. CrmCompanyId = comId,
  10910. DiId = -1,
  10911. LastName = item.LastName,
  10912. FirstName = item.Name,
  10913. OldName = "",
  10914. Pinyin = item.Pinyin,
  10915. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  10916. Marriage = 0,
  10917. Phone = item.Phone,
  10918. Job = item.Job,
  10919. BirthDay = dateTime
  10920. };
  10921. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  10922. if (clientId1 > 0) clientId = clientId1;
  10923. }
  10924. else clientId = clientInfo.Id;
  10925. }
  10926. if (clientId < 1)
  10927. {
  10928. continue;
  10929. }
  10930. int airType = 0;
  10931. if (item.AirType == "超经舱") airType = 459;
  10932. else if (item.AirType == "公务舱") airType = 458;
  10933. else if (item.AirType == "经济舱") airType = 460;
  10934. else if (item.AirType == "其他") airType = 565;
  10935. else if (item.AirType == "头等舱") airType = 457;
  10936. var _TourClientListEntity = new Grp_TourClientList()
  10937. {
  10938. DiId = item.Diid,
  10939. ClientId = clientId,
  10940. CreateUserId = item.OPer,
  10941. CreateTime = Convert.ToDateTime(data11),
  10942. Remark = item.Remark,
  10943. IsDel = item.Isdel,
  10944. ShippingSpaceTypeId = airType,
  10945. ShippingSpaceSpecialNeeds = item.AirRemark,
  10946. HotelSpecialNeeds = item.RoomType
  10947. };
  10948. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  10949. if (_TourClientList > 0)
  10950. {
  10951. updateCount++;
  10952. }
  10953. }
  10954. _sqlSugar.CommitTran();
  10955. }
  10956. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  10957. }
  10958. catch (Exception ex)
  10959. {
  10960. _sqlSugar.RollbackTran();
  10961. return Ok(JsonView(false, ex.Message));
  10962. }
  10963. return Ok(JsonView(true));
  10964. }
  10965. private bool IsValidDate(string dateString, string format)
  10966. {
  10967. DateTime dateValue;
  10968. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  10969. return valid;
  10970. }
  10971. /// <summary>
  10972. /// 接团客户名单
  10973. /// 根据团组Id查询List
  10974. /// </summary>
  10975. /// <param name="dto"></param>
  10976. /// <returns></returns>
  10977. [HttpPost]
  10978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10979. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  10980. {
  10981. #region 参数验证
  10982. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  10983. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10984. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  10985. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10986. #region 页面操作权限验证
  10987. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10988. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10989. #endregion
  10990. #endregion
  10991. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  10992. if (viewData.Code != 0)
  10993. {
  10994. return Ok(JsonView(false, viewData.Msg));
  10995. }
  10996. return Ok(JsonView(viewData.Data));
  10997. }
  10998. /// <summary>
  10999. /// 接团客户名单
  11000. /// 基础数据 Init
  11001. /// </summary>
  11002. /// <param name="_dto"></param>
  11003. /// <returns></returns>
  11004. [HttpPost]
  11005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11006. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  11007. {
  11008. #region 参数验证
  11009. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11010. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11011. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11012. #region 页面操作权限验证
  11013. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11014. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11015. #endregion
  11016. #endregion
  11017. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  11018. if (viewData.Code != 0)
  11019. {
  11020. return Ok(JsonView(false, viewData.Msg));
  11021. }
  11022. return Ok(JsonView(viewData.Data));
  11023. }
  11024. /// <summary>
  11025. /// 接团客户名单
  11026. /// 根据 Id查询 Details
  11027. /// </summary>
  11028. /// <param name="_dto"></param>
  11029. /// <returns></returns>
  11030. [HttpPost]
  11031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11032. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  11033. {
  11034. #region 参数验证
  11035. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11036. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11037. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11038. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11039. #region 页面操作权限验证
  11040. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11041. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11042. #endregion
  11043. #endregion
  11044. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  11045. if (viewData.Code != 0)
  11046. {
  11047. return Ok(JsonView(false, viewData.Msg));
  11048. }
  11049. return Ok(JsonView(viewData.Data));
  11050. }
  11051. /// <summary>
  11052. /// 接团客户名单
  11053. /// Add Or Edit
  11054. /// </summary>
  11055. /// <param name="_dto"></param>
  11056. /// <returns></returns>
  11057. [HttpPost]
  11058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11059. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  11060. {
  11061. #region 参数验证
  11062. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11063. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11064. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11065. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11066. #region 页面操作权限验证
  11067. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11068. if (_dto.Id == 0) //添加
  11069. {
  11070. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11071. }
  11072. else if (_dto.Id >= 0) //修改
  11073. {
  11074. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  11075. }
  11076. #endregion
  11077. #endregion
  11078. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  11079. if (viewData.Code != 0)
  11080. {
  11081. return Ok(JsonView(false, viewData.Msg));
  11082. }
  11083. return Ok(JsonView(true));
  11084. }
  11085. /// <summary>
  11086. /// 接团客户名单
  11087. /// AddMultiple(添加多个)
  11088. /// </summary>
  11089. /// <param name="_dto"></param>
  11090. /// <returns></returns>
  11091. [HttpPost]
  11092. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11093. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  11094. {
  11095. #region 参数验证
  11096. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11097. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11098. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11099. #region 页面操作权限验证
  11100. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11101. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11102. #endregion
  11103. #endregion
  11104. var viewData = await _tourClientListRep._AddMultiple(_dto);
  11105. if (viewData.Code != 0)
  11106. {
  11107. return Ok(JsonView(false, viewData.Msg));
  11108. }
  11109. return Ok(JsonView(true));
  11110. }
  11111. /// <summary>
  11112. /// 接团客户名单
  11113. /// Del
  11114. /// </summary>
  11115. /// <param name="_dto"></param>
  11116. /// <returns></returns>
  11117. [HttpPost]
  11118. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11119. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  11120. {
  11121. #region 参数验证
  11122. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11123. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11124. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11125. #region 页面操作权限验证
  11126. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11127. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  11128. #endregion
  11129. #endregion
  11130. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  11131. if (viewData.Code != 0)
  11132. {
  11133. return Ok(JsonView(false, viewData.Msg));
  11134. }
  11135. return Ok(JsonView(true));
  11136. }
  11137. /// <summary>
  11138. /// 接团客户名单
  11139. /// 文件下载 客户名单
  11140. /// </summary>
  11141. /// <param name="_dto"></param>
  11142. /// <returns></returns>
  11143. [HttpPost]
  11144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11145. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  11146. {
  11147. #region 参数验证
  11148. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11149. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11150. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  11151. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11152. #region 页面操作权限验证
  11153. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11154. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11155. #endregion
  11156. #endregion
  11157. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  11158. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  11159. From Grp_TourClientList tcl
  11160. Left Join
  11161. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  11162. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  11163. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  11164. From Crm_DeleClient dc
  11165. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  11166. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  11167. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  11168. Where dc.IsDel = 0) temp
  11169. On temp.DcId =tcl.ClientId
  11170. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  11171. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  11172. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  11173. //载入模板
  11174. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  11175. if (_dto.Language == 1)
  11176. {
  11177. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  11178. }
  11179. //载入模板
  11180. var doc = new Document(tempPath);
  11181. DocumentBuilder builder = new DocumentBuilder(doc);
  11182. //获取word里所有表格
  11183. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11184. //获取所填表格的序数
  11185. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11186. var rowStart = tableOne.Rows[0]; //获取第1行
  11187. if (_dto.Language == 0)
  11188. {
  11189. //循环赋值
  11190. for (int i = 0; i < DcList.Count; i++)
  11191. {
  11192. builder.MoveToCell(0, i + 1, 0, 0);
  11193. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  11194. builder.MoveToCell(0, i + 1, 1, 0);
  11195. int sex = DcList[i].Sex;
  11196. string sexStr = string.Empty;
  11197. if (sex == 0) sexStr = "男";
  11198. else if (sex == 1) sexStr = "女";
  11199. else sexStr = "未设置";
  11200. builder.Write(sexStr);
  11201. builder.MoveToCell(0, i + 1, 2, 0);
  11202. string birthDay = DcList[i].BirthDay;
  11203. string birthDayStr = string.Empty;
  11204. if (!string.IsNullOrEmpty(birthDay))
  11205. {
  11206. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  11207. }
  11208. builder.Write(birthDayStr);
  11209. builder.MoveToCell(0, i + 1, 3, 0);
  11210. string company = "";
  11211. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11212. {
  11213. company = DcList[i].CompanyFullName.ToString();
  11214. }
  11215. builder.Write(company);
  11216. builder.MoveToCell(0, i + 1, 4, 0);
  11217. builder.Write(DcList[i].Job);
  11218. }
  11219. }
  11220. else if (_dto.Language == 1)
  11221. {
  11222. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  11223. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  11224. List<string> transArrayStr = new List<string>();
  11225. string transStrRes1 = "";
  11226. for (int i = 0; i < DcList.Count; i++)
  11227. {
  11228. var dc = DcList[i];
  11229. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  11230. if (dc.Job.Equals("暂无")) dc.Job = "-";
  11231. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  11232. if (DcList.Count - 1 == i) transStrRes1 += str1;
  11233. else transStrRes1 += $"{str1}|";
  11234. }
  11235. //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";
  11236. string transStrRes = "";
  11237. if (transStrRes1.Length > 0 )
  11238. {
  11239. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  11240. }
  11241. //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
  11242. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  11243. //List<string> transArray = new List<string> { };
  11244. List<TranslateInfo> transArray = new List<TranslateInfo>();
  11245. if (transStrRes.Contains("|"))
  11246. {
  11247. string[] transArray1 = transStrRes.Split('|');
  11248. if (transArray1.Length > 0)
  11249. {
  11250. foreach (var item in transArray1)
  11251. {
  11252. if (item.Contains("&"))
  11253. {
  11254. string[] transArray2 = item.Split('&');
  11255. int index = 0;
  11256. string companyName = "", job = "";
  11257. if (transArray2.Length > 0)
  11258. {
  11259. bool success = int.TryParse(transArray2[0].Trim(), out index);
  11260. if (1 < transArray2.Length) companyName = transArray2[1];
  11261. if (2 < transArray2.Length) job = transArray2[2];
  11262. }
  11263. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  11264. }
  11265. }
  11266. }
  11267. }
  11268. //循环赋值
  11269. for (int i = 0; i < DcList.Count; i++)
  11270. {
  11271. string PYName = "";
  11272. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  11273. {
  11274. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  11275. string PY_First = DcList[i].Pinyin.Split('/')[1];
  11276. PYName = PY_First + " " + PY_Last;
  11277. }
  11278. else
  11279. {
  11280. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  11281. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  11282. PYName = PY_First + " " + PY_Last;
  11283. }
  11284. builder.MoveToCell(0, i + 1, 0, 0);
  11285. builder.Write(PYName);
  11286. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  11287. builder.MoveToCell(0, i + 1, 1, 0);
  11288. builder.Write(sex);
  11289. DateTime birthDt;
  11290. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  11291. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  11292. builder.MoveToCell(0, i + 1, 2, 0);
  11293. builder.Write(birthday);
  11294. string company = string.Empty,job = string.Empty;
  11295. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  11296. if (dcTransInfo != null)
  11297. {
  11298. company = dcTransInfo.CompanyName;
  11299. job = dcTransInfo.Job;
  11300. }
  11301. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11302. {
  11303. //查询对照表
  11304. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  11305. if (tempCec != null)
  11306. {
  11307. company = tempCec.enName;
  11308. }
  11309. //翻译
  11310. else
  11311. {
  11312. }
  11313. }
  11314. builder.MoveToCell(0, i + 1, 3, 0);
  11315. builder.Write(company);
  11316. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  11317. {
  11318. //查询对照表
  11319. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  11320. if (tempPec != null)
  11321. {
  11322. job = tempPec.enName;
  11323. }
  11324. //翻译
  11325. else
  11326. {
  11327. }
  11328. }
  11329. builder.MoveToCell(0, i + 1, 4, 0);
  11330. builder.Write(job);
  11331. }
  11332. }
  11333. //删除多余行
  11334. while (tableOne.Rows.Count > DcList.Count + 1)
  11335. {
  11336. tableOne.Rows.RemoveAt(DcList.Count + 1);
  11337. }
  11338. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  11339. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  11340. doc.Save(fileDir);
  11341. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  11342. return Ok(JsonView(true, "操作成功!", Url));
  11343. }
  11344. private class TranslateInfo
  11345. {
  11346. public int Index { get; set; }
  11347. public string CompanyName { get; set; }
  11348. public string Job { get; set; }
  11349. }
  11350. #endregion
  11351. #region 团组倒推表
  11352. /// <summary>
  11353. /// 倒推表基础数据
  11354. /// Init
  11355. /// </summary>
  11356. /// <param name="dto"></param>
  11357. /// <returns></returns>
  11358. [HttpPost]
  11359. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11360. public async Task<IActionResult> PostInvertedListInit()
  11361. {
  11362. var viewData = await _invertedListRep._Init();
  11363. if (viewData.Code != 0)
  11364. {
  11365. return Ok(JsonView(false, viewData.Msg));
  11366. }
  11367. return Ok(JsonView(viewData.Data));
  11368. }
  11369. /// <summary>
  11370. /// 倒推表
  11371. /// Info
  11372. /// </summary>
  11373. /// <param name="dto"></param>
  11374. /// <returns></returns>
  11375. [HttpPost]
  11376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11377. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  11378. {
  11379. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  11380. if (viewData.Code != 0)
  11381. {
  11382. return Ok(JsonView(false, viewData.Msg));
  11383. }
  11384. return Ok(JsonView(viewData.Data));
  11385. }
  11386. /// <summary>
  11387. /// 倒推表
  11388. /// Create
  11389. /// </summary>
  11390. /// <param name="dto"></param>
  11391. /// <returns></returns>
  11392. [HttpPost]
  11393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11394. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  11395. {
  11396. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  11397. if (viewData.Code != 0)
  11398. {
  11399. return Ok(JsonView(false, viewData.Msg));
  11400. }
  11401. return Ok(JsonView(viewData.Data));
  11402. }
  11403. /// <summary>
  11404. /// 倒推表
  11405. /// Update
  11406. /// </summary>
  11407. /// <param name="dto"></param>
  11408. /// <returns></returns>
  11409. [HttpPost]
  11410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11411. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  11412. {
  11413. var viewData = await _invertedListRep._Update(dto);
  11414. if (viewData.Code != 0)
  11415. {
  11416. return Ok(JsonView(false, viewData.Msg));
  11417. }
  11418. return Ok(JsonView(viewData.Data));
  11419. }
  11420. /// <summary>
  11421. /// 倒推表
  11422. /// File Download
  11423. /// </summary>
  11424. /// <param name="dto"></param>
  11425. /// <returns></returns>
  11426. [HttpPost]
  11427. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11428. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  11429. {
  11430. var info2 = await _invertedListRep._Info(1, dto.DiId);
  11431. if (info2.Code != 0)
  11432. {
  11433. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  11434. }
  11435. var info1 = info2.Data as InvertedListInfoView;
  11436. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  11437. string teamName = "";
  11438. if (info != null) teamName = info.TeamName;
  11439. //载入模板
  11440. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  11441. DocumentBuilder builder = new DocumentBuilder(doc);
  11442. //利用键值对存放数据
  11443. Dictionary<string, string> dic = new Dictionary<string, string>();
  11444. dic.Add("TeamName", teamName);
  11445. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  11446. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  11447. dic.Add("BPRemark", info1.ApprovalDataRemark);
  11448. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  11449. dic.Add("SQRemark", info1.ApprovalRemark);
  11450. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  11451. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  11452. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  11453. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  11454. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  11455. dic.Add("QZRemark", info1.VisaInformationRemark);
  11456. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  11457. dic.Add("SQQZRemark", info1.SendVisaRemark);
  11458. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  11459. dic.Add("CQRemark", info1.IssueVisaRemark);
  11460. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  11461. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  11462. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  11463. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  11464. #region 填充word模板书签内容
  11465. foreach (var key in dic.Keys)
  11466. {
  11467. builder.MoveToBookmark(key);
  11468. builder.Write(dic[key]);
  11469. }
  11470. #endregion
  11471. var fileDir = AppSettingsHelper.Get("WordBasePath");
  11472. string fileName = $"{teamName}团出行准备流程表.doc";
  11473. string filePath = fileDir + $@"InvertedList/{fileName}";
  11474. doc.Save(filePath);
  11475. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  11476. return Ok(JsonView(true, "操作成功!", Url));
  11477. }
  11478. #endregion
  11479. #region 三公签证费用(签证费、代办费)
  11480. /// <summary>
  11481. /// 三公签证费用(签证费、代办费)
  11482. /// List
  11483. /// </summary>
  11484. /// <returns></returns>
  11485. [HttpPost]
  11486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11487. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  11488. {
  11489. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  11490. if (_view.Code != 0)
  11491. {
  11492. return Ok(JsonView(false, _view.Msg));
  11493. }
  11494. return Ok(JsonView(true, "操作成功!", _view.Data));
  11495. }
  11496. /// <summary>
  11497. /// 三公签证费用(签证费、代办费)
  11498. /// Add Or Update
  11499. /// </summary>
  11500. /// <returns></returns>
  11501. [HttpPost]
  11502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11503. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  11504. {
  11505. var _view = await _visaFeeInfoRep._Update(_dto);
  11506. if (_view.Code != 0)
  11507. {
  11508. return Ok(JsonView(false, _view.Msg));
  11509. }
  11510. return Ok(JsonView(true, _view.Msg));
  11511. }
  11512. #endregion
  11513. #region 酒店询价
  11514. /// <summary>
  11515. /// 酒店询价
  11516. /// Init
  11517. /// </summary>
  11518. /// <param name="dto"></param>
  11519. /// <returns></returns>
  11520. [HttpPost]
  11521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11522. public async Task<IActionResult> PostHotelInquiryInit()
  11523. {
  11524. var res = await _hotelInquiryRep._Init();
  11525. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11526. return Ok(JsonView(true, res.Msg, res.Data));
  11527. }
  11528. /// <summary>
  11529. /// 酒店询价
  11530. /// page Item
  11531. /// </summary>
  11532. /// <param name="_dto"></param>
  11533. /// <returns></returns>
  11534. [HttpPost]
  11535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11536. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  11537. {
  11538. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  11539. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11540. var view = res.Data as PageDataViewBase;
  11541. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  11542. }
  11543. /// <summary>
  11544. /// 酒店询价
  11545. /// info
  11546. /// </summary>
  11547. /// <param name="_dto"></param>
  11548. /// <returns></returns>
  11549. [HttpPost]
  11550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11551. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  11552. {
  11553. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  11554. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11555. return Ok(JsonView(true, res.Msg, res.Data));
  11556. }
  11557. /// <summary>
  11558. /// 酒店询价
  11559. /// Add Or Edit
  11560. /// </summary>
  11561. /// <param name="_dto"></param>
  11562. /// <returns></returns>
  11563. [HttpPost]
  11564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11565. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  11566. {
  11567. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  11568. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11569. return Ok(JsonView(true, res.Msg, res.Data));
  11570. }
  11571. /// <summary>
  11572. /// 酒店询价
  11573. /// Del
  11574. /// </summary>
  11575. /// <param name="_dto"></param>
  11576. /// <returns></returns>
  11577. [HttpPost]
  11578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11579. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  11580. {
  11581. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  11582. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11583. return Ok(JsonView(true, res.Msg, res.Data));
  11584. }
  11585. #endregion
  11586. #region 下载匹配op行程单
  11587. /// <summary>
  11588. /// 匹配op行程单
  11589. /// Init
  11590. /// </summary>
  11591. /// <param name="dto">团组列表请求dto</param>
  11592. /// <returns></returns>
  11593. [HttpPost]
  11594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11595. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  11596. {
  11597. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11598. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11599. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  11600. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  11601. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  11602. .Where(it => it.IsDel == 0)
  11603. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  11604. .OrderByDescending(it => it.CreateUserId)
  11605. .ToList();
  11606. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  11607. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11608. var diids = groupInfos.Select(it => it.Id).ToList();
  11609. List<string> countrys = new List<string>();
  11610. foreach (var item in country)
  11611. {
  11612. var data = _groupRepository.FormartTeamName(item);
  11613. var dataArray = _groupRepository.GroupSplitCountry(data);
  11614. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  11615. }
  11616. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  11617. List<string> areaArray = new List<string>(); //GetGroupCityLine
  11618. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  11619. foreach (var item in areaItem)
  11620. {
  11621. string areaStr = item.Value;
  11622. if (!string.IsNullOrEmpty(areaStr))
  11623. {
  11624. string[] str1 = areaStr.Split("-");
  11625. if (str1.Length > 0)
  11626. {
  11627. areaArray.AddRange(str1);
  11628. }
  11629. }
  11630. }
  11631. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  11632. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  11633. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  11634. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  11635. .ToList();
  11636. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  11637. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  11638. .Where(it => countriesIds.Contains(it.Id))
  11639. .Select(it => new { it.Id, Name = it.Name_CN })
  11640. .ToList();
  11641. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  11642. .Select(it => it.TeamName).ToList();
  11643. stopwatch.Stop();
  11644. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  11645. }
  11646. ///// <summary>
  11647. ///// 匹配op行程单
  11648. ///// Init 查询区域数据
  11649. ///// </summary>
  11650. ///// <param name="dto">团组列表请求dto</param>
  11651. ///// <returns></returns>
  11652. //[HttpPost]
  11653. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11654. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  11655. //{
  11656. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11657. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  11658. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  11659. // if (string.IsNullOrEmpty(countriesDataStr))
  11660. // {
  11661. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  11662. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  11663. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  11664. // }
  11665. // else
  11666. // {
  11667. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  11668. // }
  11669. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  11670. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  11671. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  11672. // List<dynamic> childList = new List<dynamic>();
  11673. // int parentId = dto.CountriesId;
  11674. // if (provinceData.Count > 1)
  11675. // {
  11676. // foreach (var item1 in provinceData)
  11677. // {
  11678. // List<dynamic> childList1 = new List<dynamic>();
  11679. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  11680. // foreach (var item2 in citiesData1)
  11681. // {
  11682. // List<dynamic> childList2 = new List<dynamic>();
  11683. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11684. // foreach (var item3 in countiesData1)
  11685. // {
  11686. // childList2.Add(new
  11687. // {
  11688. // id = item3.Id,
  11689. // parentId = item2.Id,
  11690. // level = "district",
  11691. // name = item3.Name_CN,
  11692. // });
  11693. // }
  11694. // childList1.Add(new
  11695. // {
  11696. // id = item2.Id,
  11697. // parentId = item1.Id,
  11698. // level = "city",
  11699. // name = item2.Name_CN,
  11700. // childList = childList2
  11701. // });
  11702. // }
  11703. // childList.Add(new
  11704. // {
  11705. // id = item1.Id,
  11706. // parentId = parentId,
  11707. // level = "province",
  11708. // name = item1.Name_CN,
  11709. // childList = childList1
  11710. // });
  11711. // }
  11712. // //城市
  11713. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  11714. // foreach (var item2 in citiesData2)
  11715. // {
  11716. // List<dynamic> childList22 = new List<dynamic>();
  11717. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11718. // foreach (var item3 in countiesData1)
  11719. // {
  11720. // childList22.Add(new
  11721. // {
  11722. // id = item3.Id,
  11723. // parentId = item2.Id,
  11724. // level = "district",
  11725. // name = item3.Name_CN,
  11726. // });
  11727. // }
  11728. // childList.Add(new
  11729. // {
  11730. // id = item2.Id,
  11731. // parentId = parentId,
  11732. // level = "city",
  11733. // name = item2.Name_CN,
  11734. // childList = childList22
  11735. // });
  11736. // }
  11737. // }
  11738. // else
  11739. // {
  11740. // foreach (var item2 in citiesData)
  11741. // {
  11742. // string cname = item2.Name_CN;
  11743. // List<dynamic> childList1 = new List<dynamic>();
  11744. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11745. // foreach (var item3 in countiesData1)
  11746. // {
  11747. // childList1.Add(new
  11748. // {
  11749. // Id = item3.Id,
  11750. // parentId = item2.Id,
  11751. // level = "district",
  11752. // name = item3.Name_CN
  11753. // });
  11754. // }
  11755. // childList.Add(new
  11756. // {
  11757. // id = item2.Id,
  11758. // parentId = parentId,
  11759. // level = "city",
  11760. // name = item2.Name_CN,
  11761. // childList = childList1
  11762. // });
  11763. // }
  11764. // }
  11765. // stopwatch.Stop();
  11766. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  11767. //}
  11768. /// <summary>
  11769. /// 匹配op行程单
  11770. /// 接团信息列表 Page
  11771. /// </summary>
  11772. /// <param name="dto">团组列表请求dto</param>
  11773. /// <returns></returns>
  11774. [HttpPost]
  11775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11776. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  11777. {
  11778. var swatch = new Stopwatch();
  11779. swatch.Start();
  11780. #region 参数验证
  11781. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11782. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11783. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11784. #region 页面操作权限验证
  11785. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11786. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  11787. #endregion
  11788. #endregion
  11789. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11790. {
  11791. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  11792. string sqlWhere = "";
  11793. if (!string.IsNullOrEmpty(dto.Country))
  11794. {
  11795. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  11796. }
  11797. if (!string.IsNullOrEmpty(dto.Area))
  11798. {
  11799. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  11800. }
  11801. if (!string.IsNullOrEmpty(dto.TeamName))
  11802. {
  11803. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  11804. }
  11805. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  11806. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  11807. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  11808. swatch.Stop();
  11809. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  11810. }
  11811. else
  11812. {
  11813. return Ok(JsonView(false, "查询失败"));
  11814. }
  11815. }
  11816. /// <summary>
  11817. /// 匹配op行程单
  11818. /// 行程单下载
  11819. /// </summary>
  11820. /// <param name="dto">团组列表请求dto</param>
  11821. /// <returns></returns>
  11822. [HttpPost]
  11823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11824. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  11825. {
  11826. #region 参数验证
  11827. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11828. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11829. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11830. #region 页面操作权限验证
  11831. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11832. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  11833. #endregion
  11834. #endregion
  11835. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11836. {
  11837. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  11838. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  11839. }
  11840. else
  11841. {
  11842. return Ok(JsonView(false, "下载失败!"));
  11843. }
  11844. }
  11845. #endregion
  11846. #region 国家信息 数据 注释
  11847. //[HttpPost]
  11848. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  11849. //{
  11850. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  11851. // foreach (var item in dto)
  11852. // {
  11853. // infos.Add(new Grp_GroupsTaskAssignment()
  11854. // {
  11855. // DIId = item,
  11856. // CTId = 82,
  11857. // UId = 248,
  11858. // IsEnable = 1,
  11859. // CreateUserId = 233,
  11860. // CreateTime = DateTime.Now,
  11861. // IsDel = 0
  11862. // });
  11863. // infos.Add(new Grp_GroupsTaskAssignment()
  11864. // {
  11865. // DIId = item,
  11866. // CTId = 82,
  11867. // UId = 286,
  11868. // IsEnable = 1,
  11869. // CreateUserId = 233,
  11870. // CreateTime = DateTime.Now,
  11871. // IsDel = 0
  11872. // });
  11873. // }
  11874. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  11875. // return Ok("操作成功");
  11876. //}
  11877. //public class paramJsonDto
  11878. //{
  11879. // public List<CountriesInfo> str { get; set; }
  11880. //}
  11881. //[HttpPost]
  11882. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  11883. //{
  11884. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  11885. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  11886. // List<Sys_Cities> cities = new List<Sys_Cities>();
  11887. // List<Sys_Cities> districts = new List<Sys_Cities>();
  11888. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11889. // _sqlSugar.BeginTran();
  11890. // int countitiesIndex = 0;
  11891. // foreach (var item in dto.str)
  11892. // {
  11893. // dynamic data = item.c;
  11894. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  11895. // if (data != null)
  11896. // {
  11897. // countitiesIndex++;
  11898. // foreach (var item1 in data)
  11899. // {
  11900. // string cnname = item1.cn;
  11901. // string enname = item1.en;
  11902. // Sys_Cities provinceInfo = new Sys_Cities()
  11903. // {
  11904. // CountriesId = countriesId,
  11905. // Name_CN = cnname,
  11906. // Name_EN = enname,
  11907. // ParentId = 0,
  11908. // IsCapital = 1,
  11909. // CreateUserId = 208,
  11910. // CreateTime = DateTime.Now,
  11911. // IsDel = 0
  11912. // };
  11913. // if (item1.lv == "province") //省份
  11914. // {
  11915. // provinceInfo.Level = 1;
  11916. // int provinceId = 0;
  11917. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  11918. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  11919. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11920. // var data1 = item1.c;
  11921. // foreach (var item2 in data1)
  11922. // {
  11923. // if (item2.lv == "city")
  11924. // {
  11925. // string citycnname = item2.cn;
  11926. // string cityenname = item2.en;
  11927. // Sys_Cities cityInfo = new Sys_Cities()
  11928. // {
  11929. // CountriesId = countriesId,
  11930. // ParentId = provinceId,
  11931. // Level = 2,
  11932. // Name_CN = citycnname,
  11933. // Name_EN = cityenname,
  11934. // IsCapital = 1,
  11935. // CreateUserId = 208,
  11936. // CreateTime = DateTime.Now,
  11937. // IsDel = 0
  11938. // };
  11939. // if (item2.c != null)
  11940. // {
  11941. // int cityId = 0;
  11942. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  11943. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11944. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  11945. // foreach (var item3 in item2.c)
  11946. // {
  11947. // if (item3.lv == "district")
  11948. // {
  11949. // var districtInfo = new Sys_Cities()
  11950. // {
  11951. // CountriesId = countriesId,
  11952. // Name_CN = item3.cn,
  11953. // Name_EN = item3.en,
  11954. // Level = 3,
  11955. // ParentId = cityId,
  11956. // IsCapital = 1,
  11957. // CreateUserId = 208,
  11958. // CreateTime = DateTime.Now,
  11959. // IsDel = 0
  11960. // };
  11961. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11962. // //{
  11963. // districts.Add(districtInfo);
  11964. // //}
  11965. // }
  11966. // }
  11967. // }
  11968. // else
  11969. // {
  11970. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  11971. // //{
  11972. // cities.Add(cityInfo);
  11973. // //}
  11974. // }
  11975. // }
  11976. // }
  11977. // }
  11978. // else if (item1.lv == "city")//城市
  11979. // {
  11980. // provinceInfo.Level = 2;
  11981. // if (item1.c != null)
  11982. // {
  11983. // int cityId = 0;
  11984. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  11985. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11986. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11987. // foreach (var item3 in item1.c)
  11988. // {
  11989. // if (item3.lv == "district")
  11990. // {
  11991. // var districtInfo = new Sys_Cities()
  11992. // {
  11993. // CountriesId = countriesId,
  11994. // Name_CN = item3.cn,
  11995. // Name_EN = item3.en,
  11996. // Level = 3,
  11997. // ParentId = cityId,
  11998. // IsCapital = 1,
  11999. // CreateUserId = 208,
  12000. // CreateTime = DateTime.Now,
  12001. // IsDel = 0
  12002. // };
  12003. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12004. // //{
  12005. // districts.Add(districtInfo);
  12006. // //}
  12007. // }
  12008. // }
  12009. // }
  12010. // else
  12011. // {
  12012. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  12013. // //{
  12014. // cities.Add(provinceInfo);
  12015. // //}
  12016. // }
  12017. // }
  12018. // }
  12019. // }
  12020. // }
  12021. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  12022. // cities = cities.Distinct().ToList();
  12023. // districts = districts.Distinct().ToList();
  12024. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  12025. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  12026. // cities.AddRange(districts);
  12027. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  12028. // //_sqlSugar.RollbackTran();
  12029. // _sqlSugar.CommitTran();
  12030. // return Ok(JsonView(false, "操作成功!"));
  12031. //}
  12032. //[HttpPost]
  12033. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  12034. //{
  12035. // List<CountitiesInfo> infos = dto.MyProperty;
  12036. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  12037. // _sqlSugar.BeginTran();
  12038. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12039. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  12040. // foreach (var item in infos)
  12041. // {
  12042. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  12043. // if (countryInfo != null)
  12044. // {
  12045. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  12046. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  12047. // if (cityInfo1 != null)
  12048. // {
  12049. // cityInfo1.IsCapital = 0;
  12050. // cityInfos.Add(cityInfo1);
  12051. // }
  12052. // }
  12053. // }
  12054. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  12055. // .UpdateColumns(it => it.IsCapital)
  12056. // .WhereColumns(it => it.Id)
  12057. // .ExecuteCommand();
  12058. // //_sqlSugar.RollbackTran();
  12059. // _sqlSugar.CommitTran();
  12060. // return Ok(JsonView(false, "操作成功!"));
  12061. //}
  12062. //public class CounrtiesDto
  12063. //{
  12064. // public List<CountitiesInfo> MyProperty { get; set; }
  12065. //}
  12066. //public class CountitiesInfo
  12067. //{
  12068. // /// <summary>
  12069. // /// 圣约翰
  12070. // /// </summary>
  12071. // public string capital_name_chinese { get; set; }
  12072. // /// <summary>
  12073. // ///
  12074. // /// </summary>
  12075. // public string capital_name { get; set; }
  12076. // /// <summary>
  12077. // ///
  12078. // /// </summary>
  12079. // public string country_type { get; set; }
  12080. // /// <summary>
  12081. // /// 安提瓜和巴布达
  12082. // /// </summary>
  12083. // public string country_name_chinese { get; set; }
  12084. // /// <summary>
  12085. // /// 安提瓜和巴布达
  12086. // /// </summary>
  12087. // public string country_name_chinese_short { get; set; }
  12088. // /// <summary>
  12089. // /// 安提瓜和巴布达
  12090. // /// </summary>
  12091. // public string country_name_chinese_UN { get; set; }
  12092. // /// <summary>
  12093. // ///
  12094. // /// </summary>
  12095. // public string country_name_english_abbreviation { get; set; }
  12096. // /// <summary>
  12097. // ///
  12098. // /// </summary>
  12099. // public string country_name_english_formal { get; set; }
  12100. // /// <summary>
  12101. // ///
  12102. // /// </summary>
  12103. // public string country_name_english_UN { get; set; }
  12104. // /// <summary>
  12105. // ///
  12106. // /// </summary>
  12107. // public string continent_name { get; set; }
  12108. // /// <summary>
  12109. // ///
  12110. // /// </summary>
  12111. // public string subregion_name { get; set; }
  12112. // /// <summary>
  12113. // ///
  12114. // /// </summary>
  12115. // public string country_code2 { get; set; }
  12116. // /// <summary>
  12117. // ///
  12118. // /// </summary>
  12119. // public string country_code3 { get; set; }
  12120. // /// <summary>
  12121. // ///
  12122. // /// </summary>
  12123. // public string phone_code { get; set; }
  12124. //}
  12125. //public class CountriesInfo : BasicInfo
  12126. //{
  12127. // public List<CitiesInfo> c { get; set; }
  12128. //}
  12129. //public class CitiesInfo : BasicInfo
  12130. //{
  12131. // public List<AreaInfo> c { get; set; }
  12132. //}
  12133. //public class AreaInfo : BasicInfo
  12134. //{
  12135. // public List<AreaInfo> c { get; set; }
  12136. //}
  12137. //public class BasicInfo
  12138. //{
  12139. // public string code { get; set; }
  12140. // public string cn { get; set; }
  12141. // public string lv { get; set; }
  12142. // public string en { get; set; }
  12143. //}
  12144. #endregion
  12145. #region 查看邀请方
  12146. /// <summary>
  12147. /// 查看邀请方
  12148. /// 邀请方信息 Init
  12149. /// </summary>
  12150. /// <param name="dto"></param>
  12151. /// <returns></returns>
  12152. [HttpPost]
  12153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12154. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  12155. {
  12156. string sqlWhere = string.Empty;
  12157. if (!string.IsNullOrEmpty(dto.Search))
  12158. {
  12159. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  12160. }
  12161. string sql = string.Format($@"Select
  12162. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  12163. Id,
  12164. UnitName
  12165. From Res_InvitationOfficialActivityData
  12166. Where IsDel = 0
  12167. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  12168. RefAsync<int> total = 0;
  12169. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12170. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  12171. }
  12172. /// <summary>
  12173. /// 查看邀请方
  12174. /// 国家信息 Init
  12175. /// </summary>
  12176. /// <param name="dto"></param>
  12177. /// <returns></returns>
  12178. [HttpPost]
  12179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12180. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  12181. {
  12182. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  12183. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12184. var diids = groupInfos.Select(it => it.Id).ToList();
  12185. List<string> countrys = new List<string>();
  12186. foreach (var item in country)
  12187. {
  12188. var data = _groupRepository.FormartTeamName(item);
  12189. var dataArray = _groupRepository.GroupSplitCountry(data);
  12190. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12191. }
  12192. countrys = countrys.Distinct().ToList();
  12193. for (int i = 0; i < countrys.Count; i++)
  12194. {
  12195. string item = countrys[i];
  12196. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  12197. {
  12198. countrys.Remove(item);
  12199. i--;
  12200. }
  12201. }
  12202. RefAsync<int> total = 0;
  12203. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  12204. .Where(it => countrys.Contains(it.Name_CN))
  12205. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12206. .Select(it => new { id = it.Id, name = it.Name_CN })
  12207. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12208. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12209. }
  12210. /// <summary>
  12211. /// 查看邀请方
  12212. /// 城市信息 Init
  12213. /// </summary>
  12214. /// <param name="dto"></param>
  12215. /// <returns></returns>
  12216. [HttpPost]
  12217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12218. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  12219. {
  12220. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  12221. RefAsync<int> total = 0;
  12222. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  12223. .Where(it => it.CountriesId == dto.CountiesId)
  12224. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12225. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  12226. .Select(it => new { id = it.Id, name = it.Name_CN })
  12227. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12228. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12229. }
  12230. /// <summary>
  12231. /// 查看邀请方
  12232. /// 团组名称 Init
  12233. /// </summary>
  12234. /// <param name="dto"></param>
  12235. /// <returns></returns>
  12236. [HttpPost]
  12237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12238. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  12239. {
  12240. var watch = new Stopwatch();
  12241. watch.Start();
  12242. RefAsync<int> total = 0;
  12243. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  12244. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  12245. .Where((oa, di) => oa.IsDel == 0)
  12246. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  12247. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  12248. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  12249. .Distinct()
  12250. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12251. watch.Stop();
  12252. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  12253. }
  12254. /// <summary>
  12255. /// 查看邀请方
  12256. /// 团组 & 邀请方信息
  12257. /// </summary>
  12258. /// <param name="dto"></param>
  12259. /// <returns></returns>
  12260. [HttpPost]
  12261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12262. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  12263. {
  12264. var watch = new Stopwatch();
  12265. watch.Start();
  12266. RefAsync<int> total = 0;
  12267. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  12268. .AS("Grp_DelegationInfo")
  12269. .Includes(x => x.InvitingInfos)
  12270. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  12271. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  12272. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  12273. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  12274. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  12275. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  12276. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12277. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  12278. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  12279. infos.ForEach(x =>
  12280. {
  12281. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  12282. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  12283. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  12284. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  12285. });
  12286. watch.Stop();
  12287. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  12288. }
  12289. #endregion
  12290. #region 报批行程
  12291. /// <summary>
  12292. /// 报批行程初始化
  12293. /// </summary>
  12294. /// <param name="dto"></param>
  12295. /// <returns></returns>
  12296. [HttpPost]
  12297. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  12298. {
  12299. const int chiNumber = 5;
  12300. var jw = JsonView(false);
  12301. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  12302. var group = groupList.First();
  12303. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  12304. group = groupList.First(x => x.Id == diid);
  12305. if (group == null)
  12306. {
  12307. jw.Msg = "暂无团组!";
  12308. return Ok(jw);
  12309. }
  12310. var data = new
  12311. {
  12312. groupList = groupList.Select(x => new
  12313. {
  12314. x.TeamName,
  12315. x.Id
  12316. }),
  12317. content = new ArrayList(),
  12318. groupInfo = new
  12319. {
  12320. group.VisitDays,
  12321. group.TourCode,
  12322. group.VisitPNumber,
  12323. group.TeamName,
  12324. group.Id,
  12325. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  12326. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  12327. },
  12328. };
  12329. var resultArr = new ArrayList();
  12330. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  12331. if (content.Count == 0)
  12332. {
  12333. var stay = "-";
  12334. var cityPath = "-";
  12335. //添加城市路径以及住宿地
  12336. //黑屏代码数据
  12337. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12338. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12339. {
  12340. jw = JsonView(true, "黑屏代码有误!", data);
  12341. return Ok(jw);
  12342. }
  12343. foreach (DataRow row in dtBlack.Rows)
  12344. {
  12345. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12346. {
  12347. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  12348. return Ok(jw);
  12349. }
  12350. }
  12351. //黑屏代码获取时间区间
  12352. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12353. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12354. _sqlSugar.BeginTran();
  12355. for (int i = 0; i < timeArr.Count; i++)
  12356. {
  12357. stay = "-";
  12358. cityPath = "-";
  12359. DateTime NewData = DateTime.Parse(timeArr[i]);
  12360. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12361. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12362. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12363. if (tbSelect.Length > 0)
  12364. {
  12365. List<string> threeCodeStr = new List<string>();
  12366. foreach (var item in tbSelect)
  12367. {
  12368. var threeCode = item["Three"].ToString() ?? "";
  12369. if (threeCode.Length == 6)
  12370. {
  12371. var start = threeCode.Substring(0, 3);
  12372. var end = threeCode.Substring(3, 3);
  12373. if (threeCodeStr.Count == 0)
  12374. {
  12375. threeCodeStr.Add(start);
  12376. threeCodeStr.Add(end);
  12377. }
  12378. else
  12379. {
  12380. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12381. {
  12382. threeCodeStr.Add(end);
  12383. }
  12384. else
  12385. {
  12386. threeCodeStr.Add(start);
  12387. threeCodeStr.Add(end);
  12388. }
  12389. }
  12390. }
  12391. }
  12392. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12393. var last = threeCodeStr.Last();
  12394. foreach (var item in threeCodeStr)
  12395. {
  12396. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12397. if (item.Equals(last))
  12398. {
  12399. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12400. }
  12401. }
  12402. cityPath = cityPath.Trim('-');
  12403. }
  12404. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12405. appro.Diid = diid ?? -1;
  12406. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12407. appro.Id = thisId;
  12408. appro.CreateUserId = dto.UserId;
  12409. appro.CreateTime = DateTime.Now;
  12410. content.Add(appro);
  12411. }
  12412. _sqlSugar.CommitTran();
  12413. }
  12414. foreach (var x in content)
  12415. {
  12416. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  12417. if (chiList.Count < chiNumber)
  12418. {
  12419. for (int i = chiList.Count; i < chiNumber; i++)
  12420. {
  12421. chiList.Add(new Grp_ApprovalTravelDetails());
  12422. }
  12423. }
  12424. resultArr.Add(new
  12425. {
  12426. x.Id,
  12427. x.Date,
  12428. x.Diid,
  12429. chiList = chiList.Select(x1 => new
  12430. {
  12431. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12432. x1.Details,
  12433. x1.ParentId,
  12434. x1.Id
  12435. })
  12436. });
  12437. }
  12438. data = data with
  12439. {
  12440. content = resultArr,
  12441. };
  12442. jw = JsonView(true, "获取成功!", data);
  12443. return Ok(jw);
  12444. }
  12445. /// <summary>
  12446. /// 报批行程删除
  12447. /// </summary>
  12448. /// <param name="dto"></param>
  12449. /// <returns></returns>
  12450. [HttpPost]
  12451. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  12452. {
  12453. var jw = JsonView(false);
  12454. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12455. if (group == null)
  12456. {
  12457. jw.Msg = "团组参数有误!";
  12458. return Ok(jw);
  12459. }
  12460. try
  12461. {
  12462. _sqlSugar.BeginTran();
  12463. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  12464. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  12465. {
  12466. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12467. DeleteUserId = dto.uesrId,
  12468. IsDel = 1
  12469. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  12470. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  12471. {
  12472. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12473. DeleteUserId = dto.uesrId,
  12474. IsDel = 1
  12475. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  12476. _sqlSugar.CommitTran();
  12477. jw = JsonView(true, "删除成功");
  12478. }
  12479. catch (Exception ex)
  12480. {
  12481. jw = JsonView(false, ex.Message);
  12482. }
  12483. return Ok(jw);
  12484. }
  12485. /// <summary>
  12486. /// 报批行程保存
  12487. /// </summary>
  12488. /// <param name="dto"></param>
  12489. /// <returns></returns>
  12490. [HttpPost]
  12491. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  12492. {
  12493. var jw = JsonView(false);
  12494. var Find = dto.Arr.Find(x => x.id == 0);
  12495. if (Find != null)
  12496. {
  12497. jw.Msg = "生成的ID为0!";
  12498. return Ok(jw);
  12499. }
  12500. foreach (var item in dto.Arr)
  12501. {
  12502. foreach (var chi in item.chiList)
  12503. {
  12504. if (chi.parentId == 0)
  12505. {
  12506. chi.parentId = item.id;
  12507. }
  12508. }
  12509. }
  12510. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  12511. _sqlSugar.BeginTran();
  12512. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  12513. {
  12514. var parentIds = dto.Arr.Select(x => x.id).ToList();
  12515. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  12516. {
  12517. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12518. DeleteUserId = dto.UserId,
  12519. IsDel = 1
  12520. }).ExecuteCommand();
  12521. }
  12522. try
  12523. {
  12524. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  12525. {
  12526. CreateTime = DateTime.Now,
  12527. CreateUserId = dto.UserId,
  12528. Details = x.details,
  12529. ParentId = x.parentId,
  12530. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12531. Remark = "",
  12532. IsDel = 0
  12533. }).ToList()).ExecuteCommand();
  12534. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  12535. {
  12536. Id = x.id,
  12537. Details = x.details,
  12538. ParentId = x.parentId,
  12539. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12540. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  12541. {
  12542. Details = x.Details,
  12543. ParentId = x.ParentId,
  12544. Time = x.Time
  12545. }).ExecuteCommand();
  12546. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  12547. {
  12548. Id = x.id,
  12549. Date = x.date,
  12550. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  12551. {
  12552. Date = x.Date
  12553. }).ExecuteCommand();
  12554. _sqlSugar.CommitTran();
  12555. jw = JsonView(true, "保存成功!");
  12556. }
  12557. catch (Exception ex)
  12558. {
  12559. _sqlSugar.RollbackTran();
  12560. jw = JsonView(false, "保存失败!" + ex.Message);
  12561. }
  12562. return Ok(jw);
  12563. }
  12564. /// <summary>
  12565. /// 报批行程生成
  12566. /// </summary>
  12567. /// <param name="dto"></param>
  12568. /// <returns></returns>
  12569. [HttpPost]
  12570. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  12571. {
  12572. var jw = JsonView(false);
  12573. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12574. if (group == null)
  12575. {
  12576. jw.Msg = "暂无该团组!";
  12577. return Ok(jw);
  12578. }
  12579. //黑屏代码数据
  12580. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12581. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12582. {
  12583. jw.Msg = "黑屏代码有误!";
  12584. return Ok(jw);
  12585. }
  12586. foreach (DataRow row in dtBlack.Rows)
  12587. {
  12588. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12589. {
  12590. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  12591. return Ok(jw);
  12592. }
  12593. }
  12594. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12595. var resultArr = new ArrayList();
  12596. if (officialActivitiesArr.Count == 0)
  12597. {
  12598. jw.Msg = "暂无公务出访信息!";
  12599. return Ok(jw);
  12600. }
  12601. try
  12602. {
  12603. _sqlSugar.BeginTran();
  12604. DeleteApprovalJourney(new
  12605. Domain.Dtos.Groups.DeleteApprovalJourney
  12606. {
  12607. Diid = dto.Diid,
  12608. uesrId = dto.Userid
  12609. });
  12610. var stay = "-";
  12611. var cityPath = "-";
  12612. //添加城市路径以及住宿地
  12613. //黑屏代码获取时间区间
  12614. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12615. var empty = "【未收入该三字码!请机票同事录入】";
  12616. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12617. for (int i = 0; i < timeArr.Count; i++)
  12618. {
  12619. stay = "-";
  12620. cityPath = "-";
  12621. var chiarr = new List<Grp_ApprovalTravelDetails>();
  12622. DateTime NewData = DateTime.Parse(timeArr[i]);
  12623. 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();
  12624. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12625. if (tbSelect.Length > 0)
  12626. {
  12627. List<string> threeCodeStr = new List<string>();
  12628. bool isTrade = false;
  12629. string trip = string.Empty;
  12630. var rowLast = tbSelect.Last();
  12631. var rowFirst = tbSelect.First();
  12632. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  12633. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  12634. var takeOffTime = DateTime.Parse(timeArr[i]);
  12635. var fallToTime = DateTime.Parse(timeArr[i]);
  12636. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  12637. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  12638. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  12639. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  12640. foreach (var item in tbSelect)
  12641. {
  12642. var start = string.Empty;
  12643. var end = string.Empty;
  12644. var threeCode = item["Three"].ToString() ?? "";
  12645. if (threeCode.Length == 6)
  12646. {
  12647. start = threeCode.Substring(0, 3);
  12648. end = threeCode.Substring(3, 3);
  12649. if (threeCodeStr.Count == 0)
  12650. {
  12651. threeCodeStr.Add(start);
  12652. threeCodeStr.Add(end);
  12653. }
  12654. else
  12655. {
  12656. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12657. {
  12658. threeCodeStr.Add(end);
  12659. }
  12660. else
  12661. {
  12662. threeCodeStr.Add(start);
  12663. threeCodeStr.Add(end);
  12664. }
  12665. }
  12666. }
  12667. //处理机票信息
  12668. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  12669. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  12670. if (start_Object == null)
  12671. {
  12672. start_Object = new Res_ThreeCode()
  12673. {
  12674. AirPort = empty,
  12675. AirPort_En = empty,
  12676. City = empty,
  12677. Country = empty,
  12678. Four = empty,
  12679. Three = empty,
  12680. };
  12681. }
  12682. if (end_Object == null)
  12683. {
  12684. end_Object = new Res_ThreeCode()
  12685. {
  12686. AirPort = empty,
  12687. AirPort_En = empty,
  12688. City = empty,
  12689. Country = empty,
  12690. Four = empty,
  12691. Three = empty,
  12692. };
  12693. }
  12694. //机型判断
  12695. string airModel = item["AirModel"].ToString();
  12696. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  12697. string flightTime = item["FlightTime"].ToString();
  12698. if (flightTime!.Contains(":"))
  12699. {
  12700. flightTime = flightTime.Replace(":", "小时");
  12701. flightTime += "分钟";
  12702. }
  12703. if (flightTime.Contains("H"))
  12704. {
  12705. flightTime = flightTime.Replace("H", "小时");
  12706. }
  12707. if (flightTime.Contains("M"))
  12708. {
  12709. flightTime = flightTime.Replace("M", "分钟");
  12710. }
  12711. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  12712. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  12713. {
  12714. flightTime = flightDataTime.Hour > 0
  12715. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  12716. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  12717. ? flightDataTime.Minute.ToString() + "分钟" : "";
  12718. }
  12719. //航班号
  12720. string flightcode = item["Fliagtcode"].ToString();
  12721. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  12722. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  12723. if (aircompany == null)
  12724. {
  12725. aircompany = new Res_AirCompany
  12726. {
  12727. CnName = hsEmpty,
  12728. EnName = hsEmpty,
  12729. ShortCode = hsEmpty,
  12730. };
  12731. }
  12732. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  12733. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  12734. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  12735. if (isTrade)
  12736. {
  12737. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  12738. }
  12739. else
  12740. {
  12741. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  12742. }
  12743. }
  12744. chiarr.Add(new Grp_ApprovalTravelDetails
  12745. {
  12746. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  12747. CreateTime = DateTime.Now,
  12748. CreateUserId = dto.Userid,
  12749. ParentId = 0,
  12750. Details = trip
  12751. });
  12752. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12753. var last = threeCodeStr.Last();
  12754. foreach (var item in threeCodeStr)
  12755. {
  12756. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12757. if (item.Equals(last))
  12758. {
  12759. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12760. }
  12761. }
  12762. cityPath = cityPath.Trim('-');
  12763. }
  12764. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12765. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12766. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12767. appro.Diid = dto.Diid;
  12768. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12769. appro.Id = thisId;
  12770. appro.CreateUserId = dto.Userid;
  12771. appro.CreateTime = DateTime.Now;
  12772. foreach (var item in gwinfo)
  12773. {
  12774. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  12775. chi.Details = "拜访" + item.Client;
  12776. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  12777. {
  12778. chi.Details += "," + item.ReqSample;
  12779. }
  12780. chi.ParentId = thisId;
  12781. chi.Time = item.Time;
  12782. chiarr.Add(chi);
  12783. }
  12784. if (chiarr.Count < 5)
  12785. {
  12786. for (int j = chiarr.Count; j < 5; j++)
  12787. {
  12788. chiarr.Add(new
  12789. Grp_ApprovalTravelDetails());
  12790. }
  12791. }
  12792. resultArr.Add(new
  12793. {
  12794. appro.Id,
  12795. appro.Date,
  12796. appro.Diid,
  12797. chiList = chiarr.Select(x1 => new
  12798. {
  12799. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12800. x1.Details,
  12801. x1.ParentId,
  12802. x1.Id
  12803. })
  12804. });
  12805. }
  12806. _sqlSugar.CommitTran();
  12807. jw = JsonView(true, "生成成功!", resultArr);
  12808. }
  12809. catch (Exception ex)
  12810. {
  12811. jw.Code = 400;
  12812. jw.Msg = "生成失败!" + ex.Message;
  12813. }
  12814. return Ok(jw);
  12815. }
  12816. /// <summary>
  12817. /// 报批行程word导出
  12818. /// </summary>
  12819. /// <param name="dto"></param>
  12820. /// <returns></returns>
  12821. [HttpPost]
  12822. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  12823. {
  12824. var jw = JsonView(false);
  12825. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12826. if (group == null)
  12827. {
  12828. jw.Msg = "暂无该团组!";
  12829. return Ok(jw);
  12830. }
  12831. //模板路径
  12832. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  12833. //载入模板
  12834. Document doc = new Document(tempPath);
  12835. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12836. //获取所填表格的序数
  12837. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12838. Aspose.Words.Tables.Row titleRowClone = null;
  12839. Aspose.Words.Tables.Row CenterRowClone = null;
  12840. int index = 0;
  12841. int indexChi = 0;
  12842. int SetIndex = 0;
  12843. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  12844. //获取数据,放到datatable
  12845. foreach (var item in ApprovalTravelArr)
  12846. {
  12847. if (index > 0)
  12848. {
  12849. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  12850. tableOne.AppendChild(titleRowClone);
  12851. }
  12852. var textTime = item.Date;
  12853. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  12854. SetCells(tableOne, doc, SetIndex, 0, textTime);
  12855. SetIndex++;
  12856. if (ChiRep.Count > 0)
  12857. {
  12858. foreach (var itemChi in ChiRep)
  12859. {
  12860. var txtTime = itemChi.Time;
  12861. var txtDetail = itemChi.Details;
  12862. if (indexChi > 0)
  12863. {
  12864. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12865. tableOne.AppendChild(CenterRowClone);
  12866. }
  12867. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  12868. {
  12869. SetCells(tableOne, doc, SetIndex, 0, "");
  12870. SetCells(tableOne, doc, SetIndex, 1, "");
  12871. indexChi++;
  12872. SetIndex++;
  12873. break;
  12874. }
  12875. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  12876. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  12877. indexChi++;
  12878. SetIndex++;
  12879. }
  12880. }
  12881. else
  12882. {
  12883. if (indexChi > 0)
  12884. {
  12885. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12886. tableOne.AppendChild(CenterRowClone);
  12887. }
  12888. SetCells(tableOne, doc, SetIndex, 0, "");
  12889. SetCells(tableOne, doc, SetIndex, 1, "");
  12890. indexChi++;
  12891. SetIndex++;
  12892. }
  12893. index++;
  12894. }
  12895. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  12896. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12897. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12898. jw.Code = 200;
  12899. jw.Msg = "";
  12900. return Ok(jw);
  12901. }
  12902. private string intToString(int numberVal)
  12903. {
  12904. string numberval = numberVal.ToString();
  12905. Dictionary<char, string> Number = new Dictionary<char, string>();
  12906. Number.Add('1', "一");
  12907. Number.Add('2', "二");
  12908. Number.Add('3', "三");
  12909. Number.Add('4', "四");
  12910. Number.Add('5', "五");
  12911. Number.Add('6', "六");
  12912. Number.Add('7', "七");
  12913. Number.Add('8', "八");
  12914. Number.Add('9', "九");
  12915. string stringNumberVal = string.Empty;
  12916. for (int i = 0; i < numberval.Length; i++)
  12917. {
  12918. if (i == 0)
  12919. {
  12920. stringNumberVal += Number[numberval[i]];
  12921. }
  12922. else if (i >= 1)
  12923. {
  12924. if (numberval[i] == '0')
  12925. {
  12926. stringNumberVal = "十";
  12927. }
  12928. else
  12929. {
  12930. stringNumberVal += "十" + Number[numberval[i]];
  12931. }
  12932. }
  12933. }
  12934. return stringNumberVal;
  12935. }
  12936. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  12937. {
  12938. //获取table中的某个单元格,从0开始
  12939. Cell lshCell = table.Rows[rows].Cells[cells];
  12940. //将单元格中段落移除
  12941. foreach (Node item in lshCell.Paragraphs)
  12942. {
  12943. lshCell.Paragraphs.Remove(item);
  12944. }
  12945. if (val.Contains("\r\n"))
  12946. {
  12947. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  12948. foreach (var item in spArr)
  12949. {
  12950. //新建一个段落
  12951. Paragraph p = new Paragraph(doc);
  12952. var r = new Run(doc, item);
  12953. //把设置的值赋给之前新建的段落
  12954. p.AppendChild(r);
  12955. //将此段落加到单元格内
  12956. lshCell.AppendChild(p);
  12957. }
  12958. }
  12959. else
  12960. {
  12961. //新建一个段落
  12962. Paragraph p = new Paragraph(doc);
  12963. var r = new Run(doc, val);
  12964. //把设置的值赋给之前新建的段落
  12965. p.AppendChild(r);
  12966. //将此段落加到单元格内
  12967. lshCell.AppendChild(p);
  12968. }
  12969. }
  12970. [HttpPost]
  12971. public async Task<IActionResult> ServerHttp(string paramStr)
  12972. {
  12973. paramStr = paramStr.TrimEnd('\'');
  12974. paramStr = paramStr.TrimStart('\'');
  12975. JsonView jw = JsonView(false);
  12976. JObject param = JObject.Parse(paramStr);
  12977. if (!param.ContainsKey("url"))
  12978. {
  12979. jw.Msg = "url null";
  12980. return Ok(jw);
  12981. }
  12982. string url = param["url"]!.ToString();
  12983. var methon = "get";
  12984. Dictionary<string, string> bodyValues = null;
  12985. Dictionary<string, string> headValues = null;
  12986. if (param.ContainsKey("methon"))
  12987. {
  12988. methon = param["methon"]!.ToString();
  12989. }
  12990. if (param.ContainsKey("header"))
  12991. {
  12992. var header = param["header"]!.ToString();
  12993. JObject headerJobject = JObject.Parse(header);
  12994. headValues = new Dictionary<string, string>();
  12995. foreach (JProperty item in headerJobject.Properties())
  12996. {
  12997. var value = item.Value.ToString();
  12998. var head = item.Path;
  12999. headValues.Add(head, value);
  13000. }
  13001. }
  13002. if (param.ContainsKey("body"))
  13003. {
  13004. var body = param["body"]!.ToString();
  13005. bodyValues = new Dictionary<string, string>();
  13006. JObject bodyJobject = JObject.Parse(body);
  13007. foreach (JProperty item in bodyJobject.Properties())
  13008. {
  13009. var value = item.Value.ToString();
  13010. var head = item.Path;
  13011. bodyValues.Add(head, value);
  13012. }
  13013. }
  13014. HttpClient client = new HttpClient();
  13015. string responseString = string.Empty;
  13016. if (param.ContainsKey("isJson"))
  13017. {
  13018. }
  13019. if (headValues != null)
  13020. {
  13021. foreach (var item in headValues.Keys)
  13022. {
  13023. client.DefaultRequestHeaders.Add(item, headValues[item]);
  13024. }
  13025. }
  13026. try
  13027. {
  13028. if (methon == "get")
  13029. {
  13030. responseString = await client.GetStringAsync(url);
  13031. }
  13032. else if (methon == "post")
  13033. {
  13034. if (bodyValues == null)
  13035. {
  13036. jw.Msg = "methon post body null";
  13037. return Ok(jw);
  13038. }
  13039. // 数据转化为 key=val 格式
  13040. var content = new FormUrlEncodedContent(bodyValues);
  13041. var response = await client.PostAsync(url, content);
  13042. // 获取数据
  13043. responseString = await response.Content.ReadAsStringAsync();
  13044. }
  13045. else
  13046. {
  13047. jw.Msg = "methon error";
  13048. }
  13049. jw = JsonView(true, "success", responseString);
  13050. }
  13051. catch (Exception ex)
  13052. {
  13053. jw.Msg = "error " + ex.Message;
  13054. jw.Data = ex.StackTrace;
  13055. }
  13056. finally
  13057. {
  13058. client.Dispose();
  13059. }
  13060. return Ok(jw);
  13061. }
  13062. #endregion
  13063. // /// <summary>
  13064. // ///
  13065. // /// </summary>
  13066. // /// <param name="_dto"></param>
  13067. // /// <returns></returns>
  13068. // [HttpPost]
  13069. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13070. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  13071. // {
  13072. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  13073. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  13074. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  13075. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  13076. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  13077. // dic_psg.Add("客人", 974);
  13078. // dic_psg.Add("司机", 975);
  13079. // dic_psg.Add("导游", 976);
  13080. // dic_psg.Add("公司内部人员", 977);
  13081. // dic_psg.Add("司机/导游/公司内部人员", 978);
  13082. // foreach (var item in list_visa)
  13083. // {
  13084. // Grp_VisaInfo temp = new Grp_VisaInfo();
  13085. // temp.Id = item.Id;
  13086. // temp.DIId = item.DIId;
  13087. // temp.VisaClient = item.VisaClient;
  13088. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  13089. // temp.VisaCurrency = item.VisaCurrency;
  13090. // temp.IsThird = item.IsThird;
  13091. // if (dic_psg.ContainsKey(item.PassengerType))
  13092. // {
  13093. // temp.PassengerType = dic_psg[item.PassengerType];
  13094. // }
  13095. // else {
  13096. // temp.PassengerType = -1;
  13097. // }
  13098. // temp.VisaNumber = item.VisaNumber;
  13099. // temp.VisaFreeNumber = item.VisaFreeNumber;
  13100. // temp.CreateUserId = item.Operators;
  13101. // DateTime dt_ct;
  13102. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  13103. // if (b_ct)
  13104. // {
  13105. // temp.CreateTime = dt_ct;
  13106. // }
  13107. // else
  13108. // {
  13109. // temp.CreateTime = DateTime.Now;
  13110. // }
  13111. // temp.DeleteTime = "";
  13112. // temp.DeleteUserId = 0;
  13113. // temp.Remark = item.Remark;
  13114. // if (string.IsNullOrEmpty(temp.Remark)) {
  13115. // temp.Remark = "";
  13116. // }
  13117. // temp.IsDel = item.IsDel;
  13118. // temp.VisaDescription = item.VisaAttachment;
  13119. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  13120. //([Id]
  13121. // ,[DIId]
  13122. // ,[VisaClient]
  13123. // ,[VisaPrice]
  13124. // ,[VisaCurrency]
  13125. // ,[IsThird]
  13126. // ,[PassengerType]
  13127. // ,[VisaNumber]
  13128. // ,[VisaFreeNumber]
  13129. // ,[CreateUserId]
  13130. // ,[CreateTime]
  13131. // ,[DeleteTime]
  13132. // ,[DeleteUserId]
  13133. // ,[Remark]
  13134. // ,[IsDel]
  13135. // ,[visaDescription])
  13136. // VALUES
  13137. // ({0},{1},'{2}',{3},{4}
  13138. //,{5},{6},{7},{8},{9}
  13139. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  13140. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  13141. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  13142. //);
  13143. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  13144. // }
  13145. // return Ok(JsonView(true, "操作成功!"));
  13146. // }
  13147. /// <summary>
  13148. /// 123132123
  13149. /// </summary>
  13150. /// <param name="_dto"></param>
  13151. /// <returns></returns>
  13152. [HttpPost]
  13153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13154. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  13155. {
  13156. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  13157. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  13158. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  13159. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  13160. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  13161. dicDetail.Add(789, 1034);
  13162. dicDetail.Add(790, 1035);
  13163. dicDetail.Add(791, 1036);
  13164. dicDetail.Add(792, 1037);
  13165. dicDetail.Add(793, 1038);
  13166. dicDetail.Add(794, 1039);
  13167. dicDetail.Add(795, 1040);
  13168. dicDetail.Add(796, 1041);
  13169. dicDetail.Add(797, 1042);
  13170. dicDetail.Add(798, 1043);
  13171. dicDetail.Add(801, 1044);
  13172. dicDetail.Add(802, 1045);
  13173. dicDetail.Add(803, 1046);
  13174. Dictionary<int, int> dic = new Dictionary<int, int>();
  13175. dic.Add(806, 1027);
  13176. dic.Add(807, 1028);
  13177. dic.Add(808, 1029);
  13178. dic.Add(809, 1030);
  13179. dic.Add(810, 1031);
  13180. dic.Add(811, 1032);
  13181. dic.Add(812, 1033);
  13182. foreach (var item in list_visa)
  13183. {
  13184. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  13185. temp.Coefficient = item.coefficient;
  13186. DateTime dtCrt;
  13187. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  13188. if (b1)
  13189. {
  13190. temp.CreateTime = dtCrt;
  13191. }
  13192. else
  13193. {
  13194. temp.CreateTime = DateTime.Now;
  13195. }
  13196. temp.CreateUserId = item.Operators;
  13197. temp.DeleteTime = "";
  13198. temp.DeleteUserId = 0;
  13199. temp.DiId = int.Parse(item.DIID);
  13200. temp.FilePath = item.FilePath;
  13201. temp.IsDel = item.IsDel;
  13202. temp.Price = item.Price;
  13203. temp.PriceCount = 1;
  13204. temp.PriceCurrency = item.Currency;
  13205. int detailId = 0;
  13206. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  13207. {
  13208. detailId = dicDetail[item.PriceTypeDetail];
  13209. }
  13210. temp.PriceDetailType = detailId;
  13211. temp.PriceDt = DateTime.Now;
  13212. temp.PriceName = item.PriceName;
  13213. temp.PriceSum = item.Price;
  13214. int tid = 0;
  13215. if (dic.ContainsKey(item.PriceType))
  13216. {
  13217. tid = dic[item.PriceType];
  13218. }
  13219. temp.PriceType = tid;
  13220. temp.Remark = item.Remark;
  13221. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  13222. }
  13223. return Ok(JsonView(true, "操作成功!"));
  13224. }
  13225. }
  13226. }