GroupsController.cs 743 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using EyeSoft.Collections.Generic;
  6. using EyeSoft.IO;
  7. using Microsoft.AspNetCore.SignalR;
  8. using MySqlX.XDevAPI.Relational;
  9. using NPOI.HSSF.UserModel;
  10. using NPOI.SS.Format;
  11. using NPOI.SS.UserModel;
  12. using NPOI.SS.Util;
  13. using NPOI.XSSF.UserModel;
  14. using OASystem.API.OAMethodLib;
  15. using OASystem.API.OAMethodLib.File;
  16. using OASystem.API.OAMethodLib.Hub.HubClients;
  17. using OASystem.API.OAMethodLib.Hub.Hubs;
  18. using OASystem.API.OAMethodLib.JuHeAPI;
  19. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  20. using OASystem.Domain.Dtos.CRM;
  21. using OASystem.Domain.Dtos.FileDto;
  22. using OASystem.Domain.Dtos.Financial;
  23. using OASystem.Domain.Dtos.Groups;
  24. using OASystem.Domain.Entities.Customer;
  25. using OASystem.Domain.Entities.Financial;
  26. using OASystem.Domain.Entities.Groups;
  27. using OASystem.Domain.ViewModels;
  28. using OASystem.Domain.ViewModels.Groups;
  29. using OASystem.Domain.ViewModels.Statistics;
  30. using OASystem.Infrastructure.Repositories.Financial;
  31. using OASystem.Infrastructure.Repositories.Groups;
  32. using OfficeOpenXml;
  33. using Quartz.Util;
  34. using SqlSugar;
  35. using SqlSugar.Extensions;
  36. using System.Collections;
  37. using System.Data;
  38. using System.Data.OleDb;
  39. using System.Diagnostics;
  40. using System.Globalization;
  41. using System.IO;
  42. using System.IO.Compression;
  43. using System.Net.Http;
  44. using System.Reflection.PortableExecutable;
  45. using Ubiety.Dns.Core;
  46. using static NPOI.POIFS.Crypt.CryptoFunctions;
  47. using static OASystem.API.OAMethodLib.JWTHelper;
  48. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  49. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  50. using Bookmark = Aspose.Words.Bookmark;
  51. using Cell = Aspose.Words.Tables.Cell;
  52. using Table = Aspose.Words.Tables.Table;
  53. namespace OASystem.API.Controllers
  54. {
  55. /// <summary>
  56. /// 团组相关
  57. /// </summary>
  58. //[Authorize]
  59. [Route("api/[controller]/[action]")]
  60. public class GroupsController : ControllerBase
  61. {
  62. private readonly ILogger<GroupsController> _logger;
  63. private readonly GrpScheduleRepository _grpScheduleRep;
  64. private readonly IMapper _mapper;
  65. private readonly DelegationInfoRepository _groupRepository;
  66. private readonly TaskAssignmentRepository _taskAssignmentRep;
  67. private readonly AirTicketResRepository _airTicketResRep;
  68. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  69. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  70. private readonly DelegationEnDataRepository _delegationEnDataRep;
  71. private readonly DelegationVisaRepository _delegationVisaRep;
  72. private readonly VisaPriceRepository _visaPriceRep;
  73. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  74. private readonly HotelPriceRepository _hotelPriceRep;
  75. private readonly CustomersRepository _customersRep;
  76. private readonly MessageRepository _message;
  77. private readonly SqlSugarClient _sqlSugar;
  78. private readonly TourClientListRepository _tourClientListRep;
  79. private readonly TeamRateRepository _teamRateRep;
  80. #region 成本相关
  81. private readonly CheckBoxsRepository _checkBoxs;
  82. private readonly GroupCostRepository _GroupCostRepository;
  83. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  84. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  85. #endregion
  86. private readonly SetDataRepository _setDataRep;
  87. private string url;
  88. private string path;
  89. private readonly EnterExitCostRepository _enterExitCostRep;
  90. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  91. private readonly UsersRepository _usersRep;
  92. private readonly IJuHeApiService _juHeApi;
  93. private readonly InvertedListRepository _invertedListRep;
  94. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  95. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  96. private readonly ThreeCodeRepository _threeCodeRepository;
  97. private readonly HotelInquiryRepository _hotelInquiryRep;
  98. private readonly FeeAuditRepository _feeAuditRep;
  99. private readonly VisaCommissionRepository _visaCommissionRep;
  100. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  101. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  102. public GroupsController(ILogger<GroupsController> logger,
  103. IMapper mapper,
  104. SqlSugarClient sqlSugar,
  105. GrpScheduleRepository grpScheduleRep,
  106. DelegationInfoRepository groupRepository,
  107. TaskAssignmentRepository taskAssignmentRep,
  108. AirTicketResRepository airTicketResRep,
  109. DecreasePaymentsRepository decreasePaymentsRep,
  110. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  111. DelegationEnDataRepository delegationEnDataRep,
  112. EnterExitCostRepository enterExitCostRep,
  113. DelegationVisaRepository delegationVisaRep,
  114. MessageRepository message,
  115. VisaPriceRepository visaPriceRep,
  116. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  117. CheckBoxsRepository checkBoxs,
  118. GroupCostRepository GroupCostRepository,
  119. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  120. GroupCostParameterRepository GroupCostParameterRepository,
  121. HotelPriceRepository hotelPriceRep,
  122. CustomersRepository customersRep,
  123. SetDataRepository setDataRep,
  124. TourClientListRepository tourClientListRep,
  125. TeamRateRepository teamRateRep,
  126. IHubContext<ChatHub, IChatClient> hubContext,
  127. UsersRepository usersRep, IJuHeApiService juHeApi,
  128. InvertedListRepository invertedListRep,
  129. VisaFeeInfoRepository visaFeeInfoRep,
  130. TicketBlackCodeRepository ticketBlackCodeRep,
  131. HotelInquiryRepository hotelInquiryRep,
  132. ThreeCodeRepository threeCodeRepository,
  133. FeeAuditRepository feeAuditRep,
  134. VisaCommissionRepository visaCommissionRep,
  135. ForeignReceivablesRepository ffrRep,
  136. OpinionaireRepository opinionaireRep
  137. )
  138. {
  139. _logger = logger;
  140. _mapper = mapper;
  141. _grpScheduleRep = grpScheduleRep;
  142. _groupRepository = groupRepository;
  143. _taskAssignmentRep = taskAssignmentRep;
  144. _airTicketResRep = airTicketResRep;
  145. _sqlSugar = sqlSugar;
  146. url = AppSettingsHelper.Get("ExcelBaseUrl");
  147. path = AppSettingsHelper.Get("ExcelBasePath");
  148. if (!System.IO.Directory.Exists(path))
  149. {
  150. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  151. }
  152. _decreasePaymentsRep = decreasePaymentsRep;
  153. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  154. _delegationEnDataRep = delegationEnDataRep;
  155. _enterExitCostRep = enterExitCostRep;
  156. _delegationVisaRep = delegationVisaRep;
  157. _message = message;
  158. _visaPriceRep = visaPriceRep;
  159. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  160. _checkBoxs = checkBoxs;
  161. _GroupCostRepository = GroupCostRepository;
  162. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  163. _GroupCostParameterRepository = GroupCostParameterRepository;
  164. _hotelPriceRep = hotelPriceRep;
  165. _customersRep = customersRep;
  166. _setDataRep = setDataRep;
  167. _tourClientListRep = tourClientListRep;
  168. _teamRateRep = teamRateRep;
  169. _hubContext = hubContext;
  170. _usersRep = usersRep;
  171. _juHeApi = juHeApi;
  172. _invertedListRep = invertedListRep;
  173. _visaFeeInfoRep = visaFeeInfoRep;
  174. _ticketBlackCodeRep = ticketBlackCodeRep;
  175. _hotelInquiryRep = hotelInquiryRep;
  176. _threeCodeRepository = threeCodeRepository;
  177. _feeAuditRep = feeAuditRep;
  178. _visaCommissionRep = visaCommissionRep;
  179. _ffrRep = ffrRep;
  180. _opinionaireRep = opinionaireRep;
  181. }
  182. #region 流程管控
  183. /// <summary>
  184. /// 获取团组流程管控信息
  185. /// </summary>
  186. /// <param name="paras">参数Json字符串</param>
  187. /// <returns></returns>
  188. [HttpPost]
  189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  190. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  191. {
  192. if (string.IsNullOrEmpty(_jsonDto.Paras))
  193. {
  194. return Ok(JsonView(false, "参数为空"));
  195. }
  196. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  197. if (_ScheduleDto != null)
  198. {
  199. if (_ScheduleDto.SearchType == 2)//获取列表
  200. {
  201. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  202. return Ok(JsonView(_grpScheduleViewList));
  203. }
  204. else//获取对象
  205. {
  206. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  207. if (_grpScheduleView != null)
  208. {
  209. return Ok(JsonView(_grpScheduleView));
  210. }
  211. }
  212. }
  213. else
  214. {
  215. return Ok(JsonView(false, "参数反序列化失败"));
  216. }
  217. return Ok(JsonView(false, "暂无数据!"));
  218. }
  219. /// <summary>
  220. /// 修改团组流程管控详细表数据
  221. /// </summary>
  222. /// <param name="paras"></param>
  223. /// <returns></returns>
  224. [HttpPost]
  225. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  226. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  227. {
  228. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  229. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  230. .SetColumns(it => it.Duty == _detail.Duty)
  231. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  232. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  233. .SetColumns(it => it.JobContent == _detail.JobContent)
  234. .SetColumns(it => it.Remark == _detail.Remark)
  235. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  236. .Where(s => s.Id == dto.Id)
  237. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  238. .ExecuteCommandAsync();
  239. if (result > 0)
  240. {
  241. return Ok(JsonView(true, "保存成功!"));
  242. }
  243. return Ok(JsonView(false, "保存失败!"));
  244. }
  245. /// <summary>
  246. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  247. /// </summary>
  248. /// <param name="dto"></param>
  249. /// <returns></returns>
  250. [HttpPost]
  251. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  252. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  253. {
  254. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  255. _detail.IsDel = 1;
  256. _detail.DeleteUserId = dto.Duty;
  257. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  258. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  259. .SetColumns(it => it.IsDel == _detail.IsDel)
  260. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  261. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  262. .Where(it => it.Id == dto.Id)
  263. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  264. //.WhereColumns(s => s.Id == dto.Id)
  265. .ExecuteCommandAsync();
  266. if (result > 0)
  267. {
  268. return Ok(JsonView(true, "删除成功!"));
  269. }
  270. return Ok(JsonView(false, "删除失败!"));
  271. }
  272. /// <summary>
  273. /// 增加团组流程管控详细表数据
  274. /// </summary>
  275. /// <param name="dto"></param>
  276. /// <returns></returns>
  277. [HttpPost]
  278. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  279. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  280. {
  281. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  282. if (DateTime.Now < _detail.ExpectBeginDt)
  283. {
  284. _detail.StepStatus = 0;
  285. }
  286. else
  287. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  288. _detail.StepStatus = 1;
  289. }
  290. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  291. if (result > 0)
  292. {
  293. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  294. return Ok(JsonView(true, "添加成功!", _result));
  295. }
  296. return Ok(JsonView(false, "添加失败!"));
  297. }
  298. #endregion
  299. #region 团组基本信息
  300. /// <summary>
  301. /// 接团信息列表
  302. /// </summary>
  303. /// <param name="dto">团组列表请求dto</param>
  304. /// <returns></returns>
  305. [HttpPost]
  306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  307. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  308. {
  309. var groupData = await _groupRepository.GetGroupList(dto);
  310. if (groupData.Code != 0)
  311. {
  312. return Ok(JsonView(false, groupData.Msg));
  313. }
  314. return Ok(JsonView(groupData.Data));
  315. }
  316. /// <summary>
  317. /// 分页查询团组列表
  318. /// </summary>
  319. /// <param name="dto"></param>
  320. /// <returns></returns>
  321. [HttpPost]
  322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  323. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  324. {
  325. var watch = new Stopwatch();
  326. watch.Start();
  327. RefAsync<int> total = 0;
  328. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  329. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  330. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  331. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  332. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  333. .Distinct()
  334. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  335. watch.Stop();
  336. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  337. }
  338. /// <summary>
  339. /// 接团信息列表 Page
  340. /// </summary>
  341. /// <param name="dto">团组列表请求dto</param>
  342. /// <returns></returns>
  343. [HttpPost]
  344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  345. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  346. {
  347. #region 参数验证
  348. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  349. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  350. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  351. #region 页面操作权限验证
  352. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  353. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  354. #endregion
  355. #endregion
  356. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  357. {
  358. string sqlWhere = string.Empty;
  359. if (dto.IsSure == 0) //未完成
  360. {
  361. sqlWhere += string.Format(@" And IsSure = 0");
  362. }
  363. else if (dto.IsSure == 1) //已完成
  364. {
  365. sqlWhere += string.Format(@" And IsSure = 1");
  366. }
  367. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  368. {
  369. string tj = dto.SearchCriteria;
  370. 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}%')",
  371. tj, tj, tj, tj, tj);
  372. }
  373. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  374. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  375. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  376. JietuanOperator,IsSure,CreateTime,IsBid
  377. From (
  378. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  379. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  380. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  381. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  382. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  383. From Grp_DelegationInfo gdi
  384. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  385. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  386. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  387. Where gdi.IsDel = 0 {0}
  388. ) temp", sqlWhere);
  389. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  390. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  391. #region 处理所属部门
  392. /*
  393. * 1.sq 和 gyy 等显示 市场部
  394. * 2.王鸽和主管及张总还有管理员号统一国交部
  395. * 2-1. 4 管理员 ,21 张海麟
  396. */
  397. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  398. List<int> userIds1 = new List<int>() { 4, 21 };
  399. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  400. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  401. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  402. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  403. .ToList();
  404. foreach (var item in _DelegationList)
  405. {
  406. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  407. }
  408. #endregion
  409. var _view = new
  410. {
  411. PageFuncAuth = pageFunAuthView,
  412. Data = _DelegationList
  413. };
  414. return Ok(JsonView(true, "查询成功!", _view, total));
  415. }
  416. else
  417. {
  418. return Ok(JsonView(false, "查询失败"));
  419. }
  420. }
  421. /// <summary>
  422. /// 团组列表
  423. /// </summary>
  424. /// <returns></returns>
  425. [HttpPost]
  426. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  427. {
  428. #region 参数验证
  429. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  430. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  431. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  432. #region 页面操作权限验证
  433. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  434. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  435. #endregion
  436. #endregion
  437. if (dto.PortType != 1 && dto.PortType != 2)
  438. {
  439. return Ok(JsonView(false, "查询失败!"));
  440. }
  441. string orderbyStr = "order by gdi.CreateTime Desc";
  442. string sqlWhere = string.Empty;
  443. if (dto.IsSure == 0) //未完成
  444. {
  445. sqlWhere += string.Format(@" And IsSure = 0");
  446. }
  447. else if (dto.IsSure == 1) //已完成
  448. {
  449. sqlWhere += string.Format(@" And IsSure = 1");
  450. }
  451. //团组类型
  452. if (dto.TeamDid > 0)
  453. {
  454. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  455. }
  456. //团组名称
  457. if (!string.IsNullOrEmpty(dto.TeamName))
  458. {
  459. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  460. }
  461. //客户名称
  462. if (!string.IsNullOrEmpty(dto.ClientName))
  463. {
  464. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  465. }
  466. //客户单位
  467. if (!string.IsNullOrEmpty(dto.ClientUnit))
  468. {
  469. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  470. }
  471. //出访时间
  472. if (!string.IsNullOrEmpty(dto.visitDataTime))
  473. {
  474. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  475. orderbyStr = "order by gdi.VisitDate";
  476. }
  477. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  478. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  479. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  480. JietuanOperator,IsSure,CreateTime
  481. From (
  482. Select row_number() over({0}) as Row_Number,
  483. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  484. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  485. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  486. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  487. From Grp_DelegationInfo gdi
  488. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  489. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  490. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  491. Where gdi.IsDel = 0 {1}
  492. ) temp ", orderbyStr, sqlWhere);
  493. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  494. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  495. #region 处理所属部门
  496. /*
  497. * 1.sq 和 gyy 等显示 市场部
  498. * 2.王鸽和主管及张总还有管理员号统一国交部
  499. * 2-1. 4 管理员 ,21 张海麟
  500. */
  501. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  502. List<int> userIds1 = new List<int>() { 4, 21 };
  503. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  504. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  505. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  506. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  507. .ToList();
  508. foreach (var item in _DelegationList)
  509. {
  510. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  511. }
  512. #endregion
  513. var _view = new
  514. {
  515. PageFuncAuth = pageFunAuthView,
  516. Data = _DelegationList
  517. };
  518. return Ok(JsonView(true, "查询成功!", _view, total));
  519. }
  520. /// <summary>
  521. /// 接团信息详情
  522. /// </summary>
  523. /// <param name="dto">团组info请求dto</param>
  524. /// <returns></returns>
  525. [HttpPost]
  526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  527. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  528. {
  529. var groupData = await _groupRepository.GetGroupInfo(dto);
  530. if (groupData.Code != 0)
  531. {
  532. return Ok(JsonView(false, groupData.Msg));
  533. }
  534. return Ok(JsonView(groupData.Data));
  535. }
  536. /// <summary>
  537. /// 接团信息 编辑添加
  538. /// 基础信息数据源
  539. /// </summary>
  540. /// <param name="dto"></param>
  541. /// <returns></returns>
  542. [HttpPost]
  543. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  544. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  545. {
  546. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  547. if (groupData.Code != 0)
  548. {
  549. return Ok(JsonView(false, groupData.Msg));
  550. }
  551. return Ok(JsonView(groupData.Data));
  552. }
  553. /// <summary>
  554. /// 接团信息 操作(增改)
  555. /// </summary>
  556. /// <param name="dto"></param>
  557. /// <returns></returns>
  558. [HttpPost]
  559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  560. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  561. {
  562. try
  563. {
  564. decimal ffrPrice = 0.00M;
  565. DateTime? visitDt = null;
  566. if (dto.Status == 2)
  567. {
  568. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  569. if (groupInfo != null)
  570. {
  571. ffrPrice = groupInfo.PaymentMoney;
  572. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  573. }
  574. }
  575. var groupData = await _groupRepository.GroupOperation(dto);
  576. if (groupData.Code != 0)
  577. {
  578. return Ok(JsonView(false, groupData.Msg));
  579. }
  580. int diId = 0;
  581. //添加时 默认加入团组汇率
  582. if (dto.Status == 1) //添加
  583. {
  584. diId = groupData.Data;
  585. //添加默认币种
  586. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  587. //默认分配权限
  588. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  589. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  590. var _managerIds = new List<int>() { 22, 32, 21 };
  591. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  592. if (userIds.Count > 0)
  593. {
  594. userIds.Add(208);
  595. //创建团组管控
  596. GroupStepForDelegation.CreateWorkStep(diId);
  597. //发送消息
  598. string groupName = dto.TeamName;
  599. string createGroupUser = string.Empty;
  600. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  601. if (userInfo != null) createGroupUser = userInfo.CnName;
  602. string title = $"系统通知";
  603. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  604. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  605. }
  606. //默认创建倒推表
  607. await _invertedListRep._Create(dto.UserId, diId);
  608. }
  609. else if (dto.Status == 2)
  610. {
  611. diId = dto.Id;
  612. }
  613. #region 签证人员团组时间通知
  614. #region 计算出访起止时间
  615. var startTime = new DateTime();
  616. var endTime = new DateTime();
  617. if (DateTime.TryParse(dto.VisitDate, out startTime))
  618. {
  619. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  620. }
  621. #endregion
  622. if (diId > 0)
  623. {
  624. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  625. }
  626. #endregion
  627. #region 团组操作默认添加/修改收款账单
  628. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  629. {
  630. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  631. .Where(x => x.IsDel == 0 &&
  632. x.Diid == diId &&
  633. x.Remark.Equals("预付款")
  634. )
  635. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  636. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  637. .FirstAsync();
  638. ffrInfo = new Fin_ForeignReceivables()
  639. {
  640. Diid = diId,
  641. PriceName = dto.ClientUnit,
  642. Price = dto.PaymentMoney,
  643. Count = 1,
  644. Unit = $"元",
  645. ItemSumPrice = dto.PaymentMoney,
  646. Rate = 1.0000M,
  647. Currency = 836,
  648. AddingWay = 0,
  649. CreateUserId = dto.UserId,
  650. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  651. Remark = $"预付款"
  652. };
  653. if (ffrInfo == null) //Add
  654. {
  655. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  656. }
  657. else //修改
  658. {
  659. await _sqlSugar.Updateable(ffrInfo)
  660. .UpdateColumns(x => new
  661. {
  662. x.PriceName,
  663. x.Price,
  664. x.ItemSumPrice,
  665. x.CreateTime,
  666. x.CreateUserId
  667. })
  668. .WhereColumns(x => x.Id)
  669. .ExecuteCommandAsync();
  670. }
  671. }
  672. #endregion
  673. return Ok(JsonView(true, "操作成功!", diId));
  674. }
  675. catch (Exception ex)
  676. {
  677. Logs("[response]" + JsonConvert.SerializeObject(dto));
  678. Logs(ex.Message);
  679. return Ok(JsonView(false, ex.Message));
  680. }
  681. }
  682. /// <summary>
  683. /// 接团流程操作(增改)
  684. /// 安卓端使用 建团时添加客户名单
  685. /// </summary>
  686. /// <param name="dto"></param>
  687. /// <returns></returns>
  688. [HttpPost]
  689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  690. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  691. {
  692. try
  693. {
  694. #region 参数验证
  695. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  696. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  697. #region 页面操作权限验证
  698. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  699. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  700. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  701. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  702. #endregion
  703. #endregion
  704. _sqlSugar.BeginTran();
  705. decimal ffrPrice = 0.00M;
  706. DateTime? visitDt = null;
  707. if (dto.Status == 2)
  708. {
  709. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  710. if (groupInfo != null)
  711. {
  712. ffrPrice = groupInfo.PaymentMoney;
  713. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  714. }
  715. }
  716. var _dto = new GroupOperationDto();
  717. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  718. var groupData = await _groupRepository.GroupOperation(_dto);
  719. if (groupData.Code != 0)
  720. {
  721. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  722. }
  723. int diId = 0;
  724. //添加时 默认加入团组汇率
  725. if (dto.Status == 1) //添加
  726. {
  727. diId = groupData.Data;
  728. //添加默认币种
  729. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  730. //默认分配权限
  731. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  732. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  733. List<int> _managerIds = new List<int>() { 21,22, 32 };
  734. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  735. if (userIds.Count > 0)
  736. {
  737. userIds.Add(208);
  738. //创建团组管控
  739. GroupStepForDelegation.CreateWorkStep(diId);
  740. //发送消息
  741. string groupName = dto.TeamName;
  742. string createGroupUser = string.Empty;
  743. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  744. if (userInfo != null) createGroupUser = userInfo.CnName;
  745. string title = $"系统通知";
  746. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  747. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  748. }
  749. #region 应用推送
  750. try
  751. {
  752. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  753. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  754. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  755. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  756. {
  757. List<string> userList = new List<string>() { users.QiyeChatUserId };
  758. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  759. }
  760. }
  761. catch (Exception ex)
  762. {
  763. }
  764. #endregion
  765. //默认创建倒推表
  766. await _invertedListRep._Create(dto.UserId, diId);
  767. }
  768. if (dto.Status == 2)
  769. {
  770. diId = dto.Id;
  771. if (diId == 0)
  772. {
  773. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  774. }
  775. }
  776. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  777. if (viewData.Code != 0)
  778. {
  779. _sqlSugar.RollbackTran();
  780. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  781. }
  782. #region 团组操作默认添加/修改收款账单
  783. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  784. {
  785. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  786. .Where(x => x.IsDel == 0 &&
  787. x.Diid == diId &&
  788. x.Remark.Equals("预付款")
  789. )
  790. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  791. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  792. .FirstAsync();
  793. ffrInfo = new Fin_ForeignReceivables()
  794. {
  795. Diid = diId,
  796. PriceName = dto.ClientUnit,
  797. Price = dto.PaymentMoney,
  798. Count = 1,
  799. Unit = $"元",
  800. ItemSumPrice = dto.PaymentMoney,
  801. Rate = 1.0000M,
  802. Currency = 836,
  803. AddingWay = 0,
  804. CreateUserId = dto.UserId,
  805. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  806. Remark = $"预付款"
  807. };
  808. if (ffrInfo == null) //Add
  809. {
  810. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  811. }
  812. else //修改
  813. {
  814. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  815. .UpdateColumns(x => new
  816. {
  817. x.PriceName,
  818. x.Price,
  819. x.ItemSumPrice,
  820. x.CreateTime,
  821. x.CreateUserId
  822. })
  823. .WhereColumns(x => x.Id)
  824. .ExecuteCommandAsync();
  825. }
  826. }
  827. #endregion
  828. #region 签证人员团组时间通知
  829. #region 计算出访起止时间
  830. var startTime = new DateTime();
  831. var endTime = new DateTime();
  832. if (DateTime.TryParse(dto.VisitDate, out startTime))
  833. {
  834. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  835. }
  836. #endregion
  837. if (diId > 0)
  838. {
  839. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  840. }
  841. #endregion
  842. _sqlSugar.CommitTran();
  843. return Ok(JsonView(true, "添加成功"));
  844. }
  845. catch (Exception ex)
  846. {
  847. _sqlSugar.RollbackTran();
  848. return Ok(JsonView(false, ex.Message));
  849. }
  850. }
  851. /// <summary>
  852. /// 接团信息 操作(删除)
  853. /// </summary>
  854. /// <param name="dto"></param>
  855. /// <returns></returns>
  856. [HttpPost]
  857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  858. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  859. {
  860. try
  861. {
  862. var groupData = await _groupRepository.GroupDel(dto);
  863. if (groupData.Code != 0)
  864. {
  865. return Ok(JsonView(false, groupData.Msg));
  866. }
  867. return Ok(JsonView(true));
  868. }
  869. catch (Exception ex)
  870. {
  871. Logs("[response]" + JsonConvert.SerializeObject(dto));
  872. Logs(ex.Message);
  873. return Ok(JsonView(false, ex.Message));
  874. }
  875. }
  876. /// <summary>
  877. /// 获取团组销售报价号
  878. /// 团组添加时 使用
  879. /// </summary>
  880. /// <returns></returns>
  881. [HttpPost]
  882. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  883. public async Task<IActionResult> GetGroupSalesQuoteNo()
  884. {
  885. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  886. if (groupData.Code != 0)
  887. {
  888. return Ok(JsonView(false, groupData.Msg));
  889. }
  890. object salesQuoteNo = new
  891. {
  892. SalesQuoteNo = groupData.Data
  893. };
  894. return Ok(JsonView(salesQuoteNo));
  895. }
  896. /// <summary>
  897. /// 设置确认出团
  898. /// </summary>
  899. /// <param name="dto"></param>
  900. /// <returns></returns>
  901. [HttpPost]
  902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  903. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  904. {
  905. var groupData = await _groupRepository.ConfirmationGroup(dto);
  906. if (groupData.Code != 0)
  907. {
  908. return Ok(JsonView(false, groupData.Msg));
  909. }
  910. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  911. #region OA消息推送
  912. try
  913. {
  914. string groupName = groupInfo.TeamName;
  915. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  916. List<int> userIds = new List<int>();
  917. listUser.ForEach(s => userIds.Add(s.Id));
  918. string title = $"系统通知";
  919. string content = $"团组[{groupName}]已确认出团!";
  920. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  921. }
  922. catch (Exception ex)
  923. {
  924. }
  925. #endregion
  926. #region 应用推送
  927. try
  928. {
  929. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  930. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  931. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  932. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  933. {
  934. List<string> userList = new List<string>() { users.QiyeChatUserId };
  935. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  936. }
  937. }
  938. catch (Exception ex)
  939. {
  940. }
  941. #endregion
  942. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  943. return Ok(JsonView(true, "操作成功!", groupData.Data));
  944. }
  945. /// <summary>
  946. /// 获取团组名称data And 签证国别Data
  947. /// </summary>
  948. /// <param name="dto"></param>
  949. /// <returns></returns>
  950. [HttpPost]
  951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  952. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  953. {
  954. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  955. if (groupData.Code != 0)
  956. {
  957. return Ok(JsonView(false, groupData.Msg));
  958. }
  959. return Ok(JsonView(groupData.Data));
  960. }
  961. /// <summary>
  962. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  963. /// </summary>
  964. /// <returns></returns>
  965. [HttpPost]
  966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  967. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  968. {
  969. try
  970. {
  971. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  972. if (groupData.Code != 0)
  973. {
  974. return Ok(JsonView(false, groupData.Msg));
  975. }
  976. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  977. }
  978. catch (Exception ex)
  979. {
  980. return Ok(JsonView(false, "程序错误!"));
  981. throw;
  982. }
  983. }
  984. /// <summary>
  985. /// 团组清单 Excel
  986. /// </summary>
  987. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  988. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  989. /// <returns></returns>
  990. [HttpGet]
  991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  992. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  993. {
  994. DateTime _beginDt, _endDt;
  995. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  996. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  997. if (!beginBool && !endBool)
  998. {
  999. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1000. }
  1001. string sql = string.Format(@"
  1002. SELECT
  1003. ROW_NUMBER,
  1004. Id,
  1005. SalesQuoteNo,
  1006. TourCode,
  1007. TeamTypeId,
  1008. TeamType,
  1009. TeamLevId,
  1010. TeamLev,
  1011. TeamName,
  1012. ClientName,
  1013. ClientUnit,
  1014. VisitDate,
  1015. VisitDays,
  1016. VisitPNumber,
  1017. JietuanOperatorId,
  1018. JietuanOperator,
  1019. IsSure,
  1020. CreateTime,
  1021. IsBid
  1022. FROM
  1023. (
  1024. SELECT
  1025. ROW_NUMBER() OVER(
  1026. ORDER BY
  1027. gdi.CreateTime Desc
  1028. ) AS ROW_NUMBER,
  1029. gdi.Id,
  1030. SalesQuoteNo,
  1031. TourCode,
  1032. ssd.Id TeamTypeId,
  1033. ssd.Name TeamType,
  1034. ssd1.Id TeamLevId,
  1035. ssd1.Name TeamLev,
  1036. TeamName,
  1037. ClientName,
  1038. ClientUnit,
  1039. VisitDate,
  1040. VisitDays,
  1041. VisitPNumber,
  1042. JietuanOperator JietuanOperatorId,
  1043. su.CnName JietuanOperator,
  1044. IsSure,
  1045. gdi.CreateTime,
  1046. gdi.IsBid
  1047. FROM
  1048. Grp_DelegationInfo gdi
  1049. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1050. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1051. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1052. WHERE
  1053. gdi.IsDel = 0
  1054. AND gdi.IsBid = 0
  1055. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1056. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1057. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1058. #region 处理所属部门
  1059. /*
  1060. * 1.sq 和 gyy 等显示 市场部
  1061. * 2.王鸽和主管及张总还有管理员号统一国交部
  1062. * 2-1. 4 管理员 ,21 张海麟
  1063. */
  1064. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1065. List<int> userIds1 = new List<int>() { 4, 21 };
  1066. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1067. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1068. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1069. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1070. .ToListAsync();
  1071. foreach (var item in groupList)
  1072. {
  1073. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1074. }
  1075. #endregion
  1076. #region Excel
  1077. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1078. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1079. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1080. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1081. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1082. //载入模板
  1083. WorkbookDesigner designer = new WorkbookDesigner();
  1084. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1085. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1086. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1087. dt.TableName = "GroupList";
  1088. designer.SetDataSource(dt);
  1089. designer.Process();
  1090. if (!Directory.Exists(savePath))
  1091. {
  1092. Directory.CreateDirectory(savePath);
  1093. }
  1094. string serverPath = $"{savePath}{fileName}";
  1095. designer.Workbook.Save(serverPath);
  1096. string rst = $"{servicePath}{ftpPath}{fileName}";
  1097. #endregion
  1098. return Ok(JsonView(true, "操作成功!", rst));
  1099. }
  1100. #endregion
  1101. #region 团组&签证
  1102. /// <summary>
  1103. /// 根据团组Id获取签证客户信息List
  1104. /// </summary>
  1105. /// <param name="dto">请求dto</param>
  1106. /// <returns></returns>
  1107. [HttpPost]
  1108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1109. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1110. {
  1111. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1112. if (groupData.Code != 0)
  1113. {
  1114. return Ok(JsonView(false, groupData.Msg));
  1115. }
  1116. return Ok(JsonView(groupData.Data));
  1117. }
  1118. /// <summary>
  1119. /// IOS获取团组签证拍照上传进度01(团组列表)
  1120. /// </summary>
  1121. /// <param name="dto">请求dto</param>
  1122. /// <returns></returns>
  1123. [HttpPost]
  1124. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1125. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1126. {
  1127. if (dto == null)
  1128. {
  1129. return Ok(JsonView(false, "参数为空"));
  1130. }
  1131. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1132. return Ok(JsonView(visaList));
  1133. }
  1134. /// <summary>
  1135. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1136. /// </summary>
  1137. /// <returns></returns>
  1138. [HttpPost]
  1139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1140. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1141. {
  1142. if (dto == null)
  1143. {
  1144. return Ok(JsonView(false, "请求错误:"));
  1145. }
  1146. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1147. return Ok(JsonView(list));
  1148. }
  1149. /// <summary>
  1150. /// IOS获取团组签证拍照上传进度03(相册)
  1151. /// </summary>
  1152. /// <returns></returns>
  1153. [HttpPost]
  1154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1155. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1156. {
  1157. if (dto == null)
  1158. {
  1159. return Ok(JsonView(false, "请求错误:"));
  1160. }
  1161. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1162. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1163. list.ForEach(s => s.url = url);
  1164. return Ok(JsonView(list));
  1165. }
  1166. /// <summary>
  1167. /// IOS获取团组签证拍照上传进度04(图片上传)
  1168. /// </summary>
  1169. /// <param name="dto"></param>
  1170. /// <returns></returns>
  1171. [HttpPost]
  1172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1173. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1174. {
  1175. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1176. //if (!string.IsNullOrEmpty(result))
  1177. //{
  1178. //}
  1179. //else {
  1180. // return Ok(JsonView(false, "上传失败"));
  1181. //}
  1182. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1183. int sucNum = 0;
  1184. try
  1185. {
  1186. foreach (var item in dto.base64DataList)
  1187. {
  1188. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1189. string result = decodeBase64ToImage(item, imageName);
  1190. if (!string.IsNullOrEmpty(result))
  1191. {
  1192. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1193. pic.CreateUserId = dto.CreateUserId;
  1194. pic.PicName = imageName;
  1195. pic.PicPath = result;
  1196. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1197. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1198. if (insertResult > 0)
  1199. {
  1200. sucNum++;
  1201. }
  1202. }
  1203. }
  1204. }
  1205. catch (Exception ex)
  1206. {
  1207. return Ok(JsonView(false, ex.Message));
  1208. }
  1209. string msg = string.Format(@"成功上传{0}张", sucNum);
  1210. return Ok(JsonView(true, msg));
  1211. }
  1212. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1213. {
  1214. string filename = "";//声明一个string类型的相对路径
  1215. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1216. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1217. try//会有异常抛出,try,catch一下
  1218. {
  1219. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1220. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1221. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1222. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1223. //文件名称
  1224. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1225. //上传的文件的路径
  1226. string filePath = "";
  1227. if (!Directory.Exists(fileDir))
  1228. {
  1229. Directory.CreateDirectory(fileDir);
  1230. }
  1231. //上传的文件的路径
  1232. filePath = fileDir + filename;
  1233. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1234. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1235. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1236. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1237. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1238. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1239. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1240. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1241. bitmap.Dispose();
  1242. }
  1243. catch (Exception e)
  1244. {
  1245. string massage = e.Message;
  1246. Logs("IOS图片上传Error:" + massage);
  1247. //filename = e.Message;
  1248. }
  1249. return filename;//返回相对路径
  1250. }
  1251. /// <summary>
  1252. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1253. /// </summary>
  1254. /// <param name="dto"></param>
  1255. /// <returns></returns>
  1256. [HttpPost]
  1257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1258. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1259. {
  1260. if (dto == null)
  1261. {
  1262. return Ok(JsonView(false, "请求错误:"));
  1263. }
  1264. string msg = "参数错误";
  1265. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1266. {
  1267. try
  1268. {
  1269. //_delegationVisaRep.BeginTran();
  1270. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1271. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1272. .Where(s => s.Id == dto.visaProgressCustomerId)
  1273. .ExecuteCommandAsync();
  1274. if (updCount > 0 && dto.publishCode == 1)
  1275. {
  1276. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1277. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1278. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1279. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1280. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1281. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1282. if (groupData == null)
  1283. {
  1284. _delegationVisaRep.RollbackTran();
  1285. }
  1286. string title = string.Format(@"[签证进度更新]");
  1287. string content = string.Format(@"测试文本");
  1288. bool rst = await _message.AddMsg(new MessageDto()
  1289. {
  1290. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1291. IssuerId = dto.publisher,
  1292. Title = title,
  1293. Content = content,
  1294. ReleaseTime = DateTime.Now,
  1295. UIdList = new List<int> {
  1296. 234
  1297. }
  1298. });
  1299. if (rst)
  1300. {
  1301. return Ok(JsonView(true, "发送通知成功"));
  1302. }
  1303. }
  1304. //_delegationVisaRep.CommitTran();
  1305. }
  1306. catch (Exception)
  1307. {
  1308. //_delegationVisaRep.RollbackTran();
  1309. }
  1310. }
  1311. return Ok(JsonView(true, msg));
  1312. }
  1313. #endregion
  1314. #region 团组任务分配
  1315. /// <summary>
  1316. /// 团组任务分配初始化
  1317. /// </summary>
  1318. /// <param name="dto"></param>
  1319. /// <returns></returns>
  1320. [HttpPost]
  1321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1322. public async Task<IActionResult> GetTaskAssignmen()
  1323. {
  1324. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1325. if (groupData.Code != 0)
  1326. {
  1327. return Ok(JsonView(false, groupData.Msg));
  1328. }
  1329. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1330. }
  1331. /// <summary>
  1332. /// 团组任务分配查询
  1333. /// </summary>
  1334. /// <param name="dto"></param>
  1335. /// <returns></returns>
  1336. [HttpPost]
  1337. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1338. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1339. {
  1340. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1341. if (groupData.Code != 0)
  1342. {
  1343. return Ok(JsonView(false, groupData.Msg));
  1344. }
  1345. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1346. }
  1347. /// <summary>
  1348. /// 团组任务分配操作
  1349. /// </summary>
  1350. /// <param name="dto"></param>
  1351. /// <returns></returns>
  1352. [HttpPost]
  1353. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1354. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1355. {
  1356. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1357. if (groupData.Code != 0)
  1358. {
  1359. return Ok(JsonView(false, groupData.Msg));
  1360. }
  1361. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1362. }
  1363. /// <summary>
  1364. /// 团组任务分配
  1365. /// 批量分配
  1366. /// 查询团组
  1367. /// </summary>
  1368. /// <param name="dto"></param>
  1369. /// <returns></returns>
  1370. [HttpPost]
  1371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1372. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1373. {
  1374. //参数验证
  1375. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1376. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1377. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1378. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1379. }
  1380. /// <summary>
  1381. /// 团组任务分配
  1382. /// 批量分配
  1383. /// </summary>
  1384. /// <param name="dto"></param>
  1385. /// <returns></returns>
  1386. [HttpPost]
  1387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1388. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1389. {
  1390. //参数验证
  1391. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1392. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1393. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1394. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1395. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1396. }
  1397. #endregion
  1398. #region 团组费用审核
  1399. /// <summary>
  1400. /// 费用审核
  1401. /// 团组列表 Page
  1402. /// </summary>
  1403. /// <param name="_dto">团组列表请求dto</param>
  1404. /// <returns></returns>
  1405. [HttpPost]
  1406. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1407. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1408. {
  1409. #region 参数验证
  1410. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1411. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1412. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1413. #region 页面操作权限验证
  1414. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1415. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1416. #endregion
  1417. #endregion
  1418. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1419. {
  1420. string sqlWhere = string.Empty;
  1421. if (_dto.IsSure == 0) //未完成
  1422. {
  1423. sqlWhere += string.Format(@" And IsSure = 0");
  1424. }
  1425. else if (_dto.IsSure == 1) //已完成
  1426. {
  1427. sqlWhere += string.Format(@" And IsSure = 1");
  1428. }
  1429. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1430. {
  1431. string tj = _dto.SearchCriteria;
  1432. 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}%')",
  1433. tj, tj, tj, tj, tj);
  1434. }
  1435. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1436. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1437. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1438. From (
  1439. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1440. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1441. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1442. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1443. From Grp_DelegationInfo gdi
  1444. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1445. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1446. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1447. Where gdi.IsDel = 0 {0}
  1448. ) temp ", sqlWhere);
  1449. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1450. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1451. var _view = new
  1452. {
  1453. PageFuncAuth = pageFunAuthView,
  1454. Data = _DelegationList
  1455. };
  1456. return Ok(JsonView(true, "查询成功!", _view, total));
  1457. }
  1458. else
  1459. {
  1460. return Ok(JsonView(false, "查询失败"));
  1461. }
  1462. }
  1463. /// <summary>
  1464. /// 获取团组费用审核
  1465. /// </summary>
  1466. /// <param name="paras">参数Json字符串</param>
  1467. /// <returns></returns>
  1468. [HttpPost]
  1469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1470. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1471. {
  1472. try
  1473. {
  1474. #region 参数验证
  1475. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1476. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1477. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1478. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1479. #region 页面操作权限验证
  1480. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1481. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1482. #endregion
  1483. #endregion
  1484. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1485. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1486. #region 费用清单
  1487. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1488. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1489. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1490. List<Grp_CreditCardPayment> entityList = _groupRepository
  1491. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1492. .Where(exp.ToExpression())
  1493. .ToList();
  1494. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1495. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1496. /*
  1497. * 76://酒店预订
  1498. */
  1499. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1500. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1501. .ToListAsync();
  1502. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1503. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1504. .ToListAsync();
  1505. /*
  1506. * 79://车/导游地接
  1507. */
  1508. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1509. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1510. .ToListAsync();
  1511. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1512. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1513. .ToListAsync();
  1514. /*
  1515. * 80: //签证
  1516. */
  1517. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1518. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1519. .ToListAsync();
  1520. /*
  1521. *81: //邀请/公务活动
  1522. */
  1523. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1524. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1525. .ToListAsync();
  1526. /*
  1527. * 82: //团组客户保险
  1528. */
  1529. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1530. /*
  1531. * Lable = 85 机票预订
  1532. */
  1533. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1534. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1535. .ToListAsync();
  1536. /*
  1537. * 85 机票预定
  1538. */
  1539. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1540. /*
  1541. * 98 其他款项
  1542. */
  1543. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1544. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1545. .ToListAsync();
  1546. /*
  1547. * 285:收款退还
  1548. */
  1549. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1550. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1551. .ToListAsync();
  1552. /*
  1553. * 1015: //超支费用
  1554. */
  1555. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1556. /*
  1557. * 币种信息
  1558. */
  1559. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1560. /*
  1561. * 车/导游地接 费用类型
  1562. */
  1563. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1564. /*
  1565. * 车/导游地接 费用类型
  1566. */
  1567. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1568. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1569. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1570. /*
  1571. * 用户信息
  1572. */
  1573. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1574. /*
  1575. * 费用模块
  1576. */
  1577. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1578. string priceModule = string.Empty;
  1579. if (sdPriceName != null)
  1580. {
  1581. priceModule = sdPriceName.Name;
  1582. }
  1583. /*
  1584. * 成本信息
  1585. */
  1586. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1587. decimal _groupRate = 0.0000M;
  1588. string _groupCurrencyCode = "-";
  1589. if (groupCost != null)
  1590. {
  1591. _groupRate = groupCost.Rate;
  1592. if (int.TryParse(groupCost.Currency, out int _currency))
  1593. {
  1594. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1595. }
  1596. else _groupCurrencyCode = groupCost.Currency;
  1597. }
  1598. string costContentSql = $"Select * From Grp_GroupCost";
  1599. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1600. //处理日期为空的天数
  1601. for (int i = 0; i < groupCostDetails.Count; i++)
  1602. if (i != 0)
  1603. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1604. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1605. /*
  1606. * 处理详情数据
  1607. */
  1608. foreach (var entity in entityList)
  1609. {
  1610. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1611. _detail.Id = entity.Id;
  1612. _detail.PriceName = priceModule;
  1613. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1614. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1615. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1616. //处理金额
  1617. if (entity.CTable == 1015)
  1618. {
  1619. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1620. if (czInfo != null)
  1621. {
  1622. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1623. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1624. }
  1625. }
  1626. /*
  1627. * 应付款金额
  1628. */
  1629. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1630. string PaymentCurrency_WaitPay = "Unknown";
  1631. string hotelCurrncyCode = "Unknown";
  1632. string hotelCurrncyName = "Unknown";
  1633. if (sdPaymentCurrency_WaitPay != null)
  1634. {
  1635. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1636. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1637. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1638. if (hotelCurrncyCode.Equals("CNY"))
  1639. {
  1640. entity.DayRate = 1.0000M;
  1641. }
  1642. }
  1643. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1644. /*
  1645. * 此次付款金额
  1646. */
  1647. decimal CurrPayStr = 0.00M,
  1648. OriginalCurrPay = 0.00M;
  1649. if (entity.PayPercentage == 0)
  1650. {
  1651. if (entity.PayThenMoney != 0)
  1652. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1653. }
  1654. else
  1655. {
  1656. if (entity.PayMoney != 0)
  1657. {
  1658. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1659. }
  1660. }
  1661. if (_dto.Label == 79)
  1662. {
  1663. string original = string.Empty;
  1664. if (hotelCurrncyCode.Equals("CNY"))
  1665. {
  1666. OriginalCurrPay = CurrPayStr;
  1667. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1668. }
  1669. else
  1670. {
  1671. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1672. //760 EUR(7600.00 CNY)
  1673. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1674. }
  1675. }
  1676. else
  1677. {
  1678. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1679. }
  1680. /*
  1681. * 剩余尾款
  1682. */
  1683. decimal BalanceStr = 0;
  1684. if (CurrPayStr != 0)
  1685. {
  1686. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1687. BalanceStr = 0;
  1688. else
  1689. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1690. }
  1691. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1692. /*
  1693. * Bus名称
  1694. */
  1695. _detail.BusName = "待增加";
  1696. /*
  1697. *费用所属
  1698. */
  1699. switch (entity.CTable)
  1700. {
  1701. case 76://酒店预订
  1702. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1703. if (hotelReservations != null)
  1704. {
  1705. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1706. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1707. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1708. string roomFeeStr = "", roomFeestr1 = "";
  1709. //是否比较房型价格
  1710. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1711. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1712. roomFeeStr += $"<br/>";
  1713. if (hotelReservations.SingleRoomPrice > 0)
  1714. {
  1715. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1716. __isSingle = true;
  1717. }
  1718. if (hotelReservations.DoubleRoomPrice > 0)
  1719. {
  1720. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1721. __isDouble = true;
  1722. }
  1723. if (hotelReservations.SuiteRoomPrice > 0)
  1724. {
  1725. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1726. __isSuite = true;
  1727. }
  1728. if (hotelReservations.OtherRoomPrice > 0)
  1729. {
  1730. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1731. __isOther = true;
  1732. }
  1733. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1734. else roomFeeStr += " 0.00 * 0";
  1735. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1736. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1737. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1738. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1739. /*
  1740. * 费用类型
  1741. * 1:房费
  1742. * 2:早餐
  1743. * 3:地税
  1744. * 4:城市税
  1745. * </summary>
  1746. */
  1747. //地税
  1748. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1749. if (governmentRentData != null)
  1750. {
  1751. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1752. governmentRentFee = governmentRentData.Price;
  1753. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1754. if (governmentRentCurrData != null)
  1755. {
  1756. governmentRentCode = governmentRentCurrData.Name;
  1757. governmentRentName = $"({governmentRentCurrData.Remark})";
  1758. }
  1759. }
  1760. //城市税
  1761. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1762. if (cityTaxData != null)
  1763. {
  1764. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1765. cityTaxFee = cityTaxData.Price;
  1766. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1767. if (cityTaxCurrData != null)
  1768. {
  1769. cityTaxCode = cityTaxCurrData.Name;
  1770. cityTaxName = $"({cityTaxCurrData.Remark})";
  1771. }
  1772. }
  1773. //酒店早餐
  1774. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1775. if (breakfastData != null)
  1776. {
  1777. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1778. breakfastFee = breakfastData.Price;
  1779. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1780. if (breakfastCurrData != null)
  1781. {
  1782. breakfastCode = breakfastCurrData.Name;
  1783. breakfastName = $"({breakfastCurrData.Remark})";
  1784. }
  1785. }
  1786. //房间费用
  1787. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1788. if (roomData != null)
  1789. {
  1790. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1791. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1792. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1793. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1794. roomFee = roomData.Price;
  1795. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1796. if (roomCurrData != null)
  1797. {
  1798. roomCode = roomCurrData.Name;
  1799. roomName = $"({roomCurrData.Remark})";
  1800. }
  1801. }
  1802. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1803. string hotelCostStr = "";
  1804. decimal hotelCsotTotal = 0.00M;
  1805. if (groupCost != null)
  1806. {
  1807. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1808. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1809. }
  1810. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1811. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1812. string hotelCost_day = "";
  1813. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1814. foreach (var item in hotelCostDetails1)
  1815. {
  1816. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1817. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1818. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1819. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1820. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1821. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1822. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1823. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1824. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1825. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1826. hotelCost_day += @$"<br/>";
  1827. }
  1828. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1829. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1830. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1831. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1832. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1833. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1834. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1835. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1836. $"房间说明: {hotelReservations.Remark} <br/>" +
  1837. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1838. $"{hotelBreakfastStr}" +
  1839. $"{hotelGovernmentRentStr}" +
  1840. $"{hotelCityTaxStr}";
  1841. _detail.PriceNameContent = hotelReservations.HotelName;
  1842. }
  1843. break;
  1844. case 79://车/导游地接
  1845. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1846. if (touristGuideGroundReservations != null)
  1847. {
  1848. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1849. {
  1850. _detail.BusName = touristGuideGroundReservations.BusName;
  1851. }
  1852. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1853. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1854. //if (isInt)
  1855. //{
  1856. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1857. // if (cityInfo != null)
  1858. // {
  1859. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1860. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1861. // if (carFeeItem != null)
  1862. // {
  1863. // nameContent += $@"({carFeeItem.Name})";
  1864. // }
  1865. // _detail.PriceNameContent = nameContent;
  1866. // }
  1867. //}
  1868. //else
  1869. //{
  1870. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1871. //}
  1872. var touristGuideGroundReservationsContents =
  1873. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1874. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1875. foreach (var item in touristGuideGroundReservationsContents)
  1876. {
  1877. string typeName = "Unknown";
  1878. string carCurrencyCode = "Unknown";
  1879. string carCurrencyName = "Unknown";
  1880. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1881. if (carTypeData != null) typeName = carTypeData.Name;
  1882. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1883. if (currencyData != null)
  1884. {
  1885. carCurrencyCode = currencyData.Name;
  1886. carCurrencyName = currencyData.Remark;
  1887. }
  1888. //op、成本 币种是否一致
  1889. bool IsCurrencyAgreement = false;
  1890. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1891. string opCostStr = string.Empty;
  1892. decimal opCostTypePrice = 0.00M;
  1893. #region 处理成本各项费用
  1894. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1895. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1896. if (opCost.Count > 0)
  1897. {
  1898. switch (item.SId)
  1899. {
  1900. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1901. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1902. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1903. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1904. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1905. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1906. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1907. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1908. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1909. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1910. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1911. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1912. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1913. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1914. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1915. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1916. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1917. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1918. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1919. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1920. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1921. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1922. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1923. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1924. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1925. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1926. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1927. }
  1928. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1929. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1930. }
  1931. #endregion
  1932. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1933. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1934. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1935. $"{opTypeStr} {opCostStr}<br/>" +
  1936. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1937. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1938. }
  1939. _detail.PriceMsgContent = priceMsg;
  1940. }
  1941. break;
  1942. case 80: //签证
  1943. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1944. if (visaInfo != null)
  1945. {
  1946. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1947. _detail.PriceNameContent = visaInfo.VisaDescription;
  1948. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1949. }
  1950. break;
  1951. case 81: //邀请/公务活动
  1952. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1953. if (_ioa != null)
  1954. {
  1955. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1956. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1957. sendCurrName = "Unknown", //快递费用币种 Name
  1958. sendCurrCode = "Unknown", //快递费用币种 Code
  1959. eventsCurrName = "Unknown", //公务活动费币种 Name
  1960. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1961. translateCurrName = "Unknown", //公务翻译费 Name
  1962. translateCurrCode = "Unknown"; //公务翻译费 Code
  1963. #region 处理费用币种
  1964. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1965. if (inviteCurrData != null)
  1966. {
  1967. inviteCurrName = inviteCurrData.Remark;
  1968. inviteCurrCode = inviteCurrData.Name;
  1969. }
  1970. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1971. if (sendCurrData != null)
  1972. {
  1973. sendCurrName = sendCurrData.Remark;
  1974. sendCurrCode = sendCurrData.Name;
  1975. }
  1976. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1977. if (eventsCurrData != null)
  1978. {
  1979. eventsCurrName = eventsCurrData.Remark;
  1980. eventsCurrCode = eventsCurrData.Name;
  1981. }
  1982. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1983. if (translateCurrData != null)
  1984. {
  1985. translateCurrName = translateCurrData.Remark;
  1986. translateCurrCode = translateCurrData.Name;
  1987. }
  1988. #endregion
  1989. _detail.PriceNameContent = _ioa.InviterArea;
  1990. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1991. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1992. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1993. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1994. $@"备注:" + _ioa.Remark + "<br/>";
  1995. }
  1996. break;
  1997. case 82: //团组客户保险
  1998. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1999. if (customers != null)
  2000. {
  2001. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2002. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2003. }
  2004. break;
  2005. case 85: //机票预订
  2006. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2007. if (jpRes != null)
  2008. {
  2009. string FlightsDescription = jpRes.FlightsDescription;
  2010. string PriceDescription = jpRes.PriceDescription;
  2011. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2012. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2013. }
  2014. break;
  2015. case 98://其他款项
  2016. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2017. if (gdpRes != null)
  2018. {
  2019. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2020. _detail.PriceNameContent = gdpRes.PriceName;
  2021. }
  2022. break;
  2023. case 285://收款退还
  2024. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2025. if (refundAndOtherMoney != null)
  2026. {
  2027. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2028. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2029. }
  2030. break;
  2031. case 751://酒店早餐
  2032. break;
  2033. case 1015://超支费用
  2034. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2035. if (groupExtraCost != null)
  2036. {
  2037. _detail.PriceNameContent = groupExtraCost.PriceName;
  2038. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2039. }
  2040. break;
  2041. default:
  2042. break;
  2043. }
  2044. /*
  2045. * 申请人
  2046. */
  2047. string operatorName = " - ";
  2048. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2049. if (_opUser != null)
  2050. {
  2051. operatorName = _opUser.CnName;
  2052. }
  2053. _detail.OperatorName = operatorName;
  2054. /*
  2055. * 审核人
  2056. */
  2057. string auditOperatorName = "Unknown";
  2058. if (entity.AuditGMOperate == 0)
  2059. auditOperatorName = " - ";
  2060. else if (entity.AuditGMOperate == 4)
  2061. auditOperatorName = "自动审核";
  2062. else
  2063. {
  2064. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2065. if (_adUser != null)
  2066. {
  2067. auditOperatorName = _adUser.CnName;
  2068. }
  2069. }
  2070. _detail.AuditOperatorName = auditOperatorName;
  2071. /*
  2072. * 超预算比例
  2073. */
  2074. string overBudgetStr = "";
  2075. if (entity.ExceedBudget == -1)
  2076. overBudgetStr = sdPriceName.Name + "尚无预算";
  2077. else if (entity.ExceedBudget == 0)
  2078. {
  2079. if (entity.CTable == 76 || entity.CTable == 79)
  2080. {
  2081. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2082. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2083. }
  2084. else
  2085. {
  2086. overBudgetStr = "未超预算";
  2087. }
  2088. }
  2089. else
  2090. overBudgetStr = entity.ExceedBudget.ToString("P");
  2091. _detail.OverBudget = overBudgetStr;
  2092. /*
  2093. * 已审核金额
  2094. */
  2095. decimal auditFee = 0.00M;
  2096. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  2097. /*
  2098. * 费用总计
  2099. */
  2100. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2101. {
  2102. CurrencyId = entity.PaymentCurrency,
  2103. CurrencyName = PaymentCurrency_WaitPay,
  2104. AmountPayable = entity.PayMoney,
  2105. ThisPayment = OriginalCurrPay,
  2106. BalancePayment = BalanceStr,
  2107. AuditedFunds = auditFee
  2108. });
  2109. _detail.IsAuditGM = entity.IsAuditGM;
  2110. detailList.Add(_detail);
  2111. }
  2112. #endregion
  2113. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2114. /*
  2115. * 下方描述处理
  2116. */
  2117. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2118. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2119. if (ccpCurrencyPrice != null)
  2120. {
  2121. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2122. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2123. }
  2124. else
  2125. {
  2126. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2127. }
  2128. string amountPayableStr = string.Format(@"应付款总金额: ");
  2129. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2130. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2131. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2132. foreach (var item in nonDuplicat)
  2133. {
  2134. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2135. if (strs.Count > 0)
  2136. {
  2137. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2138. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2139. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2140. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  2141. //单独处理此次付款金额
  2142. if (item.CurrencyId == 836) //人民币
  2143. {
  2144. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2145. }
  2146. else
  2147. {
  2148. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2149. }
  2150. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  2151. //单独处理已审核费用
  2152. if (item.CurrencyId == 836) //人民币
  2153. {
  2154. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2155. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  2156. }
  2157. else
  2158. {
  2159. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  2160. }
  2161. }
  2162. }
  2163. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2164. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2165. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2166. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  2167. var _view1 = new
  2168. {
  2169. PageFuncAuth = pageFunAuthView,
  2170. Data = _view
  2171. };
  2172. return Ok(JsonView(_view1));
  2173. }
  2174. catch (Exception ex)
  2175. {
  2176. return Ok(JsonView(false, ex.Message));
  2177. }
  2178. }
  2179. /// <summary>
  2180. /// 费用审核
  2181. /// 修改团组费用审核状态
  2182. /// </summary>
  2183. /// <param name="_dto">参数Json字符串</param>
  2184. /// <returns></returns>
  2185. [HttpPost]
  2186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2187. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2188. {
  2189. #region 参数验证
  2190. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2191. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2192. #endregion
  2193. #region 页面操作权限验证
  2194. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2195. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2196. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2197. #endregion
  2198. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2199. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2200. DateTime dtNow = DateTime.Now;
  2201. _groupRepository.BeginTran();
  2202. int rst = 0;
  2203. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2204. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2205. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2206. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2207. List<dynamic> msgDatas = new List<dynamic>();
  2208. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2209. foreach (var item in idList)
  2210. {
  2211. int CreditId = int.Parse(item);
  2212. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2213. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2214. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2215. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2216. .Where(s => s.Id == CreditId)
  2217. .ExecuteCommandAsync();
  2218. if (result < 1)
  2219. {
  2220. rst = -1;
  2221. _groupRepository.RollbackTran();
  2222. return Ok(JsonView(false, "操作失败并回滚!"));
  2223. }
  2224. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2225. if (creditData != null)
  2226. {
  2227. #region 应用通知配置
  2228. try
  2229. {
  2230. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2231. }
  2232. catch (Exception ex)
  2233. {
  2234. }
  2235. #endregion
  2236. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2237. string groupNameStr = string.Empty;
  2238. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2239. if (groupData != null) groupNameStr = groupData.TeamName;
  2240. string creditTypeStr = string.Empty;
  2241. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2242. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2243. string creditCurrency = string.Empty;
  2244. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2245. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2246. if (creditCurrency.Equals("CNY"))
  2247. {
  2248. creditData.DayRate = 1.0000M;
  2249. }
  2250. if (creditData.PayPercentage == 0.00M)
  2251. {
  2252. creditData.PayPercentage = 100M;
  2253. }
  2254. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2255. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2256. string msgContent = "";
  2257. if (creditCurrency.Equals("CNY"))
  2258. {
  2259. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2260. }
  2261. else
  2262. {
  2263. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2264. }
  2265. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2266. }
  2267. }
  2268. if (rst == 0)
  2269. {
  2270. _groupRepository.CommitTran();
  2271. foreach (var item in msgDatas)
  2272. {
  2273. //发送消息
  2274. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2275. }
  2276. #region 应用推送
  2277. try
  2278. {
  2279. foreach (var ccpId in dic_ccp_user.Keys)
  2280. {
  2281. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2282. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2283. }
  2284. }
  2285. catch (Exception)
  2286. {
  2287. }
  2288. #endregion
  2289. return Ok(JsonView(true, "操作成功!"));
  2290. }
  2291. return Ok(JsonView(false, "操作失败!"));
  2292. }
  2293. #endregion
  2294. #region 机票费用录入
  2295. /// <summary>
  2296. /// 机票录入当前登录人可操作团组
  2297. /// </summary>
  2298. /// <param name="dto"></param>
  2299. /// <returns></returns>
  2300. [HttpPost]
  2301. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2302. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2303. {
  2304. try
  2305. {
  2306. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2307. if (groupData.Code != 0)
  2308. {
  2309. return Ok(JsonView(false, groupData.Msg));
  2310. }
  2311. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2312. }
  2313. catch (Exception ex)
  2314. {
  2315. return Ok(JsonView(false, "程序错误!"));
  2316. throw;
  2317. }
  2318. }
  2319. /// <summary>
  2320. /// 机票费用录入列表
  2321. /// </summary>
  2322. /// <param name="dto"></param>
  2323. /// <returns></returns>
  2324. [HttpPost]
  2325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2326. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2327. {
  2328. try
  2329. {
  2330. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2331. if (groupData.Code != 0)
  2332. {
  2333. return Ok(JsonView(false, groupData.Msg));
  2334. }
  2335. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2336. }
  2337. catch (Exception ex)
  2338. {
  2339. return Ok(JsonView(false, ex.Message));
  2340. throw;
  2341. }
  2342. }
  2343. /// <summary>
  2344. /// 根据id查询费用录入信息
  2345. /// </summary>
  2346. /// <param name="dto"></param>
  2347. /// <returns></returns>
  2348. [HttpPost]
  2349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2350. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2351. {
  2352. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2353. if (groupData.Code != 0)
  2354. {
  2355. return Ok(JsonView(false, groupData.Msg));
  2356. }
  2357. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2358. }
  2359. /// <summary>
  2360. /// 机票费用录入操作(Status:1.新增,2.修改)
  2361. /// </summary>
  2362. /// <param name="dto"></param>
  2363. /// <returns></returns>
  2364. [HttpPost]
  2365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2366. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2367. {
  2368. try
  2369. {
  2370. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2371. if (groupData.Code != 0)
  2372. {
  2373. return Ok(JsonView(false, groupData.Msg));
  2374. }
  2375. #region 应用推送
  2376. try
  2377. {
  2378. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2379. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2380. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2381. //2024-10-21 新增LZ UID
  2382. var userIds = new List<int>() { 21 };
  2383. string title = $"系统通知";
  2384. string content = "";
  2385. var diId = dto.AirTicketResOpData.DiId;
  2386. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2387. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2388. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2389. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2390. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2391. }
  2392. catch (Exception ex)
  2393. {
  2394. }
  2395. #endregion
  2396. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2397. }
  2398. catch (Exception ex)
  2399. {
  2400. return Ok(JsonView(false, "程序错误!"));
  2401. throw;
  2402. }
  2403. }
  2404. /// <summary>
  2405. /// 根据舱位类型查询接团客户名单信息
  2406. /// </summary>
  2407. /// <param name="dto"></param>
  2408. /// <returns></returns>
  2409. [HttpPost]
  2410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2411. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2412. {
  2413. try
  2414. {
  2415. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2416. if (crm_Groups.Count != 0)
  2417. {
  2418. List<dynamic> Customer = new List<dynamic>();
  2419. foreach (var item in crm_Groups)
  2420. {
  2421. var data = new
  2422. {
  2423. Id = item.Id,
  2424. Pinyin = item.Pinyin,
  2425. Name = item.LastName + item.FirstName
  2426. };
  2427. Customer.Add(data);
  2428. }
  2429. return Ok(JsonView(true, "查询成功!", Customer));
  2430. }
  2431. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2432. }
  2433. catch (Exception ex)
  2434. {
  2435. return Ok(JsonView(false, "程序错误!"));
  2436. throw;
  2437. }
  2438. }
  2439. /// <summary>
  2440. /// 根据团号获取客户信息
  2441. /// </summary>
  2442. /// <param name="dto"></param>
  2443. /// <returns></returns>
  2444. [HttpPost]
  2445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2446. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2447. {
  2448. var jw = JsonView(false);
  2449. if (dto.DIID < 1)
  2450. {
  2451. jw.Msg += "请输入正确的diid";
  2452. return Ok(jw);
  2453. }
  2454. var arr = getSimplClientList(dto.DIID);
  2455. jw = JsonView(true, "获取成功!", arr);
  2456. return Ok(jw);
  2457. }
  2458. private List<SimplClientInfo> getSimplClientList(int diId)
  2459. {
  2460. 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);
  2461. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2462. return arr;
  2463. }
  2464. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2465. {
  2466. string result = origin;
  2467. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2468. {
  2469. string[] temparr = origin.Split(',');
  2470. string fistrStr = temparr[0];
  2471. int count = temparr.Count();
  2472. int tempId;
  2473. bool success = int.TryParse(fistrStr, out tempId);
  2474. if (success)
  2475. {
  2476. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2477. if (tempInfo != null)
  2478. {
  2479. if (count > 1)
  2480. {
  2481. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2482. }
  2483. else
  2484. {
  2485. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2486. }
  2487. }
  2488. }
  2489. }
  2490. return result;
  2491. }
  2492. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2493. {
  2494. string result = origin;
  2495. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2496. {
  2497. string[] temparr = origin.Split(',');
  2498. result = "";
  2499. foreach (var item in temparr)
  2500. {
  2501. int tempId;
  2502. bool success = int.TryParse(item, out tempId);
  2503. if (success)
  2504. {
  2505. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2506. if (tempInfo != null)
  2507. {
  2508. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2509. }
  2510. }
  2511. }
  2512. }
  2513. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2514. return result;
  2515. }
  2516. /// <summary>
  2517. /// 机票费用录入,删除
  2518. /// </summary>
  2519. /// <param name="dto"></param>
  2520. /// <returns></returns>
  2521. [HttpPost]
  2522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2523. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2524. {
  2525. try
  2526. {
  2527. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2528. if (res)
  2529. {
  2530. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2531. {
  2532. IsDel = 1,
  2533. DeleteUserId = dto.DeleteUserId,
  2534. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2535. }).ExecuteCommandAsync();
  2536. return Ok(JsonView(true, "删除成功!"));
  2537. }
  2538. return Ok(JsonView(false, "删除失败!"));
  2539. }
  2540. catch (Exception ex)
  2541. {
  2542. return Ok(JsonView(false, "程序错误!"));
  2543. throw;
  2544. }
  2545. }
  2546. /// <summary>
  2547. /// 导出机票录入报表
  2548. /// </summary>
  2549. /// <param name="dto"></param>
  2550. /// <returns></returns>
  2551. [HttpPost]
  2552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2553. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2554. {
  2555. try
  2556. {
  2557. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2558. if (groupData.Code != 0)
  2559. {
  2560. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2561. }
  2562. else
  2563. {
  2564. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2565. if (AirTicketReservations.Count != 0)
  2566. {
  2567. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2568. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2569. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2570. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2571. WorkbookDesigner designer = new WorkbookDesigner();
  2572. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2573. decimal countCost = 0;
  2574. foreach (var item in AirTicketReservations)
  2575. {
  2576. #region 处理客人姓名
  2577. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2578. item.ClientName = clientNames;
  2579. #endregion
  2580. if (item.BankType == "其他")
  2581. {
  2582. item.BankNo = "--";
  2583. }
  2584. else
  2585. {
  2586. if (!string.IsNullOrEmpty(item.BankType))
  2587. {
  2588. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2589. }
  2590. }
  2591. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2592. item.Price = System.Decimal.Round(item.Price, 2);
  2593. countCost += Convert.ToDecimal(item.Price);
  2594. }
  2595. designer.SetDataSource("Export", AirTicketReservations);
  2596. designer.SetDataSource("ExportDiCode", diCode);
  2597. designer.SetDataSource("ExportDiName", diName);
  2598. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2599. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2600. designer.Process();
  2601. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2602. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2603. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2604. return Ok(JsonView(true, "成功", url = rst));
  2605. }
  2606. else
  2607. {
  2608. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2609. }
  2610. }
  2611. }
  2612. catch (Exception ex)
  2613. {
  2614. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2615. throw;
  2616. }
  2617. }
  2618. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2619. /// <summary>
  2620. /// 行程单导出
  2621. /// </summary>
  2622. /// <param name="dto"></param>
  2623. /// <returns></returns>
  2624. [HttpPost]
  2625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2626. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2627. {
  2628. try
  2629. {
  2630. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2631. if (groupData.Code != 0)
  2632. {
  2633. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2634. }
  2635. else
  2636. {
  2637. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2638. if (dto.Language == "CN")
  2639. {
  2640. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2641. DocumentBuilder builder = new DocumentBuilder(doc);
  2642. int tableIndex = 0;//表格索引
  2643. //得到文档中的第一个表格
  2644. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2645. foreach (var item in _AirTicketReservations)
  2646. {
  2647. #region 处理固定数据
  2648. string[] FlightsCode = item.FlightsCode.Split('/');
  2649. if (FlightsCode.Length != 0)
  2650. {
  2651. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2652. if (_AirCompany != null)
  2653. {
  2654. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2655. }
  2656. else
  2657. {
  2658. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2659. }
  2660. }
  2661. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2662. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2663. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2664. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2665. string name = "";
  2666. foreach (string clientName in nameArray)
  2667. {
  2668. if (!name.Contains(clientName))
  2669. {
  2670. name += clientName + ",";
  2671. }
  2672. }
  2673. if (!string.IsNullOrWhiteSpace(name))
  2674. {
  2675. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2676. }
  2677. else
  2678. {
  2679. table.Range.Bookmarks["ClientName"].Text = "--";
  2680. }
  2681. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2682. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2683. table.Range.Bookmarks["JointTicket"].Text = "--";
  2684. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2685. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2686. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2687. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2688. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2689. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2690. #endregion
  2691. #region 循环数据处理
  2692. List<AirInfo> airs = new List<AirInfo>();
  2693. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2694. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2695. for (int i = 0; i < FlightsCode.Length; i++)
  2696. {
  2697. AirInfo air = new AirInfo();
  2698. string[] tempstr = DayArray[i]
  2699. .Replace("\r\n", string.Empty)
  2700. .Replace("\\r\\n", string.Empty)
  2701. .TrimStart().TrimEnd()
  2702. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2703. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2704. string starCity = "";
  2705. if (star_Three != null)
  2706. {
  2707. starCity = star_Three.AirPort;
  2708. }
  2709. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2710. string EndCity = "";
  2711. if (End_Three != null)
  2712. {
  2713. EndCity = End_Three.AirPort;
  2714. }
  2715. air.Destination = starCity + "/" + EndCity;
  2716. air.Flight = FlightsCode[i];
  2717. air.SeatingClass = item.CTypeName;
  2718. string dateTime = tempstr[2];
  2719. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2720. air.FlightDate = DateTemp;
  2721. air.DepartureTime = tempstr[5];
  2722. air.LandingTime = tempstr[6];
  2723. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2724. air.TicketStatus = "--";
  2725. air.Luggage = "--";
  2726. air.DepartureTerminal = "--";
  2727. air.LandingTerminal = "--";
  2728. airs.Add(air);
  2729. }
  2730. int row = 13;
  2731. for (int i = 0; i < airs.Count; i++)
  2732. {
  2733. if (airs.Count > 2)
  2734. {
  2735. for (int j = 0; j < airs.Count - 2; j++)
  2736. {
  2737. var CopyRow = table.Rows[12].Clone(true);
  2738. table.Rows.Add(CopyRow);
  2739. }
  2740. }
  2741. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2742. int index = 0;
  2743. foreach (PropertyInfo property in properties)
  2744. {
  2745. string value = property.GetValue(airs[i]).ToString();
  2746. Cell ishcel0 = table.Rows[row].Cells[index];
  2747. Paragraph p = new Paragraph(doc);
  2748. string s = value;
  2749. p.AppendChild(new Run(doc, s));
  2750. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2751. ishcel0.AppendChild(p);
  2752. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2753. index++;
  2754. }
  2755. row++;
  2756. }
  2757. #endregion
  2758. Paragraph lastParagraph = new Paragraph(doc);
  2759. //第一个表格末尾加段落
  2760. table.ParentNode.InsertAfter(lastParagraph, table);
  2761. //复制第一个表格
  2762. Table cloneTable = (Table)table.Clone(true);
  2763. //在文档末尾段落后面加入复制的表格
  2764. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2765. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2766. {
  2767. int rownewsIndex = 13;
  2768. for (int i = 0; i < 2; i++)
  2769. {
  2770. var CopyRow = table.Rows[12].Clone(true);
  2771. table.Rows.RemoveAt(13);
  2772. table.Rows.Add(CopyRow);
  2773. rownewsIndex++;
  2774. }
  2775. }
  2776. else
  2777. {
  2778. table.Rows.RemoveAt(12);
  2779. }
  2780. cloneTable.Rows.RemoveAt(12);
  2781. }
  2782. if (_AirTicketReservations.Count != 0)
  2783. {
  2784. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2785. if (FlightsCode.Length != 0)
  2786. {
  2787. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2788. if (_AirCompany != null)
  2789. {
  2790. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2791. }
  2792. else
  2793. {
  2794. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2795. }
  2796. }
  2797. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2798. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2799. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2800. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2801. string name = "";
  2802. foreach (string clientName in nameArray)
  2803. {
  2804. if (!name.Contains(clientName))
  2805. {
  2806. name += clientName + ",";
  2807. }
  2808. }
  2809. if (!string.IsNullOrWhiteSpace(name))
  2810. {
  2811. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2812. }
  2813. else
  2814. {
  2815. table.Range.Bookmarks["ClientName"].Text = "--";
  2816. }
  2817. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2818. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2819. table.Range.Bookmarks["JointTicket"].Text = "--";
  2820. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2821. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2822. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2823. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2824. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2825. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2826. }
  2827. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2828. //保存合并后的文档
  2829. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2830. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2831. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2832. return Ok(JsonView(true, "成功!", rst));
  2833. }
  2834. else
  2835. {
  2836. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2837. DocumentBuilder builder = new DocumentBuilder(doc);
  2838. int tableIndex = 0;//表格索引
  2839. //得到文档中的第一个表格
  2840. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2841. List<string> texts = new List<string>();
  2842. foreach (var item in _AirTicketReservations)
  2843. {
  2844. string[] FlightsCode = item.FlightsCode.Split('/');
  2845. if (FlightsCode.Length != 0)
  2846. {
  2847. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2848. if (_AirCompany != null)
  2849. {
  2850. if (!transDic.ContainsKey(_AirCompany.CnName))
  2851. {
  2852. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2853. }
  2854. }
  2855. else
  2856. {
  2857. if (!transDic.ContainsKey("--"))
  2858. {
  2859. transDic.Add("--", "--");
  2860. }
  2861. }
  2862. }
  2863. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2864. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2865. string name = "";
  2866. foreach (string clientName in nameArray)
  2867. {
  2868. name += clientName + ",";
  2869. }
  2870. if (!texts.Contains(name))
  2871. {
  2872. texts.Add(name);
  2873. }
  2874. List<AirInfo> airs = new List<AirInfo>();
  2875. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2876. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2877. for (int i = 0; i < FlightsCode.Length; i++)
  2878. {
  2879. AirInfo air = new AirInfo();
  2880. string[] tempstr = DayArray[i]
  2881. .Replace("\r\n", string.Empty)
  2882. .Replace("\\r\\n", string.Empty)
  2883. .TrimStart().TrimEnd()
  2884. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2885. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2886. if (star_Three != null)
  2887. {
  2888. if (!transDic.ContainsKey(star_Three.AirPort))
  2889. {
  2890. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2891. }
  2892. }
  2893. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2894. if (End_Three != null)
  2895. {
  2896. if (!transDic.ContainsKey(End_Three.AirPort))
  2897. {
  2898. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2899. }
  2900. }
  2901. if (!texts.Contains(item.CTypeName))
  2902. {
  2903. texts.Add(item.CTypeName);
  2904. }
  2905. }
  2906. }
  2907. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2908. if (transData.Count > 0)
  2909. {
  2910. foreach (TranslateResult item in transData)
  2911. {
  2912. if (!transDic.ContainsKey(item.Query))
  2913. {
  2914. transDic.Add(item.Query, item.Translation);
  2915. }
  2916. }
  2917. }
  2918. foreach (var item in _AirTicketReservations)
  2919. {
  2920. #region 处理固定数据
  2921. string[] FlightsCode = item.FlightsCode.Split('/');
  2922. if (FlightsCode.Length != 0)
  2923. {
  2924. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2925. if (_AirCompany != null)
  2926. {
  2927. string str = "--";
  2928. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2929. if (!string.IsNullOrEmpty(translateResult))
  2930. {
  2931. str = translateResult;
  2932. str = _airTicketResRep.Processing(str);
  2933. }
  2934. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2935. }
  2936. else
  2937. {
  2938. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2939. }
  2940. }
  2941. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2942. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2943. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2944. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2945. string names = "";
  2946. foreach (string clientName in nameArray)
  2947. {
  2948. names += clientName + ",";
  2949. }
  2950. if (!string.IsNullOrWhiteSpace(names))
  2951. {
  2952. string str = "--";
  2953. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2954. if (!string.IsNullOrEmpty(translateResult))
  2955. {
  2956. str = translateResult;
  2957. str = _airTicketResRep.Processing(str);
  2958. }
  2959. table.Range.Bookmarks["ClientName"].Text = str;
  2960. }
  2961. else
  2962. {
  2963. table.Range.Bookmarks["ClientName"].Text = "--";
  2964. }
  2965. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2966. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2967. table.Range.Bookmarks["JointTicket"].Text = "--";
  2968. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2969. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2970. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2971. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2972. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2973. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2974. #endregion
  2975. #region 循环数据处理
  2976. List<AirInfo> airs = new List<AirInfo>();
  2977. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2978. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2979. for (int i = 0; i < FlightsCode.Length; i++)
  2980. {
  2981. AirInfo air = new AirInfo();
  2982. string[] tempstr = DayArray[i]
  2983. .Replace("\r\n", string.Empty)
  2984. .Replace("\\r\\n", string.Empty)
  2985. .TrimStart().TrimEnd()
  2986. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2987. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2988. string starCity = "";
  2989. if (star_Three != null)
  2990. {
  2991. string str2 = "--";
  2992. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2993. if (!string.IsNullOrEmpty(translateResult2))
  2994. {
  2995. str2 = translateResult2;
  2996. str2 = _airTicketResRep.Processing(str2);
  2997. }
  2998. starCity = str2;
  2999. }
  3000. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3001. string EndCity = "";
  3002. if (End_Three != null)
  3003. {
  3004. string str1 = "--";
  3005. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3006. if (!string.IsNullOrEmpty(translateResult1))
  3007. {
  3008. str1 = translateResult1;
  3009. str1 = _airTicketResRep.Processing(str1);
  3010. }
  3011. EndCity = str1;
  3012. }
  3013. air.Destination = starCity + "/" + EndCity;
  3014. air.Flight = FlightsCode[i];
  3015. string str = "--";
  3016. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3017. if (!string.IsNullOrEmpty(translateResult))
  3018. {
  3019. str = translateResult;
  3020. str = _airTicketResRep.Processing(str);
  3021. }
  3022. air.SeatingClass = str;
  3023. string dateTime = tempstr[2];
  3024. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3025. air.FlightDate = DateTemp;
  3026. air.DepartureTime = tempstr[5];
  3027. air.LandingTime = tempstr[6];
  3028. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3029. air.TicketStatus = "--";
  3030. air.Luggage = "--";
  3031. air.DepartureTerminal = "--";
  3032. air.LandingTerminal = "--";
  3033. airs.Add(air);
  3034. }
  3035. int row = 13;
  3036. for (int i = 0; i < airs.Count; i++)
  3037. {
  3038. if (airs.Count > 2)
  3039. {
  3040. for (int j = 0; j < airs.Count - 2; j++)
  3041. {
  3042. var CopyRow = table.Rows[12].Clone(true);
  3043. table.Rows.Add(CopyRow);
  3044. }
  3045. }
  3046. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3047. int index = 0;
  3048. foreach (PropertyInfo property in properties)
  3049. {
  3050. string value = property.GetValue(airs[i]).ToString();
  3051. Cell ishcel0 = table.Rows[row].Cells[index];
  3052. Paragraph p = new Paragraph(doc);
  3053. string s = value;
  3054. p.AppendChild(new Run(doc, s));
  3055. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3056. ishcel0.AppendChild(p);
  3057. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3058. //ishcel0.CellFormat.VerticalAlignment=
  3059. index++;
  3060. }
  3061. row++;
  3062. }
  3063. #endregion
  3064. Paragraph lastParagraph = new Paragraph(doc);
  3065. //第一个表格末尾加段落
  3066. table.ParentNode.InsertAfter(lastParagraph, table);
  3067. //复制第一个表格
  3068. Table cloneTable = (Table)table.Clone(true);
  3069. //在文档末尾段落后面加入复制的表格
  3070. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3071. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3072. {
  3073. int rownewsIndex = 13;
  3074. for (int i = 0; i < 2; i++)
  3075. {
  3076. var CopyRow = table.Rows[12].Clone(true);
  3077. table.Rows.RemoveAt(13);
  3078. table.Rows.Add(CopyRow);
  3079. rownewsIndex++;
  3080. }
  3081. }
  3082. else
  3083. {
  3084. table.Rows.RemoveAt(12);
  3085. }
  3086. cloneTable.Rows.RemoveAt(12);
  3087. }
  3088. if (_AirTicketReservations.Count != 0)
  3089. {
  3090. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3091. if (FlightsCode.Length != 0)
  3092. {
  3093. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3094. if (_AirCompany != null)
  3095. {
  3096. string str = "--";
  3097. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3098. if (!string.IsNullOrEmpty(translateResult))
  3099. {
  3100. str = translateResult;
  3101. str = _airTicketResRep.Processing(str);
  3102. }
  3103. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3104. }
  3105. else
  3106. {
  3107. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3108. }
  3109. }
  3110. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3111. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3112. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3113. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3114. string names = "";
  3115. foreach (string clientName in nameArray)
  3116. {
  3117. names += clientName + ",";
  3118. }
  3119. if (!string.IsNullOrWhiteSpace(names))
  3120. {
  3121. string str = "--";
  3122. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3123. if (!string.IsNullOrEmpty(translateResult))
  3124. {
  3125. str = translateResult;
  3126. str = _airTicketResRep.Processing(str);
  3127. }
  3128. table.Range.Bookmarks["ClientName"].Text = str;
  3129. }
  3130. else
  3131. {
  3132. table.Range.Bookmarks["ClientName"].Text = "--";
  3133. }
  3134. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3135. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3136. table.Range.Bookmarks["JointTicket"].Text = "--";
  3137. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3138. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3139. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3140. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3141. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3142. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3143. }
  3144. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3145. //保存合并后的文档
  3146. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3147. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3148. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3149. return Ok(JsonView(true, "成功!", rst));
  3150. }
  3151. }
  3152. }
  3153. catch (Exception ex)
  3154. {
  3155. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3156. throw;
  3157. }
  3158. }
  3159. #endregion
  3160. #region 团组增减款项 --> 其他款项
  3161. /// <summary>
  3162. /// 团组增减款项下拉框绑定
  3163. /// </summary>
  3164. /// <param name="dto"></param>
  3165. /// <returns></returns>
  3166. [HttpPost]
  3167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3168. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3169. {
  3170. #region 参数验证
  3171. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3172. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3173. #endregion
  3174. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3175. }
  3176. /// <summary>
  3177. /// 根据团组Id查询团组增减款项
  3178. /// </summary>
  3179. /// <param name="dto"></param>
  3180. /// <returns></returns>
  3181. [HttpPost]
  3182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3183. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3184. {
  3185. #region 参数验证
  3186. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3187. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3188. #endregion
  3189. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3190. }
  3191. /// <summary>
  3192. /// 团组增减款项操作(Status:1.新增,2.修改)
  3193. /// </summary>
  3194. /// <param name="dto"></param>
  3195. /// <returns></returns>
  3196. [HttpPost]
  3197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3198. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3199. {
  3200. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3201. if (groupData.Code != 200)
  3202. {
  3203. return Ok(JsonView(false, groupData.Msg));
  3204. }
  3205. #region 应用推送
  3206. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3207. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3208. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3209. //2024-10-21 新增LZ UID
  3210. var userIds = new List<int>() { 21 };
  3211. string title = $"系统通知";
  3212. string content = "";
  3213. var diId = dto.DiId;
  3214. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3215. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3216. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3217. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3218. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3219. #endregion
  3220. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3221. }
  3222. /// <summary>
  3223. /// 团组增减款项操作 删除
  3224. /// </summary>
  3225. /// <param name="dto"></param>
  3226. /// <returns></returns>
  3227. [HttpPost]
  3228. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3229. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3230. {
  3231. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3232. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3233. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3234. if (res.Code == 0)
  3235. {
  3236. return Ok(JsonView(true, "删除成功!"));
  3237. }
  3238. return Ok(JsonView(false, "删除失败!"));
  3239. }
  3240. /// <summary>
  3241. /// 根据团组增减款项Id查询
  3242. /// </summary>
  3243. /// <param name="dto"></param>
  3244. /// <returns></returns>
  3245. [HttpPost]
  3246. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3247. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3248. {
  3249. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3250. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3251. }
  3252. /// <summary>
  3253. /// 查询供应商名称
  3254. /// </summary>
  3255. /// <param name="dto"></param>
  3256. /// <returns></returns>
  3257. [HttpPost]
  3258. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3259. {
  3260. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3261. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3262. ?? new List<Grp_DecreasePayments>();
  3263. dbResult = dbResult.Distinct(new
  3264. ProductComparer()).ToList();
  3265. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3266. {
  3267. x.Id,
  3268. x.SupplierAddress,
  3269. x.SupplierArea,
  3270. x.SupplierContact,
  3271. x.SupplierContactNumber,
  3272. x.SupplierEmail,
  3273. x.SupplierName,
  3274. x.SupplierSocialAccount,
  3275. x.SupplierTypeId,
  3276. }).ToList());
  3277. return Ok(jw);
  3278. }
  3279. /// <summary>
  3280. /// 团组增减款项 OTA匹配
  3281. /// </summary>
  3282. /// <param name="file"></param>
  3283. /// <returns></returns>
  3284. [HttpPost]
  3285. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3286. {
  3287. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3288. string fileName = file.FileName;
  3289. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3290. {
  3291. return Ok(JsonView(false, "请上传Excel文件!"));
  3292. }
  3293. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3294. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3295. if (!Directory.Exists(path))
  3296. {
  3297. Directory.CreateDirectory(path);
  3298. }
  3299. var filePath = @$"{path}/{fileName}";
  3300. //保存文件
  3301. using (FileStream fs = System.IO.File.Create(filePath))
  3302. {
  3303. file.CopyTo(fs);
  3304. fs.Flush();
  3305. }
  3306. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3307. //读取ExcelFile
  3308. DataTable dt = ConvertExcelToDataTable(filePath);
  3309. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3310. dt.TableName = "TB";
  3311. //修改table列名
  3312. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3313. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3314. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3315. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3316. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3317. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3318. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3319. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3320. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3321. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3322. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3323. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3324. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3325. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3326. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3327. var otaOrderNos = new List<string>();
  3328. foreach (DataRow item in dt.Rows)
  3329. {
  3330. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3331. }
  3332. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3333. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3334. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3335. .Select((dp, di) => new
  3336. {
  3337. dp.PriceName,
  3338. dp.OTAOrderNo,
  3339. dp.FeeTotal,
  3340. di.TeamName,
  3341. })
  3342. .ToListAsync();
  3343. foreach (DataRow item in dt.Rows)
  3344. {
  3345. var otaOrderNo = item["OTAOrderNo"].ToString();
  3346. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3347. if (oaData == null) continue;
  3348. item["GroupName"] = oaData.TeamName;
  3349. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3350. }
  3351. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3352. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3353. List<DataTable> datas = new List<DataTable>();
  3354. datas.Add(dt);
  3355. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3356. return Ok(JsonView(true, "操作成功", new { url = url }));
  3357. }
  3358. #region
  3359. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3360. {
  3361. // 创建Workbook对象
  3362. Workbook workbook = new Workbook(excelFilePath);
  3363. // 获取第一个工作表
  3364. Worksheet worksheet = workbook.Worksheets[0];
  3365. // 将工作表转换为DataTable
  3366. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3367. return dataTable;
  3368. }
  3369. #endregion
  3370. #endregion
  3371. #region 文件上传、删除
  3372. /// <summary>
  3373. /// region 文件上传 可以带参数
  3374. /// </summary>
  3375. /// <param name="file"></param>
  3376. /// <returns></returns>
  3377. [HttpPost]
  3378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3379. public async Task<IActionResult> UploadProject(IFormFile file)
  3380. {
  3381. //var TypeName = Request.Headers["TypeName"].ToString();
  3382. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3383. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3384. ////文件名称
  3385. //string projectFileName = file.FileName;
  3386. ////上传的文件的路径
  3387. //string filePath = $"{fileDir}/{projectFileName}";
  3388. //if (TypeName == "A")//A代表团组增减款项
  3389. //{
  3390. // filePath = fileDir + $@"\团组增减款项相关文件";
  3391. // if (!Directory.Exists(filePath))
  3392. // {
  3393. // Directory.CreateDirectory(filePath);
  3394. // }
  3395. // //上传的文件的路径
  3396. // filePath += $@"\{projectFileName}";
  3397. //}
  3398. //else if (TypeName == "B")//B代表商邀相关文件
  3399. //{
  3400. // //上传的文件的路径
  3401. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3402. // if (!Directory.Exists(filePath))
  3403. // {
  3404. // Directory.CreateDirectory(filePath);
  3405. // }
  3406. // //上传的文件的路径
  3407. // filePath = $@"\{projectFileName}";
  3408. //}
  3409. //try
  3410. //{
  3411. // using (FileStream fs = System.IO.File.Create(filePath))
  3412. // {
  3413. // file.CopyTo(fs);
  3414. // fs.Flush();
  3415. // }
  3416. //}
  3417. //catch (Exception ex)
  3418. //{
  3419. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3420. //}
  3421. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3422. try
  3423. {
  3424. var TypeName = Request.Headers["TypeName"].ToString();
  3425. if (file != null)
  3426. {
  3427. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3428. //文件名称
  3429. string projectFileName = file.FileName;
  3430. //上传的文件的路径
  3431. string filePath = $"{fileDir}/{projectFileName}";
  3432. if (TypeName == "A")//A代表团组增减款项
  3433. {
  3434. if (!Directory.Exists(fileDir))
  3435. {
  3436. Directory.CreateDirectory(fileDir);
  3437. }
  3438. //上传的文件的路径
  3439. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3440. }
  3441. else if (TypeName == "B")//B代表商邀相关文件
  3442. {
  3443. if (!Directory.Exists(fileDir))
  3444. {
  3445. Directory.CreateDirectory(fileDir);
  3446. }
  3447. //上传的文件的路径
  3448. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3449. }
  3450. using (FileStream fs = System.IO.File.Create(filePath))
  3451. {
  3452. file.CopyTo(fs);
  3453. fs.Flush();
  3454. }
  3455. return Ok(JsonView(true, "上传成功!", projectFileName));
  3456. }
  3457. else
  3458. {
  3459. return Ok(JsonView(false, "上传失败!"));
  3460. }
  3461. }
  3462. catch (Exception ex)
  3463. {
  3464. return Ok(JsonView(false, "程序错误!"));
  3465. }
  3466. }
  3467. /// <summary>
  3468. /// 删除指定文件
  3469. /// </summary>
  3470. /// <param name="dto"></param>
  3471. /// <returns></returns>
  3472. [HttpPost]
  3473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3474. public async Task<IActionResult> DelFile(DelFileDto dto)
  3475. {
  3476. try
  3477. {
  3478. var TypeName = Request.Headers["TypeName"].ToString();
  3479. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3480. string filePath = "";
  3481. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3482. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3483. int id = 0;
  3484. if (TypeName == "A")
  3485. {
  3486. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3487. // 删除该文件
  3488. System.IO.File.Delete(filePath);
  3489. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3490. .Where(a => a.Id == dto.Id)
  3491. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3492. .ExecuteCommandAsync();
  3493. }
  3494. else if (TypeName == "B")
  3495. {
  3496. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3497. // 删除该文件
  3498. System.IO.File.Delete(filePath);
  3499. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3500. if (info != null)
  3501. {
  3502. string[] files = new string[] { };
  3503. if (!string.IsNullOrEmpty(info.Attachment))
  3504. {
  3505. try
  3506. {
  3507. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3508. }
  3509. catch (Exception)
  3510. {
  3511. files = new List<string>() { info.Attachment }.ToArray();
  3512. }
  3513. }
  3514. if (files.Length > 0)
  3515. {
  3516. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3517. string filePath2 = string.Empty;
  3518. if (files1.Length > 0)
  3519. {
  3520. filePath2 = JsonConvert.SerializeObject( files1);
  3521. }
  3522. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3523. .Where(a => a.Id == dto.Id)
  3524. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3525. .ExecuteCommandAsync();
  3526. }
  3527. }
  3528. }
  3529. if (id != 0)
  3530. {
  3531. return Ok(JsonView(true, "成功!"));
  3532. }
  3533. else
  3534. {
  3535. return Ok(JsonView(false, "失败!"));
  3536. }
  3537. }
  3538. catch (Exception ex)
  3539. {
  3540. return Ok(JsonView(false, "程序错误!"));
  3541. throw;
  3542. }
  3543. }
  3544. /// <summary>
  3545. /// 文件上传多个文件 可以带参数
  3546. /// </summary>
  3547. /// <param name="file"></param>
  3548. /// <returns></returns>
  3549. [HttpPost]
  3550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3551. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3552. {
  3553. try
  3554. {
  3555. var TypeName = Request.Headers["TypeName"].ToString();
  3556. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3557. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3558. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3559. var filePahts = new List<string>();
  3560. foreach (var file in files)
  3561. {
  3562. //文件名称
  3563. string projectFileName = file.FileName;
  3564. //上传的文件的路径
  3565. string filePath = $"{fileDir}/{projectFileName}";
  3566. if (TypeName == "A")//A代表团组增减款项
  3567. {
  3568. if (!Directory.Exists(fileDir))
  3569. {
  3570. Directory.CreateDirectory(fileDir);
  3571. }
  3572. //上传的文件的路径
  3573. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3574. }
  3575. else if (TypeName == "B")//B代表商邀相关文件
  3576. {
  3577. if (!Directory.Exists(fileDir))
  3578. {
  3579. Directory.CreateDirectory(fileDir);
  3580. }
  3581. //上传的文件的路径
  3582. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3583. }
  3584. using (FileStream fs = System.IO.File.Create(filePath))
  3585. {
  3586. file.CopyTo(fs);
  3587. fs.Flush();
  3588. }
  3589. filePahts.Add(projectFileName);
  3590. }
  3591. return Ok(JsonView(true, "上传成功!", filePahts));
  3592. }
  3593. catch (Exception ex)
  3594. {
  3595. return Ok(JsonView(false, "程序错误!"));
  3596. }
  3597. }
  3598. #endregion
  3599. #region 商邀费用录入
  3600. /// <summary>
  3601. /// 根据团组Id查询商邀费用列表
  3602. /// </summary>
  3603. /// <param name="dto"></param>
  3604. /// <returns></returns>
  3605. [HttpPost]
  3606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3607. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3608. {
  3609. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3610. if (groupData.Code != 0)
  3611. {
  3612. return Ok(JsonView(false, groupData.Msg));
  3613. }
  3614. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3615. }
  3616. /// <summary>
  3617. /// 商邀费用列表
  3618. /// 下载文件
  3619. /// </summary>
  3620. /// <param name="dto"></param>
  3621. /// <returns></returns>
  3622. [HttpGet("{id}")]
  3623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3624. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3625. {
  3626. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3627. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3628. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3629. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3630. var filePaths = new List<string>();
  3631. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3632. try
  3633. {
  3634. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3635. }
  3636. catch (Exception ex)
  3637. {
  3638. filePaths.Add(info.Attachment);
  3639. }
  3640. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3641. for (int i = 0; i < filePaths.Count; i++)
  3642. {
  3643. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3644. }
  3645. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3646. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3647. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3648. {
  3649. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3650. {
  3651. foreach (string filePath in filePaths)
  3652. {
  3653. if (System.IO.File.Exists(filePath))
  3654. {
  3655. // 获取文件名
  3656. string fileName = Path.GetFileName(filePath);
  3657. // 将文件添加到ZIP归档中
  3658. zipArchive.CreateEntryFromFile(filePath, fileName);
  3659. }
  3660. }
  3661. }
  3662. }
  3663. return Ok(JsonView(new {url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3664. }
  3665. /// <summary>
  3666. /// 商邀费用 Info Page 基础数据源
  3667. /// </summary>
  3668. /// <param name="dto"></param>
  3669. /// <returns></returns>
  3670. [HttpPost]
  3671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3672. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3673. {
  3674. try
  3675. {
  3676. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3677. if (groupData.Code != 0)
  3678. {
  3679. return Ok(JsonView(false, groupData.Msg));
  3680. }
  3681. return Ok(JsonView(true, "操作成功", groupData.Data));
  3682. }
  3683. catch (Exception ex)
  3684. {
  3685. return Ok(JsonView(false, ex.Message));
  3686. throw;
  3687. }
  3688. }
  3689. /// <summary>
  3690. /// 根据商邀费用ID查询C表和商邀费用数据
  3691. /// </summary>
  3692. /// <param name="dto"></param>
  3693. /// <returns></returns>
  3694. [HttpPost]
  3695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3696. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3697. {
  3698. try
  3699. {
  3700. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3701. if (groupData.Code != 0)
  3702. {
  3703. return Ok(JsonView(false, groupData.Msg));
  3704. }
  3705. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3706. }
  3707. catch (Exception ex)
  3708. {
  3709. return Ok(JsonView(false, ex.Message));
  3710. throw;
  3711. }
  3712. }
  3713. /// <summary>
  3714. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3715. /// </summary>
  3716. /// <param name="dto"></param>
  3717. /// <returns></returns>
  3718. [HttpPost]
  3719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3720. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3721. {
  3722. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3723. if (groupData.Code != 0)
  3724. {
  3725. return Ok(JsonView(false, groupData.Msg));
  3726. }
  3727. #region 应用推送
  3728. try
  3729. {
  3730. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3731. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3732. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3733. //2024-10-21 新增LZ UID
  3734. var userIds = new List<int>() { 21 };
  3735. string title = $"系统通知";
  3736. string content = "";
  3737. var diId = dto.DiId;
  3738. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3739. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3740. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3741. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3742. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3743. }
  3744. catch (Exception ex)
  3745. {
  3746. }
  3747. #endregion
  3748. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3749. }
  3750. /// <summary>
  3751. /// 商邀删除
  3752. /// </summary>
  3753. /// <param name="dto"></param>
  3754. /// <returns></returns>
  3755. [HttpPost]
  3756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3757. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3758. {
  3759. try
  3760. {
  3761. _sqlSugar.BeginTran();
  3762. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3763. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3764. {
  3765. IsDel = 1,
  3766. DeleteUserId = dto.DeleteUserId,
  3767. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3768. })
  3769. .Where(it => it.Id == dto.Id)
  3770. .ExecuteCommand();
  3771. if (res1 > 0)
  3772. {
  3773. int _diId = 0;
  3774. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3775. if (_ioaInfo != null)
  3776. {
  3777. _diId = _ioaInfo.DiId;
  3778. }
  3779. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3780. .SetColumns(a => new Grp_CreditCardPayment()
  3781. {
  3782. IsDel = 1,
  3783. DeleteUserId = dto.DeleteUserId,
  3784. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3785. })
  3786. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3787. .ExecuteCommand();
  3788. if (res2 > 0)
  3789. {
  3790. _sqlSugar.CommitTran();
  3791. return Ok(JsonView(true, "删除成功!"));
  3792. }
  3793. }
  3794. _sqlSugar.RollbackTran();
  3795. return Ok(JsonView(false, "删除失败"));
  3796. }
  3797. catch (Exception ex)
  3798. {
  3799. _sqlSugar.RollbackTran();
  3800. return Ok(JsonView(false, ex.Message));
  3801. }
  3802. }
  3803. /// <summary>
  3804. /// 团组模块文件上传
  3805. /// </summary>
  3806. /// <param name="dto"></param>
  3807. /// <returns></returns>
  3808. [HttpPost]
  3809. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3810. {
  3811. var jw = JsonView(false);
  3812. long M = 1024 * 1024;
  3813. if (dto.Files == null || dto.Files.Count == 0)
  3814. {
  3815. jw.Msg = "无文件信息!";
  3816. return Ok(jw);
  3817. }
  3818. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3819. {
  3820. jw.Msg = "文件大小超过20M!";
  3821. return Ok(jw);
  3822. }
  3823. //var nameSp = dto.File.FileName.Split(".");
  3824. //if (nameSp.Length < 2)
  3825. //{
  3826. // jw.Msg = "拓展名称有误!";
  3827. // return Ok(jw);
  3828. //}
  3829. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3830. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3831. //{
  3832. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3833. // return Ok(jw);
  3834. //}
  3835. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3836. if (Ctable == null)
  3837. {
  3838. jw.Msg = "Ctable指向有误!";
  3839. return Ok(jw);
  3840. }
  3841. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3842. if (groupInfo == null)
  3843. {
  3844. jw.Msg = "团组信息不存在!";
  3845. return Ok(jw);
  3846. }
  3847. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3848. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3849. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3850. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3851. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3852. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3853. try
  3854. {
  3855. if (!Directory.Exists(fileBase))
  3856. {
  3857. Directory.CreateDirectory(fileBase);
  3858. }
  3859. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3860. foreach (var fileStream in dto.Files)
  3861. {
  3862. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3863. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3864. {
  3865. Cid = dto.Cid,
  3866. CreateTime = DateTime.Now,
  3867. CreateUserId = dto.Userid,
  3868. Ctable = dto.Ctable,
  3869. Diid = dto.Diid,
  3870. IsDel = 0,
  3871. FilePath = saveFilePath,
  3872. FileName = fileStream.FileName
  3873. };
  3874. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3875. {
  3876. fileStream.CopyTo(fs);
  3877. fs.Flush();
  3878. }
  3879. saveArr.Add(file);
  3880. }
  3881. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3882. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3883. jw = JsonView(true, "保存成功!", new
  3884. {
  3885. count = addResult,
  3886. filesName = saveArr.Select(x => x.FileName)
  3887. });
  3888. }
  3889. catch (Exception ex)
  3890. {
  3891. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3892. {
  3893. count = 0,
  3894. filesName = new string[0],
  3895. });
  3896. }
  3897. return Ok(jw);
  3898. }
  3899. /// <summary>
  3900. /// 查询各模块已保存文件
  3901. /// </summary>
  3902. /// <param name="dto"></param>
  3903. /// <returns></returns>
  3904. [HttpPost]
  3905. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3906. {
  3907. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3908. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3909. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3910. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3911. {
  3912. expression = Expressionable.Create<Grp_GroupModelFile>()
  3913. .And(x => visaIds.Contains(x.CreateUserId));
  3914. }
  3915. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3916. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3917. .Where(expression.ToExpression())
  3918. .ToList();
  3919. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3920. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3921. {
  3922. x.FileName,
  3923. x.Id,
  3924. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3925. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3926. })));
  3927. }
  3928. /// <summary>
  3929. /// 下载该团组下的所有文件
  3930. /// </summary>
  3931. /// <param name="dto"></param>
  3932. /// <returns></returns>
  3933. [HttpPost]
  3934. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3935. {
  3936. var jw = JsonView(false);
  3937. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3938. if (groupInfo == null)
  3939. {
  3940. jw.Msg = "团组信息不存在!";
  3941. return Ok(jw);
  3942. }
  3943. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3944. var isModule = Convert.ToBoolean(dto.isModule);
  3945. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3946. IOOperatorHelper io = new IOOperatorHelper();
  3947. if (isModule)
  3948. {
  3949. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3950. foreach (var moduleArr in moduleGroup)
  3951. {
  3952. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3953. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3954. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3955. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3956. foreach (var item in moduleArr)
  3957. {
  3958. if (System.IO.File.Exists(item.FilePath))
  3959. {
  3960. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3961. {
  3962. byte[] bytes = new byte[fileStream.Length];
  3963. fileStream.Read(bytes, 0, bytes.Length);
  3964. fileStream.Close();
  3965. Stream stream = new MemoryStream(bytes);
  3966. chiZips.Add(item.FileName, stream);
  3967. }
  3968. }
  3969. }
  3970. if (chiZips.Count > 0)
  3971. {
  3972. var byts = io.ConvertZipStream(chiZips);
  3973. Stream stream = new MemoryStream(byts);
  3974. Zips.Add(key.Name + "_.zip", stream);
  3975. }
  3976. }
  3977. }
  3978. else
  3979. {
  3980. foreach (var item in dbQuery)
  3981. {
  3982. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3983. {
  3984. byte[] bytes = new byte[fileStream.Length];
  3985. fileStream.Read(bytes, 0, bytes.Length);
  3986. fileStream.Close();
  3987. Stream stream = new MemoryStream(bytes);
  3988. while (Zips.Keys.Contains(item.FileName))
  3989. {
  3990. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3991. }
  3992. Zips.Add(item.FileName, stream);
  3993. }
  3994. }
  3995. }
  3996. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3997. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3998. if (Zips.Count > 0)
  3999. {
  4000. var byts = io.ConvertZipStream(Zips);
  4001. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4002. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4003. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4004. }
  4005. else
  4006. {
  4007. jw.Msg = "暂无生成文件!";
  4008. }
  4009. return Ok(jw);
  4010. }
  4011. /// <summary>
  4012. /// 下载该团组下此模块的所有文件
  4013. /// </summary>
  4014. /// <param name="dto"></param>
  4015. /// <returns></returns>
  4016. [HttpPost]
  4017. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4018. {
  4019. var jw = JsonView(false);
  4020. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4021. if (groupInfo == null)
  4022. {
  4023. jw.Msg = "团组信息不存在!";
  4024. return Ok(jw);
  4025. }
  4026. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4027. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4028. && x.IsDel == 0);
  4029. if (key == null)
  4030. {
  4031. jw.Msg = "Ctable指向错误!";
  4032. return Ok(jw);
  4033. }
  4034. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4035. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4036. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4037. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4038. IOOperatorHelper io = new IOOperatorHelper();
  4039. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4040. foreach (var item in dbQuery)
  4041. {
  4042. if (System.IO.File.Exists(item.FilePath))
  4043. {
  4044. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4045. {
  4046. byte[] bytes = new byte[fileStream.Length];
  4047. fileStream.Read(bytes, 0, bytes.Length);
  4048. fileStream.Close();
  4049. Stream stream = new MemoryStream(bytes);
  4050. while (Zips.Keys.Contains(item.FileName))
  4051. {
  4052. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4053. }
  4054. Zips.Add(item.FileName, stream);
  4055. }
  4056. }
  4057. }
  4058. if (Zips.Count > 0)
  4059. {
  4060. var byts = io.ConvertZipStream(Zips);
  4061. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4062. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4063. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4064. }
  4065. else
  4066. {
  4067. jw.Msg = "暂无生成文件!";
  4068. }
  4069. return Ok(jw);
  4070. }
  4071. /// <summary>
  4072. /// 删除该团组下的指定文件
  4073. /// </summary>
  4074. /// <param name="dto"></param>
  4075. /// <returns></returns>
  4076. [HttpPost]
  4077. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4078. {
  4079. var jw = JsonView(false);
  4080. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4081. if (sing == null)
  4082. {
  4083. jw.Msg = "暂无";
  4084. return Ok(jw);
  4085. }
  4086. if (System.IO.File.Exists(sing.FilePath))
  4087. {
  4088. try
  4089. {
  4090. System.IO.File.Delete(sing.FilePath);
  4091. }
  4092. catch (Exception ex)
  4093. {
  4094. jw.Msg = "删除失败!" + ex.Message;
  4095. return Ok(jw);
  4096. }
  4097. }
  4098. sing.IsDel = 1;
  4099. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4100. sing.DeleteUserId = dto.UserId;
  4101. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4102. jw = JsonView(true, "删除成功!");
  4103. return Ok(jw);
  4104. }
  4105. #endregion
  4106. #region 团组英文资料
  4107. /// <summary>
  4108. /// 查询团组英文所有资料
  4109. /// </summary>
  4110. /// <param name="dto"></param>
  4111. /// <returns></returns>
  4112. [HttpPost]
  4113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4114. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4115. {
  4116. try
  4117. {
  4118. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4119. if (groupData.Code != 0)
  4120. {
  4121. return Ok(JsonView(false, groupData.Msg));
  4122. }
  4123. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4124. }
  4125. catch (Exception ex)
  4126. {
  4127. return Ok(JsonView(false, "程序错误!"));
  4128. throw;
  4129. }
  4130. }
  4131. /// <summary>
  4132. /// 团组英文资料操作(Status:1.新增,2.修改)
  4133. /// </summary>
  4134. /// <param name="dto"></param>
  4135. /// <returns></returns>
  4136. [HttpPost]
  4137. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4138. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4139. {
  4140. try
  4141. {
  4142. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4143. if (groupData.Code != 0)
  4144. {
  4145. return Ok(JsonView(false, groupData.Msg));
  4146. }
  4147. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4148. }
  4149. catch (Exception ex)
  4150. {
  4151. return Ok(JsonView(false, "程序错误!"));
  4152. throw;
  4153. }
  4154. }
  4155. /// <summary>
  4156. /// 团组英文资料Id查询数据
  4157. /// </summary>
  4158. /// <param name="dto"></param>
  4159. /// <returns></returns>
  4160. [HttpPost]
  4161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4162. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4163. {
  4164. try
  4165. {
  4166. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4167. if (_DelegationEnData != null)
  4168. {
  4169. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4170. }
  4171. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4172. }
  4173. catch (Exception ex)
  4174. {
  4175. return Ok(JsonView(false, "程序错误!"));
  4176. throw;
  4177. }
  4178. }
  4179. /// <summary>
  4180. /// 团组英文资料删除
  4181. /// </summary>
  4182. /// <param name="dto"></param>
  4183. /// <returns></returns>
  4184. [HttpPost]
  4185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4186. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4187. {
  4188. try
  4189. {
  4190. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4191. if (!res)
  4192. {
  4193. return Ok(JsonView(false, "删除失败"));
  4194. }
  4195. return Ok(JsonView(true, "删除成功!"));
  4196. }
  4197. catch (Exception ex)
  4198. {
  4199. return Ok(JsonView(false, "程序错误!"));
  4200. throw;
  4201. }
  4202. }
  4203. #endregion
  4204. #region 导出邀请函
  4205. /// <summary>
  4206. /// 导出邀请函页面初始化
  4207. /// </summary>
  4208. /// <param name="dto"></param>
  4209. /// <returns></returns>
  4210. [HttpPost]
  4211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4212. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4213. {
  4214. try
  4215. {
  4216. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4217. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4218. if (dto.DiId == 0)
  4219. {
  4220. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4221. }
  4222. else
  4223. {
  4224. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4225. }
  4226. return Ok(JsonView(true, "查询成功!", new
  4227. {
  4228. deleClient = crm_Deles,
  4229. delegations = grp_Delegations
  4230. }));
  4231. }
  4232. catch (Exception ex)
  4233. {
  4234. return Ok(JsonView(false, "程序错误!"));
  4235. throw;
  4236. }
  4237. }
  4238. /// <summary>
  4239. /// 导出邀请函
  4240. /// </summary>
  4241. /// <param name="dto"></param>
  4242. /// <returns></returns>
  4243. [HttpPost]
  4244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4245. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4246. {
  4247. #region 参数验证
  4248. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4249. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4250. #endregion
  4251. try
  4252. {
  4253. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4254. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4255. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4256. From Grp_TourClientList tcl
  4257. Left Join
  4258. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4259. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4260. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4261. From Crm_DeleClient dc
  4262. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4263. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4264. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4265. Where dc.IsDel = 0) temp
  4266. On temp.DcId =tcl.ClientId
  4267. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4268. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4269. List<string> texts = new List<string>();
  4270. if (datas.Count != 0)
  4271. {
  4272. foreach (TourClientListDetailsView item in datas)
  4273. {
  4274. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4275. {
  4276. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4277. }
  4278. else
  4279. {
  4280. string name = item.LastName + item.FirstName;
  4281. texts.Add(name);
  4282. }
  4283. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4284. {
  4285. if (!transDic.ContainsKey(item.Job))
  4286. {
  4287. texts.Add(item.Job);
  4288. }
  4289. }
  4290. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4291. {
  4292. texts.Add(item.CompanyFullName);
  4293. }
  4294. }
  4295. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4296. if (transData.Count > 0)
  4297. {
  4298. foreach (TranslateResult item in transData)
  4299. {
  4300. if (!transDic.ContainsKey(item.Query))
  4301. {
  4302. transDic.Add(item.Query, item.Translation);
  4303. }
  4304. }
  4305. }
  4306. List<GuestList> list = new List<GuestList>();
  4307. foreach (TourClientListDetailsView dele in datas)
  4308. {
  4309. GuestList guestList = new GuestList();
  4310. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4311. {
  4312. guestList.Name = dele.Pinyin;
  4313. }
  4314. else
  4315. {
  4316. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4317. guestList.Name = Name;
  4318. }
  4319. if (dele.Sex == 0)
  4320. {
  4321. guestList.Sex = "Male";
  4322. }
  4323. else if (dele.Sex == 1)
  4324. {
  4325. guestList.Sex = "Female";
  4326. }
  4327. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4328. if (!string.IsNullOrEmpty(dele.Job))
  4329. {
  4330. guestList.Job = dele.Job;
  4331. }
  4332. list.Add(guestList);
  4333. }
  4334. //载入模板
  4335. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4336. DocumentBuilder builder = new DocumentBuilder(doc);
  4337. //获取word里所有表格
  4338. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4339. //获取所填表格的序数
  4340. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4341. var rowStart = tableOne.Rows[0]; //获取第1行
  4342. //循环赋值
  4343. for (int i = 0; i < list.Count; i++)
  4344. {
  4345. builder.MoveToCell(0, i + 1, 0, 0);
  4346. builder.Write(list[i].Name.ToString());
  4347. builder.MoveToCell(0, i + 1, 1, 0);
  4348. builder.Write(list[i].Sex.ToString());
  4349. builder.MoveToCell(0, i + 1, 2, 0);
  4350. builder.Write(list[i].DOB.ToString());
  4351. builder.MoveToCell(0, i + 1, 3, 0);
  4352. builder.Write(list[i].Job.ToString());
  4353. }
  4354. //删除多余行
  4355. while (tableOne.Rows.Count > list.Count + 1)
  4356. {
  4357. tableOne.Rows.RemoveAt(list.Count + 1);
  4358. }
  4359. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4360. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4361. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4362. doc.Save(filePath);
  4363. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4364. return Ok(JsonView(true, "操作成功!", Url));
  4365. }
  4366. else
  4367. {
  4368. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4369. }
  4370. }
  4371. catch (Exception ex)
  4372. {
  4373. return Ok(JsonView(false, ex.Message));
  4374. throw;
  4375. }
  4376. }
  4377. #endregion
  4378. #region 团组经理模块 出入境费用
  4379. ///// <summary>
  4380. ///// 团组模块 - 出入境费用
  4381. ///// </summary>
  4382. ///// <returns></returns>
  4383. //[HttpPost]
  4384. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4385. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  4386. //{
  4387. // try
  4388. // {
  4389. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  4390. // if (data.Code != 0)
  4391. // {
  4392. // return Ok(JsonView(false, data.Msg));
  4393. // }
  4394. // return Ok(JsonView(true, "查询成功!"));
  4395. // }
  4396. // catch (Exception ex)
  4397. // {
  4398. // return Ok(JsonView(false, ex.Message));
  4399. // throw;
  4400. // }
  4401. //}
  4402. /// <summary>
  4403. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4404. /// </summary>
  4405. /// <returns></returns>
  4406. [HttpPost]
  4407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4408. public async Task<IActionResult> SetDayAndCostAreaChange()
  4409. {
  4410. try
  4411. {
  4412. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4413. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4414. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4415. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4416. foreach (var item in unite) //处理交集数据
  4417. {
  4418. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4419. }
  4420. foreach (var item in merge) //处理差集数据
  4421. {
  4422. int nationalTravelFeeId = 0;
  4423. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4424. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4425. else
  4426. {
  4427. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4428. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4429. }
  4430. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4431. }
  4432. //只更新dayAndCost 的 nationalTravelFeeId;
  4433. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4434. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4435. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4436. }
  4437. catch (Exception ex)
  4438. {
  4439. return Ok(JsonView(false, ex.Message));
  4440. throw;
  4441. }
  4442. }
  4443. /// <summary>
  4444. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4445. /// </summary>
  4446. /// <returns></returns>
  4447. [HttpPost]
  4448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4449. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4450. {
  4451. try
  4452. {
  4453. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4454. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4455. //SetDataInfoView
  4456. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4457. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4458. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4459. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4460. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4461. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4462. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4463. //默认币种显示
  4464. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4465. {
  4466. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4467. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4468. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4469. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4470. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4471. };
  4472. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4473. if (_currencyRate.Count > 0)
  4474. {
  4475. foreach (var item in _currencyInfos)
  4476. {
  4477. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4478. if (rateInfo != null)
  4479. {
  4480. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4481. rate1 *= 1.035M;
  4482. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4483. }
  4484. }
  4485. }
  4486. return Ok(JsonView(true, "查询成功!", new
  4487. {
  4488. GroupNameData = groupNameData.Data,
  4489. CurrencyData = _CurrencyData,
  4490. WordTypeData = _WordTypeData,
  4491. ExcelTypeData = _ExcelTypeData,
  4492. CurrencyInit = _currencyInfos
  4493. }));
  4494. }
  4495. catch (Exception ex)
  4496. {
  4497. return Ok(JsonView(false, ex.Message));
  4498. throw;
  4499. }
  4500. }
  4501. /// <summary>
  4502. /// 团组模块 - 出入境费用
  4503. /// 实时汇率 tips
  4504. /// 签证费用 tips
  4505. /// </summary>
  4506. /// <returns></returns>
  4507. [HttpPost]
  4508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4509. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4510. {
  4511. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4512. //默认币种显示
  4513. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4514. {
  4515. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4516. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4517. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4518. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4519. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4520. };
  4521. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4522. List<dynamic> reteInfos = new List<dynamic>();
  4523. if (_currencyRate.Count > 0)
  4524. {
  4525. foreach (var item in _currencyInfos)
  4526. {
  4527. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4528. if (rateInfo != null)
  4529. {
  4530. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4531. decimal rate1 = item.Rate;
  4532. rate1 *= 1.03M;
  4533. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4534. reteInfos.Add(new
  4535. {
  4536. currCode = item.CurrencyCode,
  4537. currName = item.CurrencyName,
  4538. rate = rate2,
  4539. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4540. });
  4541. }
  4542. }
  4543. }
  4544. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4545. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4546. return Ok(JsonView(true, "查询成功!", new
  4547. {
  4548. //GroupNameData = groupNameData.Data,
  4549. visaData = visaData.Data,
  4550. airData = airData.Data,
  4551. reteInfos = reteInfos
  4552. }));
  4553. }
  4554. /// <summary>
  4555. /// 团组模块 - 出入境费用 - Info
  4556. /// </summary>
  4557. /// <returns></returns>
  4558. [HttpPost]
  4559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4560. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4561. {
  4562. try
  4563. {
  4564. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  4565. if (data.Code != 0)
  4566. {
  4567. return Ok(JsonView(false, data.Msg));
  4568. }
  4569. return Ok(JsonView(true, "查询成功!", data.Data));
  4570. }
  4571. catch (Exception ex)
  4572. {
  4573. return Ok(JsonView(false, ex.Message));
  4574. }
  4575. }
  4576. /// <summary>
  4577. /// 团组模块 - 出入境费用 - Add And Update
  4578. /// </summary>
  4579. /// <returns></returns>
  4580. [HttpPost]
  4581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4582. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4583. {
  4584. try
  4585. {
  4586. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4587. if (data.Code != 0)
  4588. {
  4589. return Ok(JsonView(false, data.Msg));
  4590. }
  4591. //生成默认文件pdf并且通知人员
  4592. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4593. {
  4594. DiId = dto.DiId,
  4595. ExportType = 1,
  4596. SubTypeId = 1005
  4597. }, "pdf");
  4598. //发送通知
  4599. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4600. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4601. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4602. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4603. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4604. //汇率信息记录
  4605. await GeneralMethod.RateRecordSave(dto.UserId,sign,"出入境费用");
  4606. return Ok(JsonView(true, data.Msg, data.Data));
  4607. }
  4608. catch (Exception ex)
  4609. {
  4610. return Ok(JsonView(false, ex.Message));
  4611. }
  4612. }
  4613. /// <summary>
  4614. /// 团组模块 - 出入境费用 - Confirm 费用
  4615. /// </summary>
  4616. /// <returns></returns>
  4617. [HttpPost]
  4618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4619. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4620. {
  4621. //TODO:测试完毕需把对应的用户ID更改
  4622. //1、数据表添加字段
  4623. //2、更改字段接口()
  4624. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4625. //3、确认成功 给财务发送消息
  4626. if (_view.Code == 200)
  4627. {
  4628. if (dto.Type == 1)
  4629. {
  4630. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4631. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4632. }
  4633. }
  4634. return Ok(_view);
  4635. }
  4636. /// <summary>
  4637. /// 团组模块 - 出入境费用 - File downlaod
  4638. /// </summary>
  4639. /// <param name="dto"></param>
  4640. /// <returns></returns>
  4641. [HttpPost]
  4642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4643. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4644. {
  4645. try
  4646. {
  4647. if (dto.DiId < 1)
  4648. {
  4649. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4650. }
  4651. if (dto.ExportType < 1)
  4652. {
  4653. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  4654. }
  4655. if (dto.SubTypeId < 1)
  4656. {
  4657. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  4658. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4659. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4660. 3 团组成员名单 1 团组成员名单"));
  4661. }
  4662. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4663. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4664. if (_EnterExitCosts == null)
  4665. {
  4666. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  4667. }
  4668. //数据源
  4669. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4670. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4671. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4672. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4673. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4674. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4675. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4676. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4677. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4678. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4679. .Select((tcl, dc, cc) => new
  4680. {
  4681. Name = dc.LastName + dc.FirstName,
  4682. Sex = dc.Sex,
  4683. Birthday = dc.BirthDay,
  4684. Company = cc.CompanyFullName,
  4685. Job = dc.Job
  4686. })
  4687. .ToList();
  4688. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4689. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4690. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4691. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4692. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4693. if (dto.ExportType == 1) //明细表
  4694. {
  4695. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4696. {
  4697. //获取模板
  4698. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4699. //载入模板
  4700. Document doc = new Document(tempPath);
  4701. DocumentBuilder builder = new DocumentBuilder(doc);
  4702. //利用键值对存放数据
  4703. Dictionary<string, string> dic = new Dictionary<string, string>();
  4704. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4705. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4706. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4707. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4708. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4709. //境内费用(其他费用)
  4710. if (_EnterExitCosts.ChoiceOne == 1)
  4711. {
  4712. string row1_1 = "";
  4713. if (_EnterExitCosts.Visa > 0)
  4714. {
  4715. //insidePayTotal += _EnterExitCosts.Visa;
  4716. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4717. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4718. {
  4719. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4720. }
  4721. }
  4722. string row1_2 = "";
  4723. if (_EnterExitCosts.YiMiao > 0)
  4724. {
  4725. //insidePayTotal += _EnterExitCosts.YiMiao;
  4726. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4727. }
  4728. if (_EnterExitCosts.HeSuan > 0)
  4729. {
  4730. //insidePayTotal += _EnterExitCosts.HeSuan;
  4731. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4732. }
  4733. if (_EnterExitCosts.Service > 0)
  4734. {
  4735. //insidePayTotal += _EnterExitCosts.Service;
  4736. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4737. }
  4738. string row1_3 = "";
  4739. if (_EnterExitCosts.Safe > 0)
  4740. {
  4741. //insidePayTotal += _EnterExitCosts.Safe;
  4742. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4743. }
  4744. if (_EnterExitCosts.Ticket > 0)
  4745. {
  4746. //insidePayTotal += _EnterExitCosts.Ticket;
  4747. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4748. }
  4749. string row1 = "";
  4750. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4751. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4752. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4753. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4754. dic.Add("Row1Str", row1);
  4755. }
  4756. string airTotalStr = string.Empty,
  4757. airPriceStr = string.Empty;
  4758. //经济舱
  4759. if (_EnterExitCosts.SumJJC == 1)
  4760. {
  4761. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4762. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4763. }
  4764. //公务舱
  4765. if (_EnterExitCosts.SumGWC == 1)
  4766. {
  4767. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4768. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4769. }
  4770. //头等舱
  4771. if (_EnterExitCosts.SumTDC == 1)
  4772. {
  4773. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4774. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4775. }
  4776. dic.Add("AirTotalStr", airTotalStr);
  4777. dic.Add("AirPriceStr", airPriceStr);
  4778. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4779. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4780. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4781. int table1Row = 0,
  4782. table2Row = 0,
  4783. table3Row = 0,
  4784. table4Row = 0;
  4785. //住宿费
  4786. if (_EnterExitCosts.ChoiceThree == 1)
  4787. {
  4788. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4789. table1Row = dac1.Count;
  4790. #region 填充word表格内容
  4791. for (int i = 0; i < dac1.Count; i++)
  4792. {
  4793. Grp_DayAndCost dac = dac1[i];
  4794. if (dac == null) continue;
  4795. builder.MoveToCell(0, i, 0, 0);
  4796. builder.Write("第" + dac.Days.ToString() + "晚:");
  4797. builder.MoveToCell(0, i, 1, 0);
  4798. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4799. //builder.Write(dac.Place == null ? "" : dac.Place);
  4800. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4801. builder.MoveToCell(0, i, 2, 0);
  4802. builder.Write("费用标准:");
  4803. string curr = "";
  4804. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4805. if (currData != null)
  4806. {
  4807. curr = currData.Name;
  4808. }
  4809. builder.MoveToCell(0, i, 3, 0);
  4810. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4811. builder.MoveToCell(0, i, 4, 0);
  4812. builder.Write("费用小计:");
  4813. builder.MoveToCell(0, i, 5, 0);
  4814. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4815. }
  4816. #endregion
  4817. }
  4818. else dic.Add("SubZS", "0.00");
  4819. //删除多余行
  4820. while (table1.Rows.Count > table1Row)
  4821. {
  4822. table1.Rows.RemoveAt(table1Row);
  4823. }
  4824. //伙食费
  4825. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4826. if (_EnterExitCosts.ChoiceFour == 1)
  4827. {
  4828. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4829. table2Row = dac2.Count;
  4830. #region 填充word表格内容
  4831. for (int i = 0; i < dac2.Count; i++)
  4832. {
  4833. Grp_DayAndCost dac = dac2[i];
  4834. if (dac == null) continue;
  4835. builder.MoveToCell(1, i, 0, 0);
  4836. builder.Write("第" + dac.Days.ToString() + "天:");
  4837. builder.MoveToCell(1, i, 1, 0);
  4838. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4839. builder.MoveToCell(1, i, 2, 0);
  4840. builder.Write("费用标准:");
  4841. string curr = "";
  4842. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4843. if (currData != null)
  4844. {
  4845. curr = currData.Name;
  4846. }
  4847. builder.MoveToCell(1, i, 3, 0);
  4848. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4849. builder.MoveToCell(1, i, 4, 0);
  4850. builder.Write("费用小计:");
  4851. builder.MoveToCell(1, i, 5, 0);
  4852. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4853. }
  4854. #endregion
  4855. }
  4856. else dic.Add("SubHS", "0.00");
  4857. //删除多余行
  4858. while (table2.Rows.Count > table2Row)
  4859. {
  4860. table2.Rows.RemoveAt(table2Row);
  4861. }
  4862. //公杂费
  4863. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4864. if (_EnterExitCosts.ChoiceFive == 1)
  4865. {
  4866. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4867. table3Row = dac3.Count;
  4868. #region 填充word表格内容
  4869. for (int i = 0; i < dac3.Count; i++)
  4870. {
  4871. Grp_DayAndCost dac = dac3[i];
  4872. if (dac == null) continue;
  4873. builder.MoveToCell(2, i, 0, 0);
  4874. builder.Write("第" + dac.Days.ToString() + "天:");
  4875. builder.MoveToCell(2, i, 1, 0);
  4876. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4877. builder.MoveToCell(2, i, 2, 0);
  4878. builder.Write("费用标准:");
  4879. string curr = "";
  4880. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4881. if (currData != null)
  4882. {
  4883. curr = currData.Name;
  4884. }
  4885. builder.MoveToCell(2, i, 3, 0);
  4886. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4887. builder.MoveToCell(2, i, 4, 0);
  4888. builder.Write("费用小计:");
  4889. builder.MoveToCell(2, i, 5, 0);
  4890. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4891. }
  4892. //删除多余行
  4893. while (table3.Rows.Count > table3Row)
  4894. {
  4895. table3.Rows.RemoveAt(table3Row);
  4896. }
  4897. #endregion
  4898. }
  4899. else dic.Add("SubGZF", "0.00");
  4900. //删除多余行
  4901. while (table3.Rows.Count > table3Row)
  4902. {
  4903. table3.Rows.RemoveAt(table3Row);
  4904. }
  4905. //培训费
  4906. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4907. if (_EnterExitCosts.ChoiceSix == 1)
  4908. {
  4909. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4910. dic.Add("SubPX", pxStr);
  4911. table4Row = dac4.Count;
  4912. #region 填充word表格内容
  4913. for (int i = 0; i < dac4.Count; i++)
  4914. {
  4915. Grp_DayAndCost dac = dac4[i];
  4916. if (dac == null) continue;
  4917. builder.MoveToCell(3, i, 0, 0);
  4918. builder.Write("第" + dac.Days.ToString() + "天:");
  4919. builder.MoveToCell(3, i, 1, 0);
  4920. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4921. builder.MoveToCell(3, i, 2, 0);
  4922. builder.Write("费用标准:");
  4923. string curr = "";
  4924. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4925. if (currData != null)
  4926. {
  4927. curr = currData.Name;
  4928. }
  4929. builder.MoveToCell(3, i, 3, 0);
  4930. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4931. builder.MoveToCell(3, i, 4, 0);
  4932. builder.Write("费用小计:");
  4933. builder.MoveToCell(3, i, 5, 0);
  4934. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4935. }
  4936. #endregion
  4937. }
  4938. //else dic.Add("SubPX","0.00");
  4939. //删除多余行
  4940. while (table4.Rows.Count > table4Row)
  4941. {
  4942. table4.Rows.RemoveAt(table4Row);
  4943. }
  4944. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
  4945. decimal subJJC = 0.00M,
  4946. subGWC = 0.00M,
  4947. subTDC = 0.00M;
  4948. //经济舱
  4949. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  4950. //公务舱
  4951. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  4952. //头等舱
  4953. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  4954. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4955. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4956. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  4957. #region 填充word模板书签内容
  4958. foreach (var key in dic.Keys)
  4959. {
  4960. builder.MoveToBookmark(key);
  4961. builder.Write(dic[key]);
  4962. }
  4963. #endregion
  4964. //文件名
  4965. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  4966. AsposeHelper.removewatermark_v2180();
  4967. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4968. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4969. return Ok(JsonView(true, "成功", new { Url = url }));
  4970. }
  4971. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4972. {
  4973. //获取模板
  4974. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4975. //载入模板
  4976. Document doc = new Document(tempPath);
  4977. DocumentBuilder builder = new DocumentBuilder(doc);
  4978. Dictionary<string, string> dic = new Dictionary<string, string>();
  4979. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4980. {
  4981. List<string> list = new List<string>();
  4982. try
  4983. {
  4984. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4985. foreach (var item in spilitArr)
  4986. {
  4987. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4988. var depCode = spDotandEmpty[2].Substring(0, 3);
  4989. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4990. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4991. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4992. list.Add(depName);
  4993. list.Add(arrName);
  4994. }
  4995. list = list.Distinct().ToList();
  4996. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4997. }
  4998. catch (Exception)
  4999. {
  5000. dic.Add("ReturnCode", "行程录入不正确!");
  5001. }
  5002. }
  5003. else
  5004. {
  5005. dic.Add("ReturnCode", "未录入行程!");
  5006. }
  5007. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5008. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5009. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5010. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5011. {
  5012. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5013. dic.Add("Day", sp.Days.ToString());
  5014. }
  5015. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5016. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5017. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5018. //dic.Add("Names", Names);
  5019. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5020. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5021. decimal dac1totalPrice = 0.00M;
  5022. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5023. foreach (var dac in dac1)
  5024. {
  5025. if (dac.SubTotal == 0.00M)
  5026. {
  5027. continue;
  5028. }
  5029. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5030. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5031. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5032. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5033. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5034. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5035. builder.Write(currency);//币种
  5036. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5037. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5038. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5039. builder.Write("");//人数
  5040. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5041. builder.Write("");//天数
  5042. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5043. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5044. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5045. decimal rate = 0.00M;
  5046. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5047. builder.Write(rate.ToString("#0.0000"));//汇率
  5048. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5049. decimal rbmPrice = dac.SubTotal;
  5050. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5051. accommodationStartIndex++;
  5052. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5053. }
  5054. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5055. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5056. {
  5057. table1.Rows.RemoveAt(i - 1);
  5058. foodandotherStartIndex--;
  5059. }
  5060. if (dac2.Count == dac3.Count)//国家 币种 金额
  5061. {
  5062. for (int i = 0; i < dac2.Count; i++)
  5063. {
  5064. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5065. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5066. }
  5067. }
  5068. decimal dac2totalPrice = 0.00M;
  5069. foreach (var dac in dac2)
  5070. {
  5071. if (dac.SubTotal == 0)
  5072. {
  5073. continue;
  5074. }
  5075. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5076. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5077. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5078. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5079. builder.Write(currency);//币种
  5080. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5081. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5082. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5083. builder.Write("");//人数
  5084. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5085. builder.Write("");//天数
  5086. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5087. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5088. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5089. decimal rate = 0.00M;
  5090. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5091. builder.Write(rate.ToString("#0.0000"));//汇率
  5092. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5093. decimal rbmPrice = dac.SubTotal;
  5094. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5095. foodandotherStartIndex++;
  5096. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5097. }
  5098. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5099. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5100. {
  5101. table1.Rows.RemoveAt(i - 1);
  5102. }
  5103. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5104. string otherFeeStr = "";
  5105. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5106. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5107. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5108. if (otherFeeStr.Length > 0)
  5109. {
  5110. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5111. otherFeeStr = $"({otherFeeStr})";
  5112. dic.Add("OtherFeeStr", otherFeeStr);
  5113. }
  5114. //总计
  5115. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5116. //国际旅费
  5117. string outsideAir = string.Empty;
  5118. string allPriceAir = string.Empty;
  5119. if (_EnterExitCosts.SumJJC == 1)
  5120. {
  5121. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5122. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5123. }
  5124. if (_EnterExitCosts.SumGWC == 1)
  5125. {
  5126. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5127. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5128. }
  5129. if (_EnterExitCosts.SumTDC == 1)
  5130. {
  5131. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5132. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5133. }
  5134. dic.Add("InTravelPrice", $"({outsideAir})");
  5135. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5136. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5137. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5138. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5139. foreach (var key in dic.Keys)
  5140. {
  5141. builder.MoveToBookmark(key);
  5142. builder.Write(dic[key]);
  5143. }
  5144. //模板文件名
  5145. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5146. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5147. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5148. return Ok(JsonView(true, "成功", new { Url = url }));
  5149. }
  5150. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5151. {
  5152. //获取模板
  5153. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5154. //载入模板
  5155. WorkbookDesigner designer = new WorkbookDesigner();
  5156. designer.Workbook = new Workbook(tempPath);
  5157. Dictionary<string, string> dic = new Dictionary<string, string>();
  5158. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5159. {
  5160. List<string> list = new List<string>();
  5161. try
  5162. {
  5163. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5164. foreach (var item in spilitArr)
  5165. {
  5166. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5167. var depCode = spDotandEmpty[2].Substring(0, 3);
  5168. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5169. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5170. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5171. list.Add(depName);
  5172. list.Add(arrName);
  5173. }
  5174. list = list.Distinct().ToList();
  5175. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5176. }
  5177. catch (Exception)
  5178. {
  5179. dic.Add("ReturnCode", "行程录入不正确!");
  5180. }
  5181. }
  5182. else
  5183. {
  5184. dic.Add("ReturnCode", "未录入行程!");
  5185. }
  5186. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5187. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5188. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5189. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5190. {
  5191. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5192. dic.Add("Day", sp.Days.ToString());
  5193. }
  5194. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5195. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5196. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5197. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5198. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5199. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5200. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5201. designer.SetDataSource("Name", Names);
  5202. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5203. designer.SetDataSource("Day", dic["Day"] + "天");
  5204. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5205. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5206. int startIndex = 10;
  5207. const int startIndexcopy = 10;
  5208. if (dac2.Count == dac3.Count)//国家 币种 金额
  5209. {
  5210. for (int i = 0; i < dac2.Count; i++)
  5211. {
  5212. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5213. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5214. }
  5215. }
  5216. DataTable dtdac1 = new DataTable();
  5217. List<string> place = new List<string>();
  5218. dtdac1.Columns.AddRange(new DataColumn[] {
  5219. new DataColumn(){ ColumnName = "city"},
  5220. new DataColumn(){ ColumnName = "curr"},
  5221. new DataColumn(){ ColumnName = "criterion"},
  5222. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5223. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5224. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5225. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5226. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5227. });
  5228. DataTable dtdac2 = new DataTable();
  5229. dtdac2.Columns.AddRange(new DataColumn[] {
  5230. new DataColumn(){ ColumnName = "city"},
  5231. new DataColumn(){ ColumnName = "curr"},
  5232. new DataColumn(){ ColumnName = "criterion"},
  5233. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5234. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5235. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5236. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5237. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5238. });
  5239. dtdac1.TableName = "tb1";
  5240. dtdac2.TableName = "tb2";
  5241. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5242. foreach (var item in dac1)
  5243. {
  5244. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5245. if (place.Contains(item.Place))
  5246. {
  5247. continue;
  5248. }
  5249. DataRow row = dtdac1.NewRow();
  5250. row["city"] = item.Place;
  5251. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5252. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5253. row["curr"] = currency;
  5254. row["rate"] = rate.ToString("#0.0000");
  5255. row["criterion"] = item.Cost.ToString("#0.00");
  5256. row["number"] = 1;
  5257. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5258. //row["costRMB"] = rbmPrice;
  5259. dtdac1.Rows.Add(row);
  5260. place.Add(item.Place);
  5261. }
  5262. place = new List<string>();
  5263. foreach (var item in dac2)
  5264. {
  5265. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5266. if (place.Contains(item.Place))
  5267. {
  5268. continue;
  5269. }
  5270. DataRow row = dtdac2.NewRow();
  5271. row["city"] = item.Place;
  5272. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5273. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5274. row["curr"] = currency;
  5275. row["rate"] = rate.ToString("#0.0000");
  5276. row["criterion"] = item.Cost.ToString("#0.00");
  5277. row["number"] = 1;
  5278. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5279. //row["cost"] = item.SubTotal;
  5280. //row["costRMB"] = rbmPrice;
  5281. dtdac2.Rows.Add(row);
  5282. place.Add(item.Place);
  5283. //dac2totalPrice += rbmPrice;
  5284. }
  5285. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5286. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5287. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5288. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5289. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5290. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5291. string cell4Str1 = string.Empty;
  5292. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5293. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5294. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5295. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5296. string cellStr = $" 5.其他费用(";
  5297. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5298. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5299. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5300. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5301. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5302. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5303. if (cellStr.Length > 8)
  5304. {
  5305. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5306. }
  5307. cellStr += ")";
  5308. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  5309. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5310. decimal pxFee = dac4.Sum(it => it.Cost);
  5311. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5312. string celllastStr1 = "";
  5313. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5314. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5315. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5316. celllastStr1 += $",国际旅费 元";
  5317. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5318. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5319. designer.SetDataSource("cell4Str", cell4Str);
  5320. designer.SetDataSource("cellStr", cellStr);
  5321. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  5322. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5323. designer.SetDataSource("celllastStr", celllastStr);
  5324. Workbook wb = designer.Workbook;
  5325. var sheet = wb.Worksheets[0];
  5326. //绑定datatable数据集
  5327. designer.SetDataSource(dtdac1);
  5328. designer.SetDataSource(dtdac2);
  5329. designer.Process();
  5330. var rowStart = dtdac1.Rows.Count;
  5331. while (rowStart > 0)
  5332. {
  5333. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5334. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5335. startIndex++;
  5336. rowStart--;
  5337. }
  5338. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5339. startIndex += 1; //总计行
  5340. rowStart = dtdac2.Rows.Count;
  5341. while (rowStart > 0)
  5342. {
  5343. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5344. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5345. startIndex++;
  5346. rowStart--;
  5347. }
  5348. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5349. wb.CalculateFormula(true);
  5350. //模板文件名
  5351. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5352. designer.Workbook.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. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5357. {
  5358. //获取模板
  5359. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5360. //载入模板
  5361. Document doc = new Document(tempPath);
  5362. DocumentBuilder builder = new DocumentBuilder(doc);
  5363. Dictionary<string, string> dic = new Dictionary<string, string>();
  5364. dic.Add("GroupName", _DelegationInfo.TeamName);
  5365. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5366. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5367. string missionLeaderJob = "";//负责人job
  5368. int groupNumber = 0; //团人数
  5369. if (DeleClientList.Count > 0)
  5370. {
  5371. missionLeader = DeleClientList[0]?.Name ?? "";
  5372. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5373. }
  5374. dic.Add("MissionLeader", missionLeader); //团负责人
  5375. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5376. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5377. #region MyRegion
  5378. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5379. //{
  5380. // List<string> list = new List<string>();
  5381. // try
  5382. // {
  5383. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5384. // foreach (var item in spilitArr)
  5385. // {
  5386. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5387. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5388. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5389. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5390. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5391. // list.Add(depName);
  5392. // list.Add(arrName);
  5393. // }
  5394. // list = list.Distinct().ToList();
  5395. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5396. // }
  5397. // catch (Exception)
  5398. // {
  5399. // dic.Add("ReturnCode", "行程录入不正确!");
  5400. // }
  5401. //}
  5402. //else
  5403. //{
  5404. // dic.Add("ReturnCode", "未录入行程!");
  5405. //}
  5406. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5407. dic.Add("ReturnCode", string.Join("、", countrys));
  5408. #endregion
  5409. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5410. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5411. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5412. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5413. //{
  5414. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5415. // dic.Add("Day", sp.Days.ToString());
  5416. //}
  5417. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5418. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5419. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5420. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5421. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5422. //培训人员名单
  5423. int cultivateRowIndex = 7;
  5424. foreach (var item in DeleClientList)
  5425. {
  5426. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5427. builder.Write(item.Name);
  5428. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5429. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5430. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5431. string birthDay = "";
  5432. if (item.Birthday != null)
  5433. {
  5434. DateTime dt = Convert.ToDateTime(item.Birthday);
  5435. birthDay = $"{dt.Year}.{dt.Month}";
  5436. }
  5437. builder.Write(birthDay);
  5438. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5439. builder.Write(item.Company);
  5440. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5441. builder.Write(item.Job);
  5442. cultivateRowIndex++;
  5443. }
  5444. //删除多余行
  5445. //cultivateRowIndex -= 2;
  5446. int delRows = 10 + 7 - cultivateRowIndex;
  5447. if (delRows > 0)
  5448. {
  5449. for (int i = 0; i < delRows; i++)
  5450. {
  5451. table1.Rows.RemoveAt(cultivateRowIndex);
  5452. //cultivateRowIndex++;
  5453. }
  5454. }
  5455. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5456. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5457. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5458. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5459. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5460. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5461. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5462. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5463. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5464. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5465. //其他费用
  5466. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  5467. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5468. //其他费用合计
  5469. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5470. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5471. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5472. //公务舱合计
  5473. //国际旅费
  5474. string outsideJJ = "";
  5475. string allPriceJJ = "";
  5476. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5477. {
  5478. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5479. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5480. }
  5481. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5482. {
  5483. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5484. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5485. }
  5486. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5487. {
  5488. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5489. dic.Add("AirFeeTotal", airFeeTotalStr);
  5490. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5491. dic.Add("FeeTotal", feeTotalStr);
  5492. }
  5493. foreach (var key in dic.Keys)
  5494. {
  5495. builder.MoveToBookmark(key);
  5496. builder.Write(dic[key]);
  5497. }
  5498. //模板文件名
  5499. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5500. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5501. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5502. return Ok(JsonView(true, "成功", new { Url = url }));
  5503. }
  5504. }
  5505. else if (dto.ExportType == 2) //表格
  5506. {
  5507. //利用键值对存放数据
  5508. Dictionary<string, string> dic = new Dictionary<string, string>();
  5509. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5510. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5511. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5512. dic.Add("Day", sp.Days.ToString());
  5513. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5514. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5515. {
  5516. //获取模板
  5517. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5518. //载入模板
  5519. Document doc = new Document(tempPath);
  5520. DocumentBuilder builder = new DocumentBuilder(doc);
  5521. dic.Add("TeamName", _DelegationInfo.TeamName);
  5522. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5523. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5524. string missionLeaderName = "",
  5525. missionLeaderJob = "";
  5526. if (DeleClientList.Count > 0)
  5527. {
  5528. missionLeaderName = DeleClientList[0].Name;
  5529. missionLeaderJob = DeleClientList[0].Job;
  5530. }
  5531. dic.Add("MissionLeaderName", missionLeaderName);
  5532. dic.Add("MissionLeaderJob", missionLeaderJob);
  5533. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5534. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5535. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5536. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5537. int rowCount = 10;//总人数行
  5538. int startRowIndex = 7; //起始行
  5539. for (int i = 0; i < DeleClientList.Count; i++)
  5540. {
  5541. builder.MoveToCell(0, startRowIndex, 0, 0);
  5542. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5543. builder.MoveToCell(0, startRowIndex, 1, 0);
  5544. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5545. builder.Write(sex);//性别
  5546. builder.MoveToCell(0, startRowIndex, 2, 0);
  5547. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5548. builder.MoveToCell(0, startRowIndex, 3, 0);
  5549. builder.Write(DeleClientList[i].Company);//工作单位
  5550. builder.MoveToCell(0, startRowIndex, 4, 0);
  5551. builder.Write(DeleClientList[i].Job);//职务及级别
  5552. builder.MoveToCell(0, startRowIndex, 5, 0);
  5553. builder.Write("");//人员属性
  5554. builder.MoveToCell(0, startRowIndex, 6, 0);
  5555. builder.Write("");//上次出国时间
  5556. startRowIndex++;
  5557. }
  5558. int nullRow = rowCount - DeleClientList.Count;//空行
  5559. for (int i = 0; i < nullRow; i++)
  5560. {
  5561. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5562. }
  5563. foreach (var key in dic.Keys)
  5564. {
  5565. builder.MoveToBookmark(key);
  5566. builder.Write(dic[key]);
  5567. }
  5568. //模板文件名
  5569. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5570. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5571. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5572. return Ok(JsonView(true, "成功", new { Url = url }));
  5573. }
  5574. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5575. {
  5576. //获取模板
  5577. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5578. //载入模板
  5579. Document doc = new Document(tempPath);
  5580. DocumentBuilder builder = new DocumentBuilder(doc);
  5581. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5582. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5583. dic.Add("Names", Names);
  5584. int accommodationRows = 12, foodandotherRows = 12;
  5585. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5586. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5587. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5588. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5589. int accommodationStartIndex = 6;
  5590. decimal dac1totalPrice = 0.00M;
  5591. foreach (var dac in dac1)
  5592. {
  5593. if (dac.SubTotal == 0)
  5594. {
  5595. continue;
  5596. }
  5597. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5598. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5599. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5600. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5601. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5602. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5603. builder.Write(currency);//币种
  5604. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5605. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5606. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5607. builder.Write("");//人数
  5608. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5609. builder.Write("");//天数
  5610. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5611. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5612. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5613. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5614. builder.Write(rate.ToString("#0.0000"));//汇率
  5615. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5616. decimal rbmPrice = rate * dac.SubTotal;
  5617. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5618. accommodationStartIndex++;
  5619. dac1totalPrice += rbmPrice;
  5620. }
  5621. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5622. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5623. builder.Write("小计");
  5624. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5625. builder.Write(dac1totalPrice.ToString("#0.00"));
  5626. accommodationStartIndex++;
  5627. int nullRow = accommodationRows - dac1.Count;
  5628. //删除空行
  5629. //if (nullRow > 0)
  5630. //{
  5631. // int rowIndex = accommodationStartIndex;
  5632. // for (int i = 0; i < nullRow; i++)
  5633. // {
  5634. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5635. // row.Remove();
  5636. // rowIndex++;
  5637. // }
  5638. //}
  5639. if (dac2.Count == dac3.Count)//国家 币种 金额
  5640. {
  5641. for (int i = 0; i < dac2.Count; i++)
  5642. {
  5643. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5644. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5645. }
  5646. }
  5647. int foodandotherStartIndex = 19;//
  5648. decimal dac2totalPrice = 0.00M;
  5649. foreach (var dac in dac2)
  5650. {
  5651. if (dac.SubTotal == 0)
  5652. {
  5653. continue;
  5654. }
  5655. //foodandotherStartIndex = 12;
  5656. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5657. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5658. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5659. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5660. builder.Write(currency);//币种
  5661. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5662. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5663. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5664. builder.Write("");//人数
  5665. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5666. builder.Write("");//天数
  5667. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5668. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5669. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5670. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5671. builder.Write(rate.ToString("#0.0000"));//汇率
  5672. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5673. decimal rbmPrice = rate * dac.SubTotal;
  5674. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5675. foodandotherStartIndex++;
  5676. dac2totalPrice += rbmPrice;
  5677. }
  5678. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5679. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5680. //删除空行
  5681. //if (dac2.Count < foodandotherRows)
  5682. //{
  5683. // while (table2.Rows.Count > dac2.Count)
  5684. // {
  5685. // table2.Rows.RemoveAt(dac2.Count);
  5686. // }
  5687. //}
  5688. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5689. string otherFeeStr = "";
  5690. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5691. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5692. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5693. if (otherFeeStr.Length > 0)
  5694. {
  5695. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5696. otherFeeStr = $"({otherFeeStr})";
  5697. dic.Add("OtherFeeStr", otherFeeStr);
  5698. }
  5699. foreach (var key in dic.Keys)
  5700. {
  5701. builder.MoveToBookmark(key);
  5702. builder.Write(dic[key]);
  5703. }
  5704. //模板文件名
  5705. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5706. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5707. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5708. return Ok(JsonView(true, "成功", new { Url = url }));
  5709. }
  5710. }
  5711. else if (dto.ExportType == 3)
  5712. {
  5713. if (dto.SubTypeId == 1) //团组成员名单
  5714. {
  5715. if (DeleClientList.Count < 1)
  5716. {
  5717. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  5718. }
  5719. //获取模板
  5720. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5721. //载入模板
  5722. Document doc = new Document(tempPath);
  5723. DocumentBuilder builder = new DocumentBuilder(doc);
  5724. //获取word里所有表格
  5725. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5726. //获取所填表格的序数
  5727. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5728. var rowStart = tableOne.Rows[0]; //获取第1行
  5729. //循环赋值
  5730. for (int i = 0; i < DeleClientList.Count; i++)
  5731. {
  5732. builder.MoveToCell(0, i + 1, 0, 0);
  5733. builder.Write(DeleClientList[i].Name);
  5734. builder.MoveToCell(0, i + 1, 1, 0);
  5735. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5736. builder.Write(sex);
  5737. builder.MoveToCell(0, i + 1, 2, 0);
  5738. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5739. builder.MoveToCell(0, i + 1, 3, 0);
  5740. builder.Write(DeleClientList[i].Company);
  5741. builder.MoveToCell(0, i + 1, 4, 0);
  5742. builder.Write(DeleClientList[i].Job);
  5743. }
  5744. //删除多余行
  5745. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5746. {
  5747. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5748. }
  5749. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5750. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5751. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5752. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5753. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5754. return Ok(JsonView(true, "成功", new { Url = url }));
  5755. }
  5756. }
  5757. return Ok(JsonView(false, "操作失败!"));
  5758. }
  5759. catch (Exception ex)
  5760. {
  5761. return Ok(JsonView(false, ex.Message));
  5762. }
  5763. }
  5764. /// <summary>
  5765. /// 获取三公费用标准city
  5766. /// </summary>
  5767. /// <param name="placeData"></param>
  5768. /// <param name="nationalTravelFeeId"></param>
  5769. /// <returns></returns>
  5770. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5771. {
  5772. string _city = string.Empty;
  5773. if (placeData.Count < 1) return _city;
  5774. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5775. if (data == null) return _city;
  5776. string country = data.Country;
  5777. string city = data.City;
  5778. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5779. else _city = city;
  5780. return _city;
  5781. }
  5782. /// <summary>
  5783. /// 团组模块 - 出入境费用 - 明细表导出
  5784. /// </summary>
  5785. /// <returns></returns>
  5786. [HttpPost]
  5787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5788. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5789. {
  5790. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5791. if (data.Code != 0)
  5792. {
  5793. return Ok(JsonView(false, data.Msg));
  5794. }
  5795. return Ok(JsonView(true, data.Msg, data.Data));
  5796. }
  5797. /// <summary>
  5798. /// 团组模块 - 出入境费用 - 一键清空
  5799. /// </summary>
  5800. /// <returns></returns>
  5801. [HttpPost]
  5802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5803. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5804. {
  5805. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5806. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5807. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5808. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5809. if (_view.Code == 0)
  5810. {
  5811. return Ok(JsonView(true, "操作成功"));
  5812. }
  5813. return Ok(JsonView(false, "操作失败"));
  5814. }
  5815. /// <summary>
  5816. /// 团组模块 - 出入境费用 - 子项删除
  5817. /// </summary>
  5818. /// <returns></returns>
  5819. [HttpPost]
  5820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5821. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5822. {
  5823. try
  5824. {
  5825. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5826. if (data.Code != 0)
  5827. {
  5828. return Ok(JsonView(false, data.Msg));
  5829. }
  5830. return Ok(JsonView(true, "操作成功!", data.Data));
  5831. }
  5832. catch (Exception ex)
  5833. {
  5834. return Ok(JsonView(false, ex.Message));
  5835. }
  5836. }
  5837. /// <summary>
  5838. /// 团组模块 - 出入境国家费用标准 List
  5839. /// </summary>
  5840. /// <returns></returns>
  5841. [HttpPost]
  5842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5843. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5844. {
  5845. try
  5846. {
  5847. Stopwatch sw = new Stopwatch();
  5848. sw.Start();
  5849. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5850. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5851. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5852. Where gntf.Isdel = 0");
  5853. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5854. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5855. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  5856. //foreach (var item in nationalTravel)
  5857. //{
  5858. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  5859. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  5860. // if (otherData != null)
  5861. // {
  5862. // cityData.Remove(otherData);
  5863. // cityData.Add(otherData);
  5864. // }
  5865. // nationalTravelFeeData1.Add(new
  5866. // {
  5867. // Country = item.Country,
  5868. // CityData = cityData
  5869. // });
  5870. //}
  5871. sw.Stop();
  5872. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  5873. }
  5874. catch (Exception ex)
  5875. {
  5876. return Ok(JsonView(false, ex.Message));
  5877. throw;
  5878. }
  5879. }
  5880. /// <summary>
  5881. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  5882. /// </summary>
  5883. /// <returns></returns>
  5884. [HttpPost]
  5885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5886. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  5887. {
  5888. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  5889. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  5890. List<string> countryData = new List<string>();
  5891. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  5892. countryData = countryData.Distinct().ToList();
  5893. List<dynamic> dataSource = new List<dynamic>();
  5894. foreach (var item in countryData)
  5895. {
  5896. List<string> cityData1 = new List<string>();
  5897. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  5898. var countryData2 = new
  5899. {
  5900. CountryName = item,
  5901. CityData = cityData1
  5902. };
  5903. dataSource.Add(countryData2);
  5904. }
  5905. return Ok(JsonView(true, "查询成功!", dataSource));
  5906. }
  5907. /// <summary>
  5908. /// 团组模块 - 出入境国家费用标准 Page List
  5909. /// </summary>
  5910. /// <returns></returns>
  5911. [HttpPost]
  5912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5913. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  5914. {
  5915. int portId = dto.PortType;
  5916. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5917. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  5918. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  5919. string whereSql = string.Empty;
  5920. if (!string.IsNullOrEmpty(dto.Country))
  5921. {
  5922. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  5923. }
  5924. if (!string.IsNullOrEmpty(dto.City))
  5925. {
  5926. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  5927. }
  5928. string pageSql = string.Format(@"Select * From (
  5929. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  5930. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  5931. From Grp_NationalTravelFee gntf
  5932. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5933. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5934. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  5935. RefAsync<int> total = 0;
  5936. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  5937. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  5938. }
  5939. /// <summary>
  5940. /// 团组模块 - 出入境国家费用标准 根据城市查询
  5941. /// </summary>
  5942. /// <returns></returns>
  5943. [HttpPost]
  5944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5945. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  5946. {
  5947. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  5948. int portId = dto.PortType;
  5949. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5950. string whereSql = string.Empty;
  5951. if (!string.IsNullOrEmpty(dto.Country))
  5952. {
  5953. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  5954. }
  5955. if (!string.IsNullOrEmpty(dto.City))
  5956. {
  5957. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  5958. }
  5959. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  5960. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  5961. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  5962. From Grp_NationalTravelFee gntf
  5963. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5964. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5965. Where gntf.Isdel = 0 {0} ", whereSql);
  5966. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  5967. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  5968. }
  5969. /// <summary>
  5970. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  5971. /// </summary>
  5972. /// <returns></returns>
  5973. [HttpPost]
  5974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5975. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  5976. {
  5977. try
  5978. {
  5979. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  5980. if (data.Code != 0)
  5981. {
  5982. return Ok(JsonView(false, data.Msg));
  5983. }
  5984. return Ok(JsonView(true, "操作成功!", data.Data));
  5985. }
  5986. catch (Exception ex)
  5987. {
  5988. return Ok(JsonView(false, ex.Message));
  5989. }
  5990. }
  5991. /// <summary>
  5992. /// 团组模块 - 出入境国家费用标准 - Del
  5993. /// </summary>
  5994. /// <returns></returns>
  5995. [HttpPost]
  5996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5997. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  5998. {
  5999. try
  6000. {
  6001. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6002. {
  6003. Id = dto.Id,
  6004. DeleteUserId = dto.DeleteUserId,
  6005. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6006. IsDel = 1
  6007. };
  6008. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6009. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6010. .WhereColumns(it => new { it.Id })
  6011. .ExecuteCommandAsync();
  6012. if (delStatus <= 0)
  6013. {
  6014. return Ok(JsonView(false, "删除失败!"));
  6015. }
  6016. return Ok(JsonView(true, "操作成功!"));
  6017. }
  6018. catch (Exception ex)
  6019. {
  6020. return Ok(JsonView(false, ex.Message));
  6021. }
  6022. }
  6023. /// <summary>
  6024. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6025. /// 注:Get 请求Headers 加 Token
  6026. /// </summary>
  6027. /// <param name="groupId"></param>
  6028. /// <returns></returns>
  6029. [HttpGet("{groupId}")]
  6030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6031. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6032. {
  6033. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6034. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6035. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6036. data.ForEach(x =>
  6037. {
  6038. x.CreateUserId = _currUserInfo.UserId;
  6039. });
  6040. if (data.Count > 0)
  6041. {
  6042. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6043. if (add > 0)
  6044. {
  6045. return Ok(JsonView(true, "操作成功!"));
  6046. }
  6047. }
  6048. return Ok(JsonView(false, "未操作!"));
  6049. }
  6050. #endregion
  6051. #region 签证费用录入
  6052. /// <summary>
  6053. /// 根据diid查询签证费用列表
  6054. /// </summary>
  6055. /// <param name="dto"></param>
  6056. /// <returns></returns>
  6057. [HttpPost]
  6058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6059. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  6060. {
  6061. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  6062. if (groupData.Code != 0)
  6063. {
  6064. return Ok(JsonView(false, groupData.Msg));
  6065. }
  6066. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6067. }
  6068. /// <summary>
  6069. /// 根据签证费用Id查询单条数据及c表数据
  6070. /// </summary>
  6071. /// <param name="dto"></param>
  6072. /// <returns></returns>
  6073. [HttpPost]
  6074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6075. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  6076. {
  6077. try
  6078. {
  6079. Result groupData = await _visaPriceRep.PostVisaById(dto);
  6080. if (groupData.Code != 0)
  6081. {
  6082. return Ok(JsonView(false, groupData.Msg));
  6083. }
  6084. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6085. }
  6086. catch (Exception ex)
  6087. {
  6088. return Ok(JsonView(false, ex.Message));
  6089. }
  6090. }
  6091. /// <summary>
  6092. /// 签证费用删除
  6093. /// </summary>
  6094. /// <param name="dto"></param>
  6095. /// <returns></returns>
  6096. [HttpPost]
  6097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6098. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  6099. {
  6100. _sqlSugar.BeginTran();
  6101. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  6102. if (!res)
  6103. {
  6104. _sqlSugar.RollbackTran();
  6105. return Ok(JsonView(false, "删除失败"));
  6106. }
  6107. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  6108. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  6109. .SetColumns(a => new Grp_CreditCardPayment()
  6110. {
  6111. IsDel = 1,
  6112. DeleteUserId = dto.DeleteUserId,
  6113. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6114. })
  6115. .ExecuteCommand();
  6116. if (resSub < 1)
  6117. {
  6118. _sqlSugar.RollbackTran();
  6119. return Ok(JsonView(false, "删除失败"));
  6120. }
  6121. _sqlSugar.CommitTran();
  6122. return Ok(JsonView(true, "删除成功!"));
  6123. }
  6124. /// <summary>
  6125. /// 签证费用录入下拉框初始化
  6126. /// </summary>
  6127. /// <returns></returns>
  6128. [HttpPost]
  6129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6130. public async Task<IActionResult> VisaPriceAddSelect()
  6131. {
  6132. //支付方式
  6133. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  6134. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  6135. //币种
  6136. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  6137. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  6138. //乘客类型
  6139. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  6140. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  6141. //卡类型
  6142. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  6143. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  6144. var data = new
  6145. {
  6146. Payment = _Payment,
  6147. CurrencyList = _CurrencyList,
  6148. PassengerType = _PassengerType,
  6149. BankCard = _BankCard
  6150. };
  6151. return Ok(JsonView(true, "查询成功!", data));
  6152. }
  6153. /// <summary>
  6154. /// 签证费用录入操作(Status:1.新增,2.修改)
  6155. /// </summary>
  6156. /// <param name="dto"></param>
  6157. /// <returns></returns>
  6158. [HttpPost]
  6159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6160. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  6161. {
  6162. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  6163. if (groupData.Code != 0)
  6164. {
  6165. return Ok(JsonView(false, groupData.Msg));
  6166. }
  6167. #region 应用推送
  6168. try
  6169. {
  6170. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6171. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6172. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6173. //2024-10-21 新增LZ UID
  6174. var userIds = new List<int>() { 21 };
  6175. string title = $"系统通知";
  6176. string content = "";
  6177. var diId = dto.DiId;
  6178. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6179. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6180. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6181. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6182. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6183. }
  6184. catch (Exception ex)
  6185. {
  6186. }
  6187. #endregion
  6188. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6189. }
  6190. #endregion
  6191. #region 签证提成录入
  6192. /// <summary>
  6193. /// 签证提成录入
  6194. /// 基础数据
  6195. /// </summary>
  6196. /// <param name="_dto"></param>
  6197. /// <returns></returns>
  6198. [HttpGet]
  6199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6200. public async Task<IActionResult> VisaCommissionInit()
  6201. {
  6202. return Ok(await _visaCommissionRep.Init());
  6203. }
  6204. /// <summary>
  6205. /// 签证提成录入
  6206. /// Item
  6207. /// </summary>
  6208. /// <param name="_dto"></param>
  6209. /// <returns></returns>
  6210. [HttpPost]
  6211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6212. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  6213. {
  6214. var validator = new VisaCommissionItemDtoValidator();
  6215. var validatorRes = await validator.ValidateAsync(_dto);
  6216. if (!validatorRes.IsValid)
  6217. {
  6218. StringBuilder sb = new StringBuilder();
  6219. foreach (var item in validatorRes.Errors)
  6220. {
  6221. sb.AppendLine(item.ErrorMessage);
  6222. }
  6223. return Ok(JsonView(false, sb.ToString()));
  6224. }
  6225. return Ok(await _visaCommissionRep.Item(_dto));
  6226. }
  6227. /// <summary>
  6228. /// 签证提成录入
  6229. /// Save
  6230. /// </summary>
  6231. /// <param name="_dto"></param>
  6232. /// <returns></returns>
  6233. [HttpPost]
  6234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6235. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  6236. {
  6237. //参数验证
  6238. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  6239. foreach (var item in _dto.Items)
  6240. {
  6241. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  6242. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  6243. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  6244. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  6245. }
  6246. return Ok(await _visaCommissionRep.Save(_dto));
  6247. }
  6248. /// <summary>
  6249. /// 签证提成录入
  6250. /// Create
  6251. /// </summary>
  6252. /// <param name="_dto"></param>
  6253. /// <returns></returns>
  6254. [HttpPost]
  6255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6256. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  6257. {
  6258. var validator = new VisaCommissionCreateDtoValidator();
  6259. var validatorRes = await validator.ValidateAsync(_dto);
  6260. if (!validatorRes.IsValid)
  6261. {
  6262. StringBuilder sb = new StringBuilder();
  6263. foreach (var item in validatorRes.Errors)
  6264. {
  6265. sb.AppendLine(item.ErrorMessage);
  6266. }
  6267. return Ok(JsonView(false, sb.ToString()));
  6268. }
  6269. return Ok(await _visaCommissionRep.Create(_dto));
  6270. }
  6271. /// <summary>
  6272. /// 签证提成录入
  6273. /// Put(编辑)
  6274. /// </summary>
  6275. /// <param name="id"></param>
  6276. /// <param name="_dto"></param>
  6277. /// <returns></returns>
  6278. [HttpPut]
  6279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6280. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  6281. {
  6282. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6283. var validator = new VisaCommissionCreateDtoValidator();
  6284. var validatorRes = await validator.ValidateAsync(_dto);
  6285. if (!validatorRes.IsValid)
  6286. {
  6287. StringBuilder sb = new StringBuilder();
  6288. foreach (var item in validatorRes.Errors)
  6289. {
  6290. sb.AppendLine(item.ErrorMessage);
  6291. }
  6292. return Ok(JsonView(false, sb.ToString()));
  6293. }
  6294. return Ok(await _visaCommissionRep.Edit(id, _dto));
  6295. }
  6296. /// <summary>
  6297. /// 签证提成录入
  6298. /// Del
  6299. /// </summary>
  6300. /// <param name="id"></param>
  6301. /// <param name="currUserId"></param>
  6302. /// <returns></returns>
  6303. [HttpPost]
  6304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6305. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  6306. {
  6307. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6308. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  6309. return Ok(await _visaCommissionRep.Del(id, currUserId));
  6310. }
  6311. #endregion
  6312. #region op费用录入
  6313. /// <summary>
  6314. /// 根据diid查询op费用列表
  6315. /// </summary>
  6316. /// <param name="dto"></param>
  6317. /// <returns></returns>
  6318. [HttpPost]
  6319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6320. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  6321. {
  6322. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  6323. if (groupData.Code != 0)
  6324. {
  6325. return Ok(JsonView(false, groupData.Msg));
  6326. }
  6327. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6328. }
  6329. /// <summary>
  6330. /// 根据op费用Id查询单条数据及c表数据
  6331. /// </summary>
  6332. /// <param name="dto"></param>
  6333. /// <returns></returns>
  6334. [HttpPost]
  6335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6336. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  6337. {
  6338. try
  6339. {
  6340. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  6341. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  6342. var data = new
  6343. {
  6344. CarTouristGuideGround = _groupData,
  6345. CreditCardPayment = _creditCardPayment
  6346. };
  6347. return Ok(JsonView(true, "查询成功!", data));
  6348. }
  6349. catch (Exception ex)
  6350. {
  6351. return Ok(JsonView(false, "程序错误!"));
  6352. }
  6353. }
  6354. /// <summary>
  6355. /// op费用删除
  6356. /// </summary>
  6357. /// <param name="dto"></param>
  6358. /// <returns></returns>
  6359. [HttpPost]
  6360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6361. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  6362. {
  6363. try
  6364. {
  6365. _sqlSugar.BeginTran();
  6366. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  6367. if (!res)
  6368. {
  6369. return Ok(JsonView(false, "删除失败"));
  6370. }
  6371. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  6372. {
  6373. IsDel = 1,
  6374. DeleteUserId = dto.DeleteUserId,
  6375. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6376. }).ExecuteCommandAsync();
  6377. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  6378. {
  6379. IsDel = 1,
  6380. DeleteUserId = dto.DeleteUserId,
  6381. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6382. }).ExecuteCommandAsync();
  6383. #region 删除超支相关数据
  6384. //删除导入的超支数据
  6385. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  6386. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  6387. {
  6388. IsDel = 1,
  6389. DeleteUserId = dto.DeleteUserId,
  6390. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6391. }).ExecuteCommand();
  6392. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  6393. {
  6394. IsDel = 1,
  6395. DeleteUserId = dto.DeleteUserId,
  6396. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6397. }).ExecuteCommand();
  6398. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  6399. {
  6400. IsDel = 1,
  6401. DeleteUserId = dto.DeleteUserId,
  6402. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6403. }).ExecuteCommand();
  6404. #endregion
  6405. _sqlSugar.CommitTran();
  6406. return Ok(JsonView(true, "删除成功!"));
  6407. }
  6408. catch (Exception ex)
  6409. {
  6410. _sqlSugar.RollbackTran();
  6411. return Ok(JsonView(false, "程序错误!" + ex.Message));
  6412. }
  6413. }
  6414. /// <summary>
  6415. /// op费用录入操作(Status:1.新增,2.修改)
  6416. /// </summary>
  6417. /// <param name="dto"></param>
  6418. /// <returns></returns>
  6419. [HttpPost]
  6420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6421. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  6422. {
  6423. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  6424. if (groupData.Code != 0)
  6425. {
  6426. return Ok(JsonView(false, groupData.Msg));
  6427. }
  6428. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6429. }
  6430. /// <summary>
  6431. /// 填写费用详细页面初始化绑定
  6432. /// </summary>
  6433. /// <param name="dto"></param>
  6434. /// <returns></returns>
  6435. [HttpPost]
  6436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6437. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  6438. {
  6439. try
  6440. {
  6441. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  6442. if (groupData.Code != 0)
  6443. {
  6444. return Ok(JsonView(false, groupData.Msg));
  6445. }
  6446. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6447. }
  6448. catch (Exception ex)
  6449. {
  6450. return Ok(JsonView(false, ex.Message));
  6451. }
  6452. }
  6453. /// <summary>
  6454. /// 根据op费用Id查询详细数据
  6455. /// </summary>
  6456. /// <param name="dto"></param>
  6457. /// <returns></returns>
  6458. [HttpPost]
  6459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6460. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  6461. {
  6462. try
  6463. {
  6464. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  6465. if (groupData.Code != 0)
  6466. {
  6467. return Ok(JsonView(false, groupData.Msg));
  6468. }
  6469. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6470. }
  6471. catch (Exception ex)
  6472. {
  6473. return Ok(JsonView(false, ex.Message));
  6474. }
  6475. }
  6476. /// <summary>
  6477. /// OP费用录入填写详情
  6478. /// </summary>
  6479. /// <param name="dto"></param>
  6480. /// <returns></returns>
  6481. [HttpPost]
  6482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6483. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  6484. {
  6485. try
  6486. {
  6487. #region 参数校验
  6488. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  6489. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  6490. if (di == null) return Ok(JsonView(false, "团组错误!"));
  6491. #endregion
  6492. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  6493. if (groupData.Code != 0)
  6494. {
  6495. return Ok(JsonView(false, groupData.Msg));
  6496. }
  6497. //自动审核
  6498. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  6499. #region 应用推送
  6500. try
  6501. {
  6502. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6503. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6504. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6505. //2024-10-21 新增LZ UID
  6506. var userIds = new List<int>() { 21 };
  6507. string title = $"系统通知";
  6508. var diId = dto.DiId;
  6509. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6510. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6511. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  6512. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6513. }
  6514. catch (Exception ex)
  6515. {
  6516. }
  6517. #endregion
  6518. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6519. }
  6520. catch (Exception ex)
  6521. {
  6522. return Ok(JsonView(false, ex.Message));
  6523. }
  6524. }
  6525. /// <summary>
  6526. /// 获取三公详细所有城市
  6527. /// </summary>
  6528. /// <returns></returns>
  6529. [HttpGet]
  6530. public IActionResult OpCarCityResult()
  6531. {
  6532. var jw = JsonView(false);
  6533. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  6534. {
  6535. x.Id,
  6536. x.Country,
  6537. x.City,
  6538. }).ToList();
  6539. if (data.Count > 0)
  6540. {
  6541. jw = JsonView(true, "获取成功!", data);
  6542. }
  6543. else
  6544. {
  6545. jw.Msg = "城市数据为空!";
  6546. jw.Data = new string[0];
  6547. }
  6548. return Ok(jw);
  6549. }
  6550. /// <summary>
  6551. /// 导出地接费用明细
  6552. /// </summary>
  6553. /// <param name="dto"></param>
  6554. /// <returns></returns>
  6555. [HttpPost]
  6556. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  6557. {
  6558. var jw = JsonView(false);
  6559. if (dto.Diid < 1)
  6560. {
  6561. jw.Msg = "请输入正确的diid!";
  6562. return Ok(jw);
  6563. }
  6564. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6565. if (group == null)
  6566. {
  6567. jw.Msg = "未找到团组信息!";
  6568. return Ok(jw);
  6569. }
  6570. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  6571. if (localGuideArr.Count == 0)
  6572. {
  6573. jw.Msg = "该团组暂无地接信息!";
  6574. return Ok(jw);
  6575. }
  6576. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  6577. var overspendSoure = new Dictionary<int, int>
  6578. {
  6579. { 91, 982 }, //车
  6580. { 92 , 1059} ,//导游
  6581. { 994 , 1073}, //翻译
  6582. { 988 , 1074 }, //早餐
  6583. { 93 , 1075 }, //午餐
  6584. { 989 , 1076 }, //晚餐
  6585. };
  6586. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  6587. foreach (var groupArr in localGroup)
  6588. {
  6589. var keyValue = groupArr.Key;
  6590. if (int.TryParse(keyValue, out int cityid))
  6591. {
  6592. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  6593. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  6594. }
  6595. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  6596. foreach (var item in groupArr)
  6597. {
  6598. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  6599. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  6600. new Grp_CarTouristGuideGroundReservationsContentExtend
  6601. {
  6602. Count = a.Count,
  6603. CreateTime = a.CreateTime,
  6604. CreateUserId = a.CreateUserId,
  6605. CTGGRId = a.CTGGRId,
  6606. Currency = a.Currency,
  6607. DatePrice = a.DatePrice,
  6608. DeleteTime = a.DeleteTime,
  6609. DeleteUserId = a.DeleteUserId,
  6610. DiId = a.DiId,
  6611. Id = a.Id,
  6612. IsDel = a.IsDel,
  6613. Price = a.Price,
  6614. PriceContent = a.PriceContent,
  6615. Remark = a.Remark,
  6616. SId = a.SId,
  6617. SidName = b.Name,
  6618. Units = a.Units,
  6619. }
  6620. ).ToList();
  6621. if (content.Count > 0)
  6622. {
  6623. contentArr.Add(content);
  6624. }
  6625. }
  6626. //open excel
  6627. //set excel
  6628. //save excel
  6629. try
  6630. {
  6631. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  6632. IWorkbook workbook;
  6633. if (Path.GetExtension(filePath).ToLower() == ".xls")
  6634. {
  6635. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6636. }
  6637. else
  6638. {
  6639. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6640. }
  6641. ISheet sheet = workbook.GetSheetAt(0);
  6642. var rowStartIndex = 2;
  6643. var clounmCount = 10;
  6644. var initStyleRow = sheet.GetRow(2);
  6645. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  6646. //var overspendArrDetail =
  6647. var existsId = new List<CarCompare>();
  6648. var lastElem = arr.Last();
  6649. var thisSid = -1;
  6650. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  6651. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  6652. {
  6653. Name = "未知币种!",
  6654. Remark = "未知币种!",
  6655. };
  6656. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  6657. Action cloneRowFn = () =>
  6658. {
  6659. rowStartIndex++;
  6660. var cloneRow = sheet.CreateRow(rowStartIndex);
  6661. // 复制样式
  6662. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  6663. {
  6664. ICell sourceCell = initStyleRow.GetCell(i);
  6665. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  6666. // 确保单元格存在样式
  6667. if (sourceCell.CellStyle != null)
  6668. {
  6669. targetCell.CellStyle = sourceCell.CellStyle;
  6670. }
  6671. }
  6672. };
  6673. var mergeRow = () =>
  6674. {
  6675. for (int i = 2; i < sheet.LastRowNum; i++)
  6676. {
  6677. var row = sheet.GetRow(i);
  6678. var cellFirst = row.GetCell(0);
  6679. var thisIndex = i + 1;
  6680. while (thisIndex < sheet.LastRowNum)
  6681. {
  6682. var nextRow = sheet.GetRow(thisIndex);
  6683. var nextCellFirst = nextRow.GetCell(0);
  6684. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  6685. {
  6686. thisIndex++;
  6687. }
  6688. else
  6689. {
  6690. break;
  6691. }
  6692. }
  6693. thisIndex--;
  6694. if (thisIndex != i)
  6695. {
  6696. //合并row
  6697. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6698. i, // 起始行索引(0-based)
  6699. thisIndex, // 结束行索引(0-based)
  6700. 0, // 起始列索引(0-based)
  6701. 0 // 结束列索引(0-based)
  6702. );
  6703. sheet.AddMergedRegion(cellRangeAddress);
  6704. i = thisIndex;
  6705. }
  6706. }
  6707. };
  6708. var chaoshiNumber = 0;
  6709. var totalNumber = 0.00M;
  6710. string lastStr = "";
  6711. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  6712. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  6713. {
  6714. b.IsAuditGM,
  6715. x.Id,
  6716. x.Area,
  6717. b.PayPercentage,
  6718. b.PayMoney,
  6719. }).ToList();
  6720. string yesPayment = "", noPayment = "";
  6721. foreach (var item in queryCarArrByCityAndDiid)
  6722. {
  6723. if (item.IsAuditGM == 1)
  6724. {
  6725. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6726. }
  6727. else
  6728. {
  6729. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6730. }
  6731. }
  6732. lastStr = yesPayment + noPayment;
  6733. foreach (var item in arr)
  6734. {
  6735. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  6736. {
  6737. if (thisSid != item.SId)
  6738. {
  6739. if (thisSid == -1)
  6740. {
  6741. thisSid = item.SId;
  6742. }
  6743. else
  6744. {
  6745. //合并小计行
  6746. //创建合并区域的实例
  6747. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6748. rowStartIndex, // 起始行索引(0-based)
  6749. rowStartIndex, // 结束行索引(0-based)
  6750. 0, // 起始列索引(0-based)
  6751. 3 // 结束列索引(0-based)
  6752. );
  6753. sheet.AddMergedRegion(cellRangeAddress);
  6754. var CellStyle = workbook.CreateCellStyle();
  6755. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6756. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6757. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6758. for (int i = 0; i <= clounmCount; i++)
  6759. {
  6760. if (i > 6)
  6761. {
  6762. var CellStyle1 = workbook.CreateCellStyle();
  6763. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6764. IFont Font = workbook.CreateFont(); // 创建字体
  6765. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6766. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6767. CellStyle1.SetFont(Font);
  6768. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6769. }
  6770. else
  6771. {
  6772. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6773. }
  6774. }
  6775. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6776. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6777. //超时合计
  6778. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6779. //超时数
  6780. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6781. //超时合计费用
  6782. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6783. thisSid = item.SId;
  6784. cloneRowFn();
  6785. chaoshiNumber = 0;
  6786. totalNumber = 0;
  6787. }
  6788. }
  6789. IRow row = sheet.GetRow(rowStartIndex);
  6790. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6791. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6792. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6793. if (isOpenOverspendSoure)
  6794. {
  6795. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6796. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6797. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6798. }
  6799. for (int i = 0; i <= clounmCount; i++)
  6800. {
  6801. var cell = row.GetCell(i);
  6802. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6803. if (cell == null)
  6804. {
  6805. cell = row.CreateCell(i);
  6806. }
  6807. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6808. fontRed.CloneStyleFrom(cell.CellStyle);
  6809. IFont Font = workbook.CreateFont(); // 创建字体
  6810. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6811. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6812. fontRed.SetFont(Font);
  6813. byte[] rgb = new byte[3] { 255, 242, 204 };
  6814. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6815. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6816. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6817. if (workbook is XSSFWorkbook)
  6818. {
  6819. BackgroundColor255_242_204.FillForegroundColor = 0;
  6820. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6821. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6822. }
  6823. else
  6824. {
  6825. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6826. }
  6827. if (i == 1 || i > 6)
  6828. {
  6829. if (i > 6)
  6830. {
  6831. fontRed.FillForegroundColor = 0;
  6832. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6833. fontRed.FillPattern = FillPattern.SolidForeground;
  6834. }
  6835. cell.CellStyle = fontRed;
  6836. }
  6837. if (i > 2 && i < 7)
  6838. {
  6839. cell.CellStyle = BackgroundColor255_242_204;
  6840. }
  6841. cell.SetCellValue(setCellValue); //写入单元格
  6842. }
  6843. if (overspendSoure.ContainsKey(thisSid))
  6844. {
  6845. var overspendId = overspendSoure[thisSid];
  6846. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6847. }
  6848. cloneRowFn();
  6849. existsId.Add(new CarCompare
  6850. {
  6851. DataPrice = item.DatePrice.ObjToDate(),
  6852. Sid = item.SId
  6853. });
  6854. }
  6855. if (item.Equals(lastElem))
  6856. {
  6857. //合并小计行
  6858. //创建合并区域的实例
  6859. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6860. rowStartIndex, // 起始行索引(0-based)
  6861. rowStartIndex, // 结束行索引(0-based)
  6862. 0, // 起始列索引(0-based)
  6863. 3 // 结束列索引(0-based)
  6864. );
  6865. sheet.AddMergedRegion(cellRangeAddress);
  6866. var CellStyle = workbook.CreateCellStyle();
  6867. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6868. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6869. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6870. for (int i = 0; i <= clounmCount; i++)
  6871. {
  6872. if (i > 6)
  6873. {
  6874. var CellStyle1 = workbook.CreateCellStyle();
  6875. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6876. IFont Font = workbook.CreateFont(); // 创建字体
  6877. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6878. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6879. CellStyle1.SetFont(Font);
  6880. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6881. }
  6882. else
  6883. {
  6884. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6885. }
  6886. }
  6887. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6888. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6889. //超时合计
  6890. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6891. //超时数
  6892. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6893. //超时合计费用
  6894. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6895. cloneRowFn();
  6896. // 创建合并区域的实例
  6897. cellRangeAddress = new CellRangeAddress(
  6898. rowStartIndex, // 起始行索引(0-based)
  6899. rowStartIndex, // 结束行索引(0-based)
  6900. 0, // 起始列索引(0-based)
  6901. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  6902. );
  6903. // 添加合并区域
  6904. sheet.AddMergedRegion(cellRangeAddress);
  6905. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  6906. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  6907. }
  6908. }
  6909. mergeRow();
  6910. // 保存修改后的Excel文件到新文件
  6911. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  6912. // new FileStream(newFilePath, FileMode.CreateNew)
  6913. using (var stream = new MemoryStream())
  6914. {
  6915. workbook.Write(stream, true);
  6916. stream.Flush();
  6917. stream.Seek(0, SeekOrigin.Begin);
  6918. MemoryStream memoryStream = new MemoryStream();
  6919. stream.CopyTo(memoryStream);
  6920. memoryStream.Seek(0, SeekOrigin.Begin);
  6921. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  6922. }
  6923. workbook.Close();
  6924. workbook.Dispose();
  6925. }
  6926. catch (Exception ex)
  6927. {
  6928. jw.Msg = "出现异常!" + ex.Message;
  6929. return Ok(jw);
  6930. }
  6931. }
  6932. if (Zips.Count > 0)
  6933. {
  6934. IOOperatorHelper io = new IOOperatorHelper();
  6935. var byts = io.ConvertZipStream(Zips);
  6936. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  6937. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  6938. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  6939. }
  6940. else
  6941. {
  6942. jw.Msg = "暂无生成文件!";
  6943. }
  6944. return Ok(jw);
  6945. }
  6946. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  6947. {
  6948. string outStr = string.Empty;
  6949. switch (i)
  6950. {
  6951. case 0:
  6952. outStr = arr[0].SidName;
  6953. break;
  6954. case 1:
  6955. outStr = arr[0].DataPriceStr;
  6956. break;
  6957. case 2:
  6958. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  6959. break;
  6960. case 4:
  6961. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  6962. break;
  6963. case 7:
  6964. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6965. {
  6966. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  6967. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  6968. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  6969. }
  6970. break;
  6971. case 8:
  6972. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6973. {
  6974. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  6975. }
  6976. break;
  6977. case 9:
  6978. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6979. {
  6980. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  6981. }
  6982. break;
  6983. case 10:
  6984. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6985. {
  6986. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  6987. }
  6988. break;
  6989. }
  6990. return outStr;
  6991. }
  6992. #region OP行程单
  6993. /// <summary>
  6994. /// OP行程单初始化
  6995. /// </summary>
  6996. /// <param name="dto"></param>
  6997. /// <returns></returns>
  6998. [HttpPost]
  6999. public IActionResult InitOpTravel(InitOpTravelDto dto)
  7000. {
  7001. var jw = JsonView(false);
  7002. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  7003. var group = groupList.First();
  7004. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  7005. if (group == null)
  7006. {
  7007. jw.Msg = "暂无团组!";
  7008. return Ok(jw);
  7009. }
  7010. group = groupList.Find(x => x.Id == diid);
  7011. if (group == null)
  7012. {
  7013. jw.Msg = "请输入正确的团组ID!";
  7014. return Ok(jw);
  7015. }
  7016. string city = string.Empty;
  7017. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  7018. if (blackCode.Count > 0)
  7019. {
  7020. var black = blackCode.First();
  7021. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  7022. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  7023. if (blackSp.Length > 0)
  7024. {
  7025. try
  7026. {
  7027. var cityArrCode = new List<string>(20);
  7028. foreach (var item in blackSp)
  7029. {
  7030. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  7031. var IndexSelect = itemSp[2];
  7032. var cityArrCodeLength = cityArrCode.Count - 1;
  7033. var startCity = IndexSelect.Substring(0, 3);
  7034. if (cityArrCodeLength > 0)
  7035. {
  7036. var arrEndCity = cityArrCode[cityArrCodeLength];
  7037. if (arrEndCity != startCity)
  7038. {
  7039. cityArrCode.Add(startCity.ToUpper());
  7040. }
  7041. }
  7042. else
  7043. {
  7044. cityArrCode.Add(startCity.ToUpper());
  7045. }
  7046. var endCity = IndexSelect.Substring(3, 3);
  7047. cityArrCode.Add(endCity.ToUpper());
  7048. }
  7049. var cityThree = string.Empty;
  7050. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  7051. cityThree = cityThree.TrimEnd(',');
  7052. if (string.IsNullOrWhiteSpace(cityThree))
  7053. {
  7054. throw new
  7055. Exception("error");
  7056. }
  7057. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  7058. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  7059. foreach (var item in cityArrCode)
  7060. {
  7061. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  7062. if (find != null)
  7063. {
  7064. city += find.City + "/";
  7065. }
  7066. else
  7067. {
  7068. city += item + "三字码未收入/";
  7069. }
  7070. }
  7071. city = city.TrimEnd('/');
  7072. }
  7073. catch (Exception e)
  7074. {
  7075. city = "黑屏代码格式不正确!";
  7076. }
  7077. }
  7078. }
  7079. else
  7080. {
  7081. city = "未录入黑屏代码";
  7082. }
  7083. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  7084. {
  7085. Date = x.Date,
  7086. Days = x.Days,
  7087. Diffgroup = x.Diffgroup,
  7088. Diid = x.Diid,
  7089. Traffic_First = x.Traffic_First,
  7090. Traffic_Second = x.Traffic_Second,
  7091. Trip = x.Trip,
  7092. WeekDay = x.WeekDay,
  7093. Id = x.Id
  7094. }).ToList();
  7095. jw.Data = new
  7096. {
  7097. groupList = groupList.Select(x => new
  7098. {
  7099. x.Id,
  7100. x.TeamName,
  7101. x.TourCode
  7102. }).ToList(),
  7103. groupInfo = new
  7104. {
  7105. group.VisitDays,
  7106. group.TourCode,
  7107. group.VisitPNumber,
  7108. group.TeamName,
  7109. city
  7110. },
  7111. OpTravelList
  7112. };
  7113. jw.Code = 200;
  7114. jw.Msg = "操作成功!";
  7115. return Ok(jw);
  7116. }
  7117. /// <summary>
  7118. /// 删除团组行程单
  7119. /// </summary>
  7120. /// <returns></returns>
  7121. [HttpPost]
  7122. public IActionResult DelTravel(DelOpTravelDto dto)
  7123. {
  7124. var jw = JsonView(false);
  7125. if (dto.UserId <= 0 || dto.Diid <= 0)
  7126. {
  7127. jw.Msg = "请输入正确的参数!";
  7128. return Ok(jw);
  7129. }
  7130. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  7131. .SetColumns(x => new Grp_TravelList
  7132. {
  7133. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7134. DeleteUserId = dto.UserId,
  7135. IsDel = 1,
  7136. }).ExecuteCommand();
  7137. jw = JsonView(true);
  7138. return Ok(jw);
  7139. }
  7140. /// <summary>
  7141. /// 行程单保存
  7142. /// </summary>
  7143. /// <returns></returns>
  7144. [HttpPost]
  7145. public IActionResult TravelSave(TravelSaveDto dto)
  7146. {
  7147. var jw = JsonView(false);
  7148. if (dto.Arr.Count > 0)
  7149. {
  7150. try
  7151. {
  7152. _sqlSugar.BeginTran();
  7153. foreach (var item in dto.Arr)
  7154. {
  7155. if (item.Id == 0)
  7156. {
  7157. throw new Exception("请传入正确的Id");
  7158. }
  7159. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  7160. .SetColumns(x => new Grp_TravelList
  7161. {
  7162. Trip = item.Trip
  7163. }).ExecuteCommand();
  7164. }
  7165. _sqlSugar.CommitTran();
  7166. jw = JsonView(true);
  7167. }
  7168. catch (Exception ex)
  7169. {
  7170. _sqlSugar.RollbackTran();
  7171. jw.Msg = "程序异常!" + ex.Message;
  7172. }
  7173. }
  7174. else
  7175. {
  7176. jw.Msg = "请传入正确的参数!";
  7177. }
  7178. return Ok(jw);
  7179. }
  7180. /// <summary>
  7181. /// 导出行程单
  7182. /// </summary>
  7183. /// <param name="dto"></param>
  7184. /// <returns></returns>
  7185. [HttpPost]
  7186. public IActionResult ExportTravel(ExportTravelDto dto)
  7187. {
  7188. var jw = JsonView(false);
  7189. jw.Data = "";
  7190. int diid = 0;
  7191. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  7192. if (Find == null)
  7193. {
  7194. jw.Msg = "请选择正确的团组!";
  7195. return Ok(jw);
  7196. }
  7197. else
  7198. {
  7199. diid = Find.Id;
  7200. }
  7201. //数据源
  7202. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  7203. DataTable dtBlack = null;
  7204. try
  7205. {
  7206. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  7207. }
  7208. catch (Exception)
  7209. {
  7210. jw.Msg = "机票黑屏代码有误!";
  7211. return Ok(jw);
  7212. }
  7213. string CityStr = string.Empty;
  7214. if (dtBlack.Rows.Count == 0)
  7215. {
  7216. jw.Msg = "机票黑屏代码有误!";
  7217. return Ok(jw);
  7218. }
  7219. else
  7220. {
  7221. foreach (DataRow row in dtBlack.Rows)
  7222. {
  7223. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  7224. {
  7225. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  7226. return Ok(jw);
  7227. }
  7228. }
  7229. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  7230. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  7231. }
  7232. //创建数据源Table
  7233. DataTable dtSource = new DataTable();
  7234. dtSource.Columns.Add("Days", typeof(string));
  7235. dtSource.Columns.Add("Date", typeof(string));
  7236. dtSource.Columns.Add("Week", typeof(string));
  7237. dtSource.Columns.Add("Traffic", typeof(string));
  7238. dtSource.Columns.Add("Trip", typeof(string));
  7239. //获取数据,放到datatable
  7240. foreach (var item in _travelList)
  7241. {
  7242. DataRow dr = dtSource.NewRow();
  7243. dr["Days"] = item.Days;
  7244. dr["Date"] = item.Date;
  7245. dr["Week"] = item.WeekDay;
  7246. dr["Traffic"] = item.Traffic_First
  7247. + "\r\n"
  7248. + item.Traffic_Second;
  7249. dr["Trip"] = item.Trip;
  7250. dtSource.Rows.Add(dr);
  7251. }
  7252. Dictionary<string, string> dic = new Dictionary<string, string>();
  7253. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  7254. dic.Add("City", CityStr);
  7255. dic.Add("Days", Find.VisitDays.ToString());
  7256. dic.Add("DeleCode", Find.TourCode);
  7257. dic.Add("Pnum", Find.VisitPNumber.ToString());
  7258. //模板路径
  7259. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  7260. //载入模板
  7261. Document doc = null;
  7262. DocumentBuilder builder = null;
  7263. try
  7264. {
  7265. //载入模板
  7266. doc = new Document(tempPath);
  7267. builder = new DocumentBuilder(doc);
  7268. }
  7269. catch (Exception)
  7270. {
  7271. jw.Msg = "模板位置不存在!";
  7272. return Ok(jw);
  7273. }
  7274. foreach (var key in dic.Keys)
  7275. {
  7276. Bookmark bookmark = doc.Range.Bookmarks[key];
  7277. if (bookmark != null)
  7278. {
  7279. builder.MoveToBookmark(key);
  7280. builder.Write(dic[key]);
  7281. }
  7282. }
  7283. //获取word里所有表格
  7284. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7285. //获取所填表格的序数
  7286. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7287. try
  7288. {
  7289. //循环赋值
  7290. for (int i = 0; i < dtSource.Rows.Count; i++)
  7291. {
  7292. builder.MoveToCell(0, i + 1, 0, 0);
  7293. builder.Write(dtSource.Rows[i]["Days"].ToString());
  7294. builder.MoveToCell(0, i + 1, 1, 0);
  7295. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  7296. builder.MoveToCell(0, i + 1, 2, 0);
  7297. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  7298. var trip = dtSource.Rows[i]["Trip"].ToString();
  7299. builder.MoveToCell(0, i + 1, 3, 0);
  7300. builder.Write(trip);
  7301. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  7302. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7303. // 获取特定索引的段落
  7304. Paragraph paragraph = (Paragraph)paragraphs[0];
  7305. Run run = paragraph.Runs[0];
  7306. Aspose.Words.Font font = run.Font;
  7307. font.Name = "黑体";
  7308. //设置双休红色
  7309. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  7310. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7311. paragraph = (Paragraph)paragraphs[1];
  7312. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  7313. {
  7314. run = paragraph.Runs[0];
  7315. font = run.Font;
  7316. font.Color = Color.Red;
  7317. }
  7318. }
  7319. }
  7320. catch (Exception ex)
  7321. {
  7322. }
  7323. //删除多余行
  7324. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  7325. {
  7326. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  7327. }
  7328. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  7329. if (!Directory.Exists(savePath))
  7330. {
  7331. try
  7332. {
  7333. Directory.CreateDirectory(savePath);
  7334. }
  7335. catch
  7336. {
  7337. }
  7338. }
  7339. string path = savePath + Find.TeamName + "出访日程";
  7340. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  7341. try
  7342. {
  7343. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  7344. string postfix = ".docx";
  7345. if (dto.IsPDF == 1)
  7346. {
  7347. saveFormat = Aspose.Words.SaveFormat.Pdf;
  7348. postfix = ".pdf";
  7349. }
  7350. doc.Save(path + postfix, saveFormat);
  7351. jw = JsonView(true, "导出成功", ftpPath + postfix);
  7352. }
  7353. catch (Exception)
  7354. {
  7355. jw = JsonView(false);
  7356. }
  7357. return Ok(jw);
  7358. }
  7359. /// <summary>
  7360. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  7361. /// </summary>
  7362. /// <param name="num"></param>
  7363. /// <returns></returns>
  7364. string GetNum(string num)
  7365. {
  7366. string str = "";
  7367. switch (num)
  7368. {
  7369. case "1":
  7370. str = "一";
  7371. break;
  7372. case "2":
  7373. str = "二";
  7374. break;
  7375. case "3":
  7376. str = "三";
  7377. break;
  7378. case "4":
  7379. str = "四";
  7380. break;
  7381. case "5":
  7382. str = "五";
  7383. break;
  7384. case "6":
  7385. str = "六";
  7386. break;
  7387. case "7":
  7388. str = "七";
  7389. break;
  7390. case "8":
  7391. str = "八";
  7392. break;
  7393. case "9":
  7394. str = "九";
  7395. break;
  7396. case "10":
  7397. str = "十";
  7398. break;
  7399. case "11":
  7400. str = "十一";
  7401. break;
  7402. case "12":
  7403. str = "十二";
  7404. break;
  7405. case "一":
  7406. str = "1";
  7407. break;
  7408. case "二":
  7409. str = "2";
  7410. break;
  7411. case "三":
  7412. str = "3";
  7413. break;
  7414. case "四":
  7415. str = "4";
  7416. break;
  7417. case "五":
  7418. str = "5";
  7419. break;
  7420. case "六":
  7421. str = "6";
  7422. break;
  7423. case "七":
  7424. str = "7";
  7425. break;
  7426. case "八":
  7427. str = "8";
  7428. break;
  7429. case "九":
  7430. str = "9";
  7431. break;
  7432. case "十":
  7433. str = "10";
  7434. break;
  7435. case "十一":
  7436. str = "11";
  7437. break;
  7438. case "十二":
  7439. str = "12";
  7440. break;
  7441. }
  7442. return str;
  7443. }
  7444. #endregion
  7445. #endregion
  7446. #region 团组成本
  7447. /// <summary>
  7448. /// 团组成本数据初始化
  7449. /// </summary>
  7450. /// <param name="dto"></param>
  7451. /// <returns></returns>
  7452. [HttpPost]
  7453. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  7454. {
  7455. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  7456. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  7457. WHEN COUNT(*) >= 0 THEN 'True'
  7458. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  7459. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  7460. ").ToList(); //团组列表
  7461. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  7462. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  7463. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  7464. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  7465. if (groupinfoValue != null)
  7466. {
  7467. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  7468. var spArr = new string[1] { countryArr };
  7469. if (countryArr.Contains("|"))
  7470. {
  7471. spArr = countryArr.Split("|");
  7472. }
  7473. else if (countryArr.Contains("、"))
  7474. {
  7475. spArr = countryArr.Split("、");
  7476. }
  7477. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  7478. {
  7479. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  7480. if (dbQueryCountry != null)
  7481. {
  7482. visaCountryInfoArr.Add(dbQueryCountry);
  7483. }
  7484. }
  7485. }
  7486. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  7487. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  7488. var create = _GroupCostRepository.
  7489. CreateGroupCostByBlackCode(dto.Diid);
  7490. if (groupCost.Count == 0 && create.Code == 0)
  7491. {
  7492. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  7493. }
  7494. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  7495. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  7496. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  7497. groupCostMap = groupCostMap.Select(x =>
  7498. {
  7499. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  7500. {
  7501. x.Date = dataForamt.ToString("yyyy-MM-dd");
  7502. }
  7503. return x;
  7504. }).ToList();
  7505. //GroupCostParameter.Add(new
  7506. // Grp_GroupCostParameter());
  7507. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  7508. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  7509. return Ok(JsonView(new
  7510. {
  7511. groupList,
  7512. groupInfo,
  7513. groupChecks,
  7514. groupCost = groupCostMap,
  7515. hotelNumber,
  7516. GroupCostParameter = GroupCostParameterMap,
  7517. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  7518. {
  7519. x.VisaCountry,
  7520. x.VisaPrice,
  7521. x.Id,
  7522. }).ToList(),
  7523. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  7524. blackCodeIsTrue = create.Code == 0 ? true : false,
  7525. hotelIsTrue = hotelIsTrue,
  7526. }));
  7527. }
  7528. /// <summary>
  7529. /// 团组成本信息保存
  7530. /// </summary>
  7531. /// <param name="dto"></param>
  7532. /// <returns></returns>
  7533. [HttpPost]
  7534. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  7535. {
  7536. if (dto.Diid <= 0 || dto.Userid <= 0)
  7537. {
  7538. return Ok(JsonView(false));
  7539. }
  7540. JsonView jw = null;
  7541. bool isTrue = false;
  7542. #region 复制团组成本
  7543. //if (dto.Diid == 2581)
  7544. //{
  7545. // dto.Diid = 2599;
  7546. // dto.CheckBoxs.ForEach(x =>
  7547. // {
  7548. // x.Diid = 2599;
  7549. // });
  7550. // dto.GroupCosts.ForEach(x =>
  7551. // {
  7552. // x.Diid = 2599;
  7553. // });
  7554. // dto.CostTypeHotelNumbers.ForEach(x =>
  7555. // {
  7556. // x.Diid = 2599;
  7557. // });
  7558. // dto.GroupCostParameters.ForEach(x =>
  7559. // {
  7560. // x.DiId = 2599;
  7561. // });
  7562. //}
  7563. #endregion
  7564. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  7565. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  7566. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  7567. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  7568. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  7569. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  7570. try
  7571. {
  7572. _sqlSugar.BeginTran();
  7573. isTrue = await _GroupCostRepository.
  7574. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  7575. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  7576. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  7577. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  7578. _sqlSugar.CommitTran();
  7579. jw = JsonView(true, "保存成功!", isTrue);
  7580. }
  7581. catch (Exception)
  7582. {
  7583. _sqlSugar.RollbackTran();
  7584. jw = JsonView(false);
  7585. }
  7586. return Ok(jw);
  7587. }
  7588. /// <summary>
  7589. /// 司兼导数据
  7590. /// </summary>
  7591. /// <param name="dto"></param>
  7592. /// <returns></returns>
  7593. [HttpPost]
  7594. public IActionResult GetCarGuides(CarGuidesDto dto)
  7595. {
  7596. JsonView jw = null;
  7597. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  7598. jw = JsonView(true, "获取成功!", Data);
  7599. return Ok(jw);
  7600. }
  7601. /// <summary>
  7602. /// 导游数据
  7603. /// </summary>
  7604. /// <param name="dto"></param>
  7605. /// <returns></returns>
  7606. [HttpPost]
  7607. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  7608. {
  7609. JsonView jw = null;
  7610. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  7611. // 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
  7612. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  7613. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  7614. jw = JsonView(true, "获取成功!", Data);
  7615. return Ok(jw);
  7616. }
  7617. /// <summary>
  7618. /// 成本车数据
  7619. /// </summary>
  7620. /// <param name="dto"></param>
  7621. /// <returns></returns>
  7622. [HttpPost]
  7623. public IActionResult GetCarInfo(CarGuidesDto dto)
  7624. {
  7625. JsonView jw = null;
  7626. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  7627. jw = JsonView(true, "获取成功!", Data);
  7628. return Ok(jw);
  7629. }
  7630. /// <summary>
  7631. /// 景点数据
  7632. /// </summary>
  7633. /// <param name="dto"></param>
  7634. /// <returns></returns>
  7635. [HttpPost]
  7636. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  7637. {
  7638. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  7639. return Ok(JsonView(true, "获取成功!", Data));
  7640. }
  7641. /// <summary>
  7642. /// 成本通知
  7643. /// </summary>
  7644. /// <param name="dto"></param>
  7645. /// <returns></returns>
  7646. [HttpPost]
  7647. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  7648. {
  7649. if (dto.Diid < 0)
  7650. {
  7651. return Ok(JsonView(false));
  7652. }
  7653. JsonView jw = null;
  7654. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  7655. if (GroupCostParameter != null)
  7656. {
  7657. int IsShare = 0;
  7658. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  7659. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  7660. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  7661. string msg = string.Empty;
  7662. if (isTrue)
  7663. {
  7664. if (IsShare == 0)
  7665. {
  7666. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  7667. }
  7668. else
  7669. {
  7670. #region 企微通知对应岗位用户
  7671. try
  7672. {
  7673. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  7674. }
  7675. catch (Exception ex)
  7676. {
  7677. }
  7678. #endregion
  7679. msg = "通知成功,其他模块操作人员可见此成本信息!";
  7680. }
  7681. jw = JsonView(isTrue, msg, new { IsShare });
  7682. }
  7683. else
  7684. {
  7685. msg = "修改失败!";
  7686. jw = JsonView(isTrue, msg);
  7687. }
  7688. }
  7689. else
  7690. {
  7691. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  7692. }
  7693. return Ok(jw);
  7694. }
  7695. /// <summary>
  7696. /// 导出报价单
  7697. /// </summary>
  7698. /// <param name="dto"></param>
  7699. /// <returns></returns>
  7700. [HttpPost]
  7701. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  7702. {
  7703. if (dto.Diid == 0)
  7704. {
  7705. return Ok(JsonView(false, "请传递团组id"));
  7706. }
  7707. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7708. if (deleInfo.Code != 0)
  7709. {
  7710. return Ok(JsonView(false, "团组信息查询失败!"));
  7711. }
  7712. var di = deleInfo.Data as DelegationInfoWebView;
  7713. if (di != null)
  7714. {
  7715. di.TeamName = di.TeamName.Replace("|", "、");
  7716. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  7717. //文件名
  7718. string strFileName = di.TeamName + "-收款账单.doc";
  7719. //获取模板
  7720. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  7721. //载入模板
  7722. Document doc = new Document(tmppath);
  7723. decimal TotalPrice = 0.00M;
  7724. string itemStr = string.Empty;
  7725. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  7726. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7727. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7728. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7729. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7730. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7731. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7732. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7733. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7734. foreach (var cost in groupCostType)
  7735. {
  7736. var List = cost.ToList();
  7737. if (cost.Key == "A")
  7738. {
  7739. foreach (var ListItem in List)
  7740. {
  7741. if (ListItem.number > 0)
  7742. {
  7743. if (ListItem.code.Contains("TBR"))
  7744. {
  7745. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7746. }
  7747. else
  7748. {
  7749. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7750. }
  7751. TotalPrice += (ListItem.number * ListItem.price);
  7752. }
  7753. }
  7754. }
  7755. else
  7756. {
  7757. itemStr = itemStr.Insert(0, "A段\r\n");
  7758. itemStr += "B段\r\n";
  7759. foreach (var ListItem in List)
  7760. {
  7761. if (ListItem.number > 0)
  7762. {
  7763. if (ListItem.code.Contains("TBR"))
  7764. {
  7765. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7766. }
  7767. else
  7768. {
  7769. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7770. }
  7771. TotalPrice += (ListItem.number * ListItem.price);
  7772. }
  7773. }
  7774. }
  7775. }
  7776. #region 替换Word模板书签内容
  7777. Dictionary<string, string> marks = new Dictionary<string, string>();
  7778. marks.Add("To", di.ClientUnit);//付款方
  7779. marks.Add("ToTel", di.TellPhone);//付款方电话
  7780. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7781. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7782. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7783. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7784. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7785. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7786. marks.Add("PayItemContent", itemStr);//详细信息
  7787. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7788. #endregion
  7789. ////注
  7790. //if (doc.Range.Bookmarks["Attention"] != null)
  7791. //{
  7792. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7793. // mark.Text = frList[0].Attention;
  7794. //}
  7795. foreach (var item in marks.Keys)
  7796. {
  7797. if (doc.Range.Bookmarks[item] != null)
  7798. {
  7799. Bookmark mark = doc.Range.Bookmarks[item];
  7800. mark.Text = marks[item];
  7801. }
  7802. }
  7803. byte[] bytes = null;
  7804. using (MemoryStream stream = new MemoryStream())
  7805. {
  7806. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7807. bytes = stream.ToArray();
  7808. }
  7809. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7810. return Ok(JsonView(true, "", new
  7811. {
  7812. Data = bytes,
  7813. strFileName,
  7814. }));
  7815. }
  7816. else
  7817. {
  7818. return Ok(JsonView(false, "团组信息不存在!"));
  7819. }
  7820. }
  7821. /// <summary>
  7822. /// 导出团组成本
  7823. /// </summary>
  7824. /// <param name="dto"></param>
  7825. /// <returns></returns>
  7826. [HttpPost]
  7827. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7828. {
  7829. var jw = JsonView(false);
  7830. if (dto.Diid == 0)
  7831. {
  7832. return Ok(JsonView(false, "请传递团组id"));
  7833. }
  7834. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7835. if (deleInfo.Code != 0)
  7836. {
  7837. return Ok(JsonView(false, "团组信息查询失败!"));
  7838. }
  7839. var di = deleInfo.Data as DelegationInfoWebView;
  7840. if (di == null)
  7841. {
  7842. return Ok(JsonView(false, "团组信息查询失败!"));
  7843. }
  7844. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7845. WorkbookDesigner designer = new WorkbookDesigner();
  7846. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7847. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7848. for (int i = 0; i < List_GC.Count; i++)
  7849. {
  7850. GroupCost_Excel gc = new GroupCost_Excel();
  7851. gc.Id = List_GC[i].Id;
  7852. gc.Diid = List_GC[i].Diid.ToString();
  7853. gc.DAY = List_GC[i].DAY;
  7854. string week = "";
  7855. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7856. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7857. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7858. gc.ITIN = List_GC[i].ITIN;
  7859. gc.CarType = List_GC[i].CarType;
  7860. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7861. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7862. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7863. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7864. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7865. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7866. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7867. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7868. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7869. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7870. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7871. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7872. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7873. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7874. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7875. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7876. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7877. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7878. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7879. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7880. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7881. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7882. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7883. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7884. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7885. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7886. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7887. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7888. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7889. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7890. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7891. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7892. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7893. List_GC1.Add(gc);
  7894. }
  7895. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7896. dt.TableName = "TB";
  7897. //报表标题等不用dt的值
  7898. designer.SetDataSource("TeamName", dto.title.TeamName);
  7899. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7900. designer.SetDataSource("Tax", dto.title.Tax);
  7901. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7902. designer.SetDataSource("Currency", dto.title.Currency);
  7903. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7904. designer.SetDataSource("Rate", dto.title.Rate);
  7905. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7906. var Aparams = hotels.Find(x => x.Type == "Default");
  7907. if (Aparams == null)
  7908. {
  7909. return Ok(jw);
  7910. }
  7911. //酒店数量
  7912. var txtSGRNumber = Aparams.SGR.ToString();
  7913. var txtTBRNumber = Aparams.TBR.ToString();
  7914. var txtJSESNumber = Aparams.JSES.ToString();
  7915. var txtSUITENumbe = Aparams.SUITE.ToString();
  7916. if (dto.costType == "B")
  7917. {
  7918. Aparams = hotels.Find(x => x.Type == "A");
  7919. var Bparams = hotels.Find(x => x.Type == "B");
  7920. if (Aparams == null || Bparams == null)
  7921. {
  7922. return Ok(jw);
  7923. }
  7924. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7925. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7926. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7927. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7928. }
  7929. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7930. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7931. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7932. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7933. var ws = designer.Workbook.Worksheets[0];
  7934. int Row = List_GC.Count;
  7935. int startIndex = 11;
  7936. int HideRows = 0;
  7937. List<int> hideRowsList = new List<int>();
  7938. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7939. #region A段left数据
  7940. var left = dto.leftInfo.Find(x => x.Type == "A");
  7941. if (left == null)
  7942. {
  7943. return Ok(jw);
  7944. }
  7945. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7946. if (leftBindData != null)
  7947. {
  7948. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7949. designer.SetDataSource("VisaRS", leftBindData.rs);
  7950. designer.SetDataSource("VisaXS", leftBindData.xs);
  7951. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7952. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7953. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7954. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7955. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7956. }
  7957. else
  7958. {
  7959. hideRowsList.Add(Row + startIndex + HideRows);
  7960. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7961. }
  7962. HideRows += 2;
  7963. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7964. if (leftBindData != null)
  7965. {
  7966. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7967. designer.SetDataSource("BXRS", leftBindData.rs);
  7968. designer.SetDataSource("BXXS", leftBindData.xs);
  7969. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7970. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7971. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7972. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7973. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7974. }
  7975. else
  7976. {
  7977. hideRowsList.Add(Row + startIndex + HideRows);
  7978. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7979. }
  7980. HideRows += 2;
  7981. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7982. if (leftBindData != null)
  7983. {
  7984. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7985. designer.SetDataSource("HSRS", leftBindData.rs);
  7986. designer.SetDataSource("HSXS", leftBindData.xs);
  7987. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7988. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7989. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7990. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7991. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7992. }
  7993. else
  7994. {
  7995. hideRowsList.Add(Row + startIndex + HideRows);
  7996. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7997. }
  7998. HideRows += 2;
  7999. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8000. if (leftBindData != null)
  8001. {
  8002. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  8003. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  8004. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  8005. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8006. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8007. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8008. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8009. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8010. }
  8011. else
  8012. {
  8013. hideRowsList.Add(Row + startIndex + HideRows);
  8014. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8015. }
  8016. HideRows += 2;
  8017. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8018. if (leftBindData != null)
  8019. {
  8020. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  8021. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  8022. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  8023. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8024. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8025. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8026. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8027. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8028. }
  8029. else
  8030. {
  8031. hideRowsList.Add(Row + startIndex + HideRows);
  8032. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8033. }
  8034. HideRows += 2;
  8035. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8036. if (leftBindData != null)
  8037. {
  8038. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  8039. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  8040. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  8041. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8042. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8043. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8044. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8045. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8046. }
  8047. else
  8048. {
  8049. hideRowsList.Add(Row + startIndex + HideRows);
  8050. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8051. }
  8052. HideRows += 2;
  8053. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8054. if (leftBindData != null)
  8055. {
  8056. ////TBR
  8057. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  8058. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  8059. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  8060. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8061. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8062. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8063. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8064. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8065. }
  8066. else
  8067. {
  8068. hideRowsList.Add(Row + startIndex + HideRows);
  8069. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8070. }
  8071. HideRows += 2;
  8072. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8073. if (leftBindData != null)
  8074. {
  8075. ////SGR
  8076. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  8077. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  8078. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  8079. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8080. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8081. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8082. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8083. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8084. }
  8085. else
  8086. {
  8087. hideRowsList.Add(Row + startIndex + HideRows);
  8088. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8089. }
  8090. HideRows += 2;
  8091. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8092. if (leftBindData != null)
  8093. {
  8094. ////JS/ES
  8095. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  8096. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  8097. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  8098. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8099. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8100. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8101. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8102. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8103. }
  8104. else
  8105. {
  8106. hideRowsList.Add(Row + startIndex + HideRows);
  8107. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8108. }
  8109. HideRows += 2;
  8110. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8111. if (leftBindData != null)
  8112. {
  8113. ////SUITE
  8114. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  8115. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  8116. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  8117. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8118. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8119. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8120. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8121. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8122. }
  8123. else
  8124. {
  8125. hideRowsList.Add(Row + startIndex + HideRows);
  8126. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8127. }
  8128. HideRows += 2;
  8129. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8130. if (leftBindData != null)
  8131. {
  8132. designer.SetDataSource("DJDRCB", leftBindData.cb);
  8133. designer.SetDataSource("DJRS", leftBindData.rs);
  8134. designer.SetDataSource("DJXS", leftBindData.xs);
  8135. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8136. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8137. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8138. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8139. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8140. }
  8141. else
  8142. {
  8143. hideRowsList.Add(Row + startIndex + HideRows);
  8144. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8145. }
  8146. HideRows += 2;
  8147. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8148. if (leftBindData != null)
  8149. {
  8150. designer.SetDataSource("HCPCB", leftBindData.cb);
  8151. designer.SetDataSource("HCPRS", leftBindData.rs);
  8152. designer.SetDataSource("HCPXS", leftBindData.xs);
  8153. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8154. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8155. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8156. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8157. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8158. }
  8159. else
  8160. {
  8161. hideRowsList.Add(Row + startIndex + HideRows);
  8162. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8163. }
  8164. HideRows += 2;
  8165. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8166. if (leftBindData != null)
  8167. {
  8168. designer.SetDataSource("CPCB", leftBindData.cb);
  8169. designer.SetDataSource("CPRS", leftBindData.rs);
  8170. designer.SetDataSource("CPXS", leftBindData.xs);
  8171. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8172. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8173. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8174. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8175. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8176. }
  8177. else
  8178. {
  8179. hideRowsList.Add(Row + startIndex + HideRows);
  8180. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8181. }
  8182. HideRows += 2;
  8183. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8184. if (leftBindData != null)
  8185. {
  8186. designer.SetDataSource("GWDRCD", leftBindData.cb);
  8187. designer.SetDataSource("GWRS", leftBindData.rs);
  8188. designer.SetDataSource("GWXS", leftBindData.xs);
  8189. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8190. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8191. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8192. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8193. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8194. }
  8195. else
  8196. {
  8197. hideRowsList.Add(Row + startIndex + HideRows);
  8198. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8199. }
  8200. HideRows += 2;
  8201. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8202. if (leftBindData != null)
  8203. {
  8204. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  8205. designer.SetDataSource("LYJRS", leftBindData.rs);
  8206. designer.SetDataSource("LYJXS", leftBindData.xs);
  8207. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8208. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8209. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8210. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8211. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8212. }
  8213. else
  8214. {
  8215. hideRowsList.Add(Row + startIndex + HideRows);
  8216. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8217. }
  8218. #endregion
  8219. #region A段Right信息
  8220. var right = dto.rightInfo.Find(x => x.Type == "A");
  8221. if (right == null)
  8222. {
  8223. return Ok(jw);
  8224. }
  8225. HideRows += 4;
  8226. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8227. if (rightBindData != null)
  8228. {
  8229. //经济舱 + 双人间 TBR
  8230. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  8231. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  8232. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8233. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  8234. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8235. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8236. designer.SetDataSource("lblJJCTBRZLR", (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. else
  8242. {
  8243. hideRowsList.Add(Row + startIndex + HideRows);
  8244. }
  8245. HideRows += 2;
  8246. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8247. if (rightBindData != null)
  8248. {
  8249. //经济舱 + 单人间 SGR
  8250. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  8251. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  8252. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8253. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  8254. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8255. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8256. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8257. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8258. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8259. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8260. }
  8261. else
  8262. {
  8263. hideRowsList.Add(Row + startIndex + HideRows);
  8264. }
  8265. HideRows += 2;
  8266. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8267. if (rightBindData != null)
  8268. {
  8269. //公务舱 + 单人间 SGR
  8270. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  8271. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  8272. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8273. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  8274. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8275. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8276. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8277. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8278. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8279. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8280. }
  8281. else
  8282. {
  8283. hideRowsList.Add(Row + startIndex + HideRows);
  8284. }
  8285. HideRows += 2;
  8286. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8287. if (rightBindData != null)
  8288. {
  8289. //公务舱 + 小套房 JSES
  8290. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  8291. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  8292. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8293. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  8294. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8295. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8296. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8297. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8298. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8299. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8300. }
  8301. else
  8302. {
  8303. hideRowsList.Add(Row + startIndex + HideRows);
  8304. }
  8305. HideRows += 2;
  8306. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8307. if (rightBindData != null)
  8308. {
  8309. //公务舱 + 小套房 JSES
  8310. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  8311. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  8312. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8313. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  8314. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8315. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8316. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8317. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8318. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8319. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8320. }
  8321. else
  8322. {
  8323. hideRowsList.Add(Row + startIndex + HideRows);
  8324. }
  8325. HideRows += 2;
  8326. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8327. if (rightBindData != null)
  8328. {
  8329. //经济舱 + 大套房
  8330. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  8331. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  8332. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8333. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  8334. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8335. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8336. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8337. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8338. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8339. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8340. }
  8341. else
  8342. {
  8343. hideRowsList.Add(Row + startIndex + HideRows);
  8344. }
  8345. HideRows += 2;
  8346. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8347. if (rightBindData != null)
  8348. {
  8349. //头等舱 + 小套房 JSES
  8350. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  8351. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  8352. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8353. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  8354. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8355. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8356. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8357. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8358. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8359. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8360. }
  8361. else
  8362. {
  8363. hideRowsList.Add(Row + startIndex + HideRows);
  8364. }
  8365. HideRows += 2;
  8366. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8367. if (rightBindData != null)
  8368. {
  8369. //头等舱 + 大套房
  8370. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  8371. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  8372. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8373. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  8374. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8375. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8376. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8377. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8378. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8379. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8380. }
  8381. else
  8382. {
  8383. hideRowsList.Add(Row + startIndex + HideRows);
  8384. }
  8385. #endregion
  8386. #region B段标题清空
  8387. designer.SetDataSource("CostBDRCB", "");
  8388. designer.SetDataSource("CostBRS", "");
  8389. designer.SetDataSource("CostBXS", "");
  8390. designer.SetDataSource("CostBZCB", "");
  8391. designer.SetDataSource("CostBDRBJ", "");
  8392. designer.SetDataSource("CostBZBJ", "");
  8393. designer.SetDataSource("CostBDRLR", "");
  8394. designer.SetDataSource("CostBZLR", "");
  8395. designer.SetDataSource("CostBDRCBOM", "");
  8396. designer.SetDataSource("CostBRSOM", "");
  8397. designer.SetDataSource("CostBZCBOM", "");
  8398. designer.SetDataSource("CostBDRBJOM", "");
  8399. designer.SetDataSource("CostBZBJOM", "");
  8400. designer.SetDataSource("CostBDRLROM", "");
  8401. designer.SetDataSource("CostBZLROM", "");
  8402. #endregion
  8403. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  8404. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  8405. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  8406. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  8407. designer.SetDataSource("DJName", "地接(CNY)");
  8408. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  8409. designer.SetDataSource("CPName", "地接-船票(CNY)");
  8410. designer.SetDataSource("GWName", "公务(CNY)");
  8411. designer.SetDataSource("YQHName", "邀请函(CNY)");
  8412. designer.SetDataSource("LYJName", "零用金(CNY)");
  8413. designer.SetDataSource("HSName", "核酸检测(CNY)");
  8414. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  8415. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  8416. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  8417. designer.SetDataSource("BXName", "保险(CNY)");
  8418. designer.SetDataSource("VisaName", "签证(CNY)");
  8419. #region B段基本数据
  8420. if (dto.costType == "B")
  8421. {
  8422. left = dto.leftInfo.Find(x => x.Type == "B");
  8423. if (left == null)
  8424. {
  8425. return Ok(jw);
  8426. }
  8427. #region B段left数据
  8428. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  8429. if (leftBindData != null)
  8430. {
  8431. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  8432. designer.SetDataSource("BHSRS", leftBindData.rs);
  8433. designer.SetDataSource("BHSXS", leftBindData.xs);
  8434. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8435. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8436. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8437. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8438. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8439. }
  8440. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8441. if (leftBindData != null)
  8442. {
  8443. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  8444. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  8445. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  8446. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8447. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8448. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8449. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8450. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8451. }
  8452. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8453. if (leftBindData != null)
  8454. {
  8455. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  8456. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  8457. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  8458. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8459. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8460. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8461. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8462. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8463. }
  8464. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8465. if (leftBindData != null)
  8466. {
  8467. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  8468. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  8469. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  8470. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8471. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8472. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8473. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8474. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8475. }
  8476. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8477. if (leftBindData != null)
  8478. {
  8479. designer.SetDataSource("BHCPCB", leftBindData.cb);
  8480. designer.SetDataSource("BHCPRS", leftBindData.rs);
  8481. designer.SetDataSource("BHCPXS", leftBindData.xs);
  8482. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8483. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8484. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8485. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8486. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8487. }
  8488. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8489. if (leftBindData != null)
  8490. {
  8491. designer.SetDataSource("BCPCB", leftBindData.cb);
  8492. designer.SetDataSource("BCPRS", leftBindData.rs);
  8493. designer.SetDataSource("BCPXS", leftBindData.xs);
  8494. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8495. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8496. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8497. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8498. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8499. }
  8500. //TBR
  8501. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8502. if (leftBindData != null)
  8503. {
  8504. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  8505. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  8506. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  8507. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8508. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8509. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8510. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8511. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8512. }
  8513. //SGR
  8514. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8515. if (leftBindData != null)
  8516. {
  8517. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  8518. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  8519. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  8520. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8521. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8522. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8523. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8524. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8525. }
  8526. //JS/ES
  8527. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8528. if (leftBindData != null)
  8529. {
  8530. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  8531. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  8532. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  8533. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8534. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8535. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8536. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8537. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8538. }
  8539. //SUITE
  8540. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8541. if (leftBindData != null)
  8542. {
  8543. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  8544. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  8545. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  8546. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8547. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8548. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8549. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8550. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8551. }
  8552. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8553. if (leftBindData != null)
  8554. {
  8555. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  8556. designer.SetDataSource("BDJRS", leftBindData.rs);
  8557. designer.SetDataSource("BDJXS", leftBindData.xs);
  8558. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8559. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8560. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8561. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8562. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8563. }
  8564. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8565. if (leftBindData != null)
  8566. {
  8567. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  8568. designer.SetDataSource("BGWRS", leftBindData.rs);
  8569. designer.SetDataSource("BGWXS", leftBindData.xs);
  8570. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8571. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8572. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8573. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8574. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8575. }
  8576. #region 优化方案
  8577. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  8578. //excelBind.Add("零用金", new {
  8579. //cb="",
  8580. //rs="",
  8581. //xs ="",
  8582. //zcb = "",
  8583. //});
  8584. #endregion
  8585. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8586. if (leftBindData != null)
  8587. {
  8588. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  8589. designer.SetDataSource("BLYJRS", leftBindData.rs);
  8590. designer.SetDataSource("BLYJXS", leftBindData.xs);
  8591. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8592. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8593. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8594. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8595. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8596. }
  8597. #endregion
  8598. #region B段Right信息
  8599. right = dto.rightInfo.Find(x => x.Type == "B");
  8600. if (right == null)
  8601. {
  8602. return Ok(jw);
  8603. }
  8604. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8605. if (rightBindData != null)
  8606. {
  8607. //经济舱 + 双人间 TBR
  8608. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  8609. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  8610. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8611. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  8612. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8613. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8614. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8615. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8616. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8617. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8618. }
  8619. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8620. if (rightBindData != null)
  8621. {
  8622. //经济舱 + 单人间 SGR
  8623. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  8624. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  8625. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8626. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  8627. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8628. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8629. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8630. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8631. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8632. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8633. }
  8634. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8635. if (rightBindData != null)
  8636. {
  8637. //公务舱 + 单人间 SGR
  8638. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  8639. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  8640. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8641. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  8642. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8643. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8644. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8645. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8646. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8647. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8648. }
  8649. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8650. if (rightBindData != null)
  8651. {
  8652. //公务舱 + 小套房 JSES
  8653. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  8654. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  8655. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8656. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  8657. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8658. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8659. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8660. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8661. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8662. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8663. }
  8664. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8665. if (rightBindData != null)
  8666. {
  8667. //公务舱 + 小套房 JSES
  8668. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  8669. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  8670. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8671. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  8672. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8673. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8674. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8675. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8676. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8677. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8678. }
  8679. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8680. if (rightBindData != null)
  8681. {
  8682. //经济舱 + 大套房
  8683. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  8684. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  8685. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8686. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  8687. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8688. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8689. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8690. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8691. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8692. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8693. }
  8694. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8695. if (rightBindData != null)
  8696. {
  8697. //头等舱 + 小套房 JSES
  8698. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  8699. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  8700. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8701. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  8702. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8703. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8704. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8705. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8706. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8707. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8708. }
  8709. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8710. if (rightBindData != null)
  8711. {
  8712. //头等舱 + 大套房
  8713. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  8714. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  8715. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8716. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  8717. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8718. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8719. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8720. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8721. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8722. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8723. }
  8724. #endregion
  8725. #region 标题
  8726. designer.SetDataSource("CostBDRCB", "单人成本");
  8727. designer.SetDataSource("CostBRS", "人数");
  8728. designer.SetDataSource("CostBXS", "系数");
  8729. designer.SetDataSource("CostBZCB", "总成本");
  8730. designer.SetDataSource("CostBDRBJ", "单人报价");
  8731. designer.SetDataSource("CostBZBJ", "总报价");
  8732. designer.SetDataSource("CostBDRLR", "单人利润");
  8733. designer.SetDataSource("CostBZLR", "总利润");
  8734. designer.SetDataSource("CostBDRCBOM", "单人成本");
  8735. designer.SetDataSource("CostBRSOM", "人数");
  8736. designer.SetDataSource("CostBZCBOM", "总成本");
  8737. designer.SetDataSource("CostBDRBJOM", "单人报价");
  8738. designer.SetDataSource("CostBZBJOM", "总报价");
  8739. designer.SetDataSource("CostBDRLROM", "单人利润");
  8740. designer.SetDataSource("CostBZLROM", "总利润");
  8741. #endregion
  8742. }
  8743. #endregion
  8744. designer.SetDataSource("TzZCB2", TzZCB2);
  8745. designer.SetDataSource("TzZBJ2", TzZBJ2);
  8746. designer.SetDataSource("TzZLR2", TzZLR2);
  8747. string[] dataSourceKeys = new string[]
  8748. {
  8749. "VF",
  8750. "TGS",
  8751. "TGOF",
  8752. "TGM",
  8753. "TGA",
  8754. "TGTF",
  8755. "TGEF",
  8756. "CFM",
  8757. "CFOF",
  8758. "B",
  8759. "L",
  8760. "D",
  8761. "TBR",
  8762. "SGR",
  8763. "JSES",
  8764. "Suite",
  8765. "TV",
  8766. "1L",
  8767. "IF",
  8768. "EF",
  8769. "BRF",
  8770. "TE",
  8771. "TGT",
  8772. "DRVT",
  8773. "PC",
  8774. "TLF",
  8775. "ECT"
  8776. };
  8777. foreach (var item in dataSourceKeys)
  8778. {
  8779. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8780. if (find != null)
  8781. {
  8782. designer.SetDataSource(item, find.text);
  8783. }
  8784. else
  8785. {
  8786. designer.SetDataSource(item, 0);
  8787. }
  8788. }
  8789. designer.SetDataSource(dt);
  8790. //根据数据源处理生成报表内容
  8791. designer.Process();
  8792. designer.Workbook.Worksheets[0].Name = "清单";
  8793. Worksheet sheet = designer.Workbook.Worksheets[0];
  8794. foreach (var Rowindex in hideRowsList)
  8795. {
  8796. ws.Cells.HideRows(Rowindex, 2);
  8797. }
  8798. byte[] bytes = null;
  8799. string strFileName = di.TeamName + "-团组-成本.xls";
  8800. using (MemoryStream stream = new MemoryStream())
  8801. {
  8802. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8803. bytes = stream.ToArray();
  8804. }
  8805. return Ok(JsonView(true, "", new
  8806. {
  8807. Data = bytes,
  8808. strFileName,
  8809. }));
  8810. }
  8811. /// <summary>
  8812. /// 导出客户报表
  8813. /// </summary>
  8814. /// <returns></returns>
  8815. [HttpPost]
  8816. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8817. {
  8818. var jw = JsonView(false);
  8819. if (dto.Diid == 0)
  8820. {
  8821. return Ok(JsonView(false, "请传递团组id"));
  8822. }
  8823. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8824. if (deleInfo.Code != 0)
  8825. {
  8826. return Ok(JsonView(false, "团组信息查询失败!"));
  8827. }
  8828. var di = deleInfo.Data as DelegationInfoWebView;
  8829. if (di == null)
  8830. {
  8831. return Ok(JsonView(false, "团组信息查询失败!"));
  8832. }
  8833. //文件名
  8834. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8835. //获取模板
  8836. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8837. //载入模板
  8838. Document doc = new Document(tmppath);
  8839. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8840. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8841. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8842. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8843. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8844. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8845. if (AParameter == null)
  8846. {
  8847. return Ok(JsonView(false, "系数不存在!"));
  8848. }
  8849. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8850. , TzAirDesc, TzZCost;
  8851. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8852. = TzAirDesc = TzZCost = string.Empty;
  8853. TzNumber = AParameter.CostTypenumber.ToString();
  8854. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8855. CarGuides1 = dto.CarGuides1;
  8856. Meal = dto.Meal;
  8857. SubsidizedMeals = dto.SubsidizedMeals;
  8858. NightRepair = dto.NightRepair;
  8859. AttractionsTickets = dto.AttractionsTickets;
  8860. MiscellaneousFees = dto.MiscellaneousFees;
  8861. ATip = dto.ATip;
  8862. TzHotelDesc = "";
  8863. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8864. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8865. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8866. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8867. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8868. TzAirDesc = "";
  8869. TzZCost = dto.TzZCost;
  8870. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8871. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8872. var index = 1;
  8873. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8874. foreach (var item in TzHotelDescArr)
  8875. {
  8876. if (AinfoArr != null)
  8877. {
  8878. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8879. if (Ainfo != null)
  8880. {
  8881. if (int.Parse(Ainfo.rs) <= 0)
  8882. {
  8883. continue;
  8884. }
  8885. var hotelText = string.Empty;
  8886. switch (item)
  8887. {
  8888. case "SGR":
  8889. hotelText = "单人间";
  8890. break;
  8891. case "JSES":
  8892. hotelText = "小套房";
  8893. break;
  8894. case "SUITE":
  8895. hotelText = "套房";
  8896. break;
  8897. case "TBR":
  8898. hotelText = "双人间";
  8899. break;
  8900. }
  8901. if (item != "TBR")
  8902. {
  8903. 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";
  8904. }
  8905. else
  8906. {
  8907. 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";
  8908. }
  8909. index++;
  8910. }
  8911. }
  8912. }
  8913. index = 1;
  8914. foreach (var item in TzAirDescArr)
  8915. {
  8916. if (AinfoArr != null)
  8917. {
  8918. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8919. if (Ainfo != null)
  8920. {
  8921. if (int.Parse(Ainfo.rs) <= 0)
  8922. {
  8923. continue;
  8924. }
  8925. 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";
  8926. index++;
  8927. }
  8928. }
  8929. }
  8930. if (dto.costType == "B")
  8931. {
  8932. if (BParameter == null)
  8933. {
  8934. return Ok(JsonView(false, "B段系数不存在!"));
  8935. }
  8936. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8937. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8938. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8939. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8940. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8941. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8942. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8943. foreach (var item in TzHotelDescArr)
  8944. {
  8945. if (AinfoArr != null)
  8946. {
  8947. TzHotelDesc += "B段信息 \r\n";
  8948. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8949. if (Ainfo != null)
  8950. {
  8951. if (int.Parse(Ainfo.rs) <= 0)
  8952. {
  8953. continue;
  8954. }
  8955. var hotelText = string.Empty;
  8956. switch (item)
  8957. {
  8958. case "SGR":
  8959. hotelText = "单人间";
  8960. break;
  8961. case "JSES":
  8962. hotelText = "小套房";
  8963. break;
  8964. case "SUITE":
  8965. hotelText = "套房";
  8966. break;
  8967. case "TBR":
  8968. hotelText = "双人间";
  8969. break;
  8970. }
  8971. if (item != "TBR")
  8972. {
  8973. 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";
  8974. }
  8975. else
  8976. {
  8977. 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";
  8978. }
  8979. index++;
  8980. }
  8981. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8982. }
  8983. }
  8984. index = 1;
  8985. foreach (var item in TzAirDescArr)
  8986. {
  8987. if (AinfoArr != null)
  8988. {
  8989. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8990. if (Ainfo != null)
  8991. {
  8992. if (int.Parse(Ainfo.rs) <= 0)
  8993. {
  8994. continue;
  8995. }
  8996. 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";
  8997. index++;
  8998. }
  8999. }
  9000. }
  9001. }
  9002. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  9003. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  9004. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  9005. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  9006. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  9007. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  9008. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  9009. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  9010. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  9011. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  9012. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  9013. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  9014. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  9015. DickeyValue.Add("Visa", Visa); // 签证单人报价
  9016. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  9017. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  9018. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  9019. DickeyValue.Add("TzZCost", TzZCost);
  9020. foreach (var key in DickeyValue.Keys)
  9021. {
  9022. if (doc.Range.Bookmarks[key] != null)
  9023. {
  9024. Bookmark mark = doc.Range.Bookmarks[key];
  9025. mark.Text = DickeyValue[key];
  9026. }
  9027. }
  9028. byte[] bytes = null;
  9029. string strFileName = di.TeamName + "-客户报价.doc";
  9030. using (MemoryStream stream = new MemoryStream())
  9031. {
  9032. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  9033. bytes = stream.ToArray();
  9034. }
  9035. return Ok(JsonView(true, "", new
  9036. {
  9037. Data = bytes,
  9038. strFileName,
  9039. }));
  9040. }
  9041. /// <summary>
  9042. /// 团组成本 各模块(酒店,地接,机票)成本提示
  9043. /// </summary>
  9044. /// <param name="dto"></param>
  9045. /// <returns></returns>
  9046. [HttpPost]
  9047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9048. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  9049. {
  9050. try
  9051. {
  9052. #region 参数验证
  9053. if (dto.DiId < 0)
  9054. {
  9055. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  9056. }
  9057. List<int> cTableIds = new List<int>() {
  9058. 76 ,//酒店预订
  9059. 77 ,//行程
  9060. 79 ,//车/导游地接
  9061. 80 ,//签证
  9062. 81 ,//邀请/公务活
  9063. 82 ,//团组客户保险
  9064. 85 ,//机票预订
  9065. 98 ,//其他款项
  9066. 285 ,//收款退还
  9067. 751 ,//酒店早餐
  9068. 1015 // 超支费用
  9069. };
  9070. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  9071. {
  9072. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  9073. }
  9074. #endregion
  9075. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  9076. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  9077. if (_GroupCostParameters.Count <= 0)
  9078. {
  9079. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  9080. }
  9081. if (_GroupCostParameters[0].IsShare == 0)
  9082. {
  9083. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  9084. }
  9085. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9086. //处理date为空问题
  9087. if (_GroupCosts.Count > 0)
  9088. {
  9089. for (int i = 0; i < _GroupCosts.Count; i++)
  9090. {
  9091. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  9092. {
  9093. if (i > 0)
  9094. {
  9095. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  9096. }
  9097. }
  9098. }
  9099. }
  9100. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  9101. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  9102. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  9103. string currCode = "";
  9104. #region currCode 验证
  9105. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  9106. if (isInt)
  9107. {
  9108. var currData = currDatas.Find(it => it.Id == intCurrency);
  9109. if (currData != null)
  9110. {
  9111. currCode = currData.Name;
  9112. }
  9113. }
  9114. else
  9115. {
  9116. currCode = _GroupCostParameters[0].Currency.Trim();
  9117. }
  9118. #endregion
  9119. //op,酒店单段模式存储
  9120. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  9121. {
  9122. CurrencyCode = currCode,
  9123. Rate = _GroupCostParameters[0].Rate,
  9124. CostType = _GroupCostParameters[0].CostType,
  9125. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  9126. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  9127. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  9128. };
  9129. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  9130. if (_GroupCostParameters.Count == 2)
  9131. {
  9132. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  9133. }
  9134. foreach (var item in _GroupCostParameters)
  9135. {
  9136. decimal _rate = 1;
  9137. decimal _rate1 = item.Rate;
  9138. decimal _scale = 1;
  9139. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  9140. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  9141. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  9142. //if (userInfo != null)
  9143. //{
  9144. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  9145. // {
  9146. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  9147. // {
  9148. // _scale = 1.00M;
  9149. // }
  9150. // }
  9151. //}
  9152. #endregion
  9153. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  9154. {
  9155. CurrencyCode = currCode,
  9156. Rate = _rate1,
  9157. CostType = item.CostType,
  9158. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  9159. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  9160. CostTypeNumber = item.CostTypenumber
  9161. };
  9162. if (_GroupCostParameters.Count > 1)
  9163. {
  9164. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  9165. }
  9166. else
  9167. {
  9168. modulePromptInfo.CostTypeNumber = item.LYJRS;
  9169. }
  9170. if (dto.CTable == 79)//
  9171. {
  9172. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  9173. modulePromptInfo.TotalCost = item.DJCB;
  9174. }
  9175. List<string> costTypes = new List<string>() { "A", "B" };
  9176. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  9177. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  9178. if (_GroupCostsDuplicates.Count() == 1)
  9179. {
  9180. _GroupCostsTypeData = _GroupCosts;
  9181. }
  9182. else
  9183. {
  9184. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  9185. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  9186. }
  9187. /*
  9188. * 76 酒店预订
  9189. * 77 行程
  9190. * 79 车/导游地接
  9191. * 80 签证
  9192. * 81 邀请/公务活动
  9193. * 82 团组客户保险
  9194. * 85 机票预订
  9195. * 98 其他款项
  9196. * 285 收款退还
  9197. * 751 酒店早餐
  9198. * 1015 超支费用
  9199. */
  9200. switch (dto.CTable)
  9201. {
  9202. case 76: // 酒店预订
  9203. _ModuleSubPromptInfo.AddRange(
  9204. _GroupCostsTypeData.Select(it => new
  9205. {
  9206. it.DAY,
  9207. it.Date,
  9208. it.ACCON,
  9209. it.ITIN,
  9210. it.SGR,
  9211. it.TBR,
  9212. it.JS_ES,
  9213. it.Suite
  9214. })
  9215. );
  9216. break;
  9217. case 79: // 车/导游地接
  9218. _ModuleSubPromptInfo.AddRange(
  9219. _GroupCostsTypeData.Select(it => new
  9220. {
  9221. Date = it.Date, //日期
  9222. CarFee = it.CarCost * _rate * _scale, //车费用
  9223. CarType = it.CarType, //车型
  9224. DriverFee = it.CFS * _rate * _scale, //司机工资
  9225. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  9226. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  9227. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  9228. GuideFee = it.TGS * _rate * _scale, //导游费用
  9229. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  9230. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  9231. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  9232. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  9233. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  9234. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  9235. Breakfast = it.B * _rate * _scale, //早餐费
  9236. Lunch = it.L * _rate * _scale, //午餐费
  9237. Dinner = it.D * _rate * _scale, //晚餐费
  9238. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  9239. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  9240. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  9241. TicketFee = it.EF * _rate * _scale, //门票费
  9242. TicketRemark = it.EFR, //门票费描述
  9243. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  9244. TravelSupplies = it.TE * _rate * _scale, //出行物资
  9245. SpentCash = it.PC * _rate * _scale, //零用金
  9246. LeadersFee = it.TLF * _rate * _scale, //领队费
  9247. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  9248. })
  9249. );
  9250. break;
  9251. case 85: // 机票
  9252. List<dynamic> datas = new List<dynamic>();
  9253. datas.Add(
  9254. new
  9255. {
  9256. AirType = "经济舱",
  9257. AirNum = item.JJCRS,
  9258. AirDRCB = item.JJCCB,
  9259. AirZCB = (item.JJCRS * item.JJCCB)
  9260. }
  9261. );
  9262. datas.Add(
  9263. new
  9264. {
  9265. AirType = "公务舱",
  9266. AirNum = item.GWCRS,
  9267. AirDRCB = item.GWCCB,
  9268. AirZCB = (item.GWCRS * item.GWCCB)
  9269. }
  9270. );
  9271. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9272. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  9273. modulePromptInfo.Data = new
  9274. {
  9275. airFeeData = datas,
  9276. airInitData = initDatas
  9277. };
  9278. _ModulePromptInfos.Add(modulePromptInfo);
  9279. break;
  9280. default:
  9281. break;
  9282. }
  9283. }
  9284. if (dto.CTable != 85)
  9285. {
  9286. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  9287. _ModulePromptInfos.Add(_ModulePromptInfo);
  9288. }
  9289. _view.ModulePromptInfos = _ModulePromptInfos;
  9290. return Ok(JsonView(true, "操作成功!", _view));
  9291. }
  9292. catch (Exception ex)
  9293. {
  9294. return Ok(JsonView(false, ex.Message));
  9295. }
  9296. }
  9297. /// <summary>
  9298. /// 根据黑屏代码重新生成行程
  9299. /// </summary>
  9300. /// <param name="dto"></param>
  9301. /// <returns></returns>
  9302. [HttpPost]
  9303. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  9304. {
  9305. var jw = JsonView(false);
  9306. var Create = _GroupCostRepository.
  9307. CreateGroupCostByBlackCode(dto.Diid);
  9308. jw.Msg = Create.Msg;
  9309. if (Create.Code == 0)
  9310. {
  9311. jw.Code = 200;
  9312. jw.Data = new
  9313. {
  9314. groupCost = Create.Data,
  9315. blackCodeIsTrue = true
  9316. };
  9317. }
  9318. else
  9319. {
  9320. jw.Code = 400;
  9321. jw.Data = new
  9322. {
  9323. groupCost = Create.Data,
  9324. blackCodeIsTrue = false,
  9325. };
  9326. }
  9327. return Ok(jw);
  9328. }
  9329. /// <summary>
  9330. /// 成本获取OP历史车费用
  9331. /// </summary>
  9332. /// <param name="dto"></param>
  9333. /// <returns></returns>
  9334. [HttpPost]
  9335. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  9336. {
  9337. var jw = JsonView(false);
  9338. try
  9339. {
  9340. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  9341. //获取现有所有车的数据
  9342. if (!dto.Param.IsNullOrWhiteSpace())
  9343. {
  9344. string sql = $@"
  9345. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  9346. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  9347. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  9348. 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
  9349. AND gctggr.ServiceEndTime is not NULL
  9350. ORDER by gctggrc.id DESC
  9351. ";
  9352. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  9353. var numeberResult = await Task.Run(() =>
  9354. {
  9355. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  9356. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  9357. return numberArr;
  9358. });
  9359. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  9360. foreach (var item in numeberResult)
  9361. {
  9362. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  9363. {
  9364. Country = "数据异常!",
  9365. City = string.Empty,
  9366. };
  9367. item.Area = find.Country + " " + find.City;
  9368. }
  9369. dbResult.AddRange(numeberResult);
  9370. if (dto.Param.Contains("、"))
  9371. {
  9372. var sp = dto.Param.Split("、");
  9373. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9374. .Where(x =>
  9375. {
  9376. return System.Array.Exists(sp, e =>
  9377. {
  9378. bool where = false;
  9379. if (x.Area != null)
  9380. {
  9381. where = x.Area.Contains(e);
  9382. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9383. {
  9384. return false;
  9385. }
  9386. }
  9387. if (x.PriceName != null && !where)
  9388. {
  9389. where = x.PriceName.Contains(e);
  9390. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9391. {
  9392. return false;
  9393. }
  9394. }
  9395. return where;
  9396. });
  9397. }).ToList();
  9398. }
  9399. else
  9400. {
  9401. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9402. .Where(x =>
  9403. {
  9404. bool where = false;
  9405. if (x.Area != null)
  9406. {
  9407. where = x.Area.Contains(dto.Param);
  9408. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9409. {
  9410. return false;
  9411. }
  9412. }
  9413. if (x.PriceName != null && !where)
  9414. {
  9415. where = x.PriceName.Contains(dto.Param);
  9416. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9417. {
  9418. return false;
  9419. }
  9420. }
  9421. return where;
  9422. }
  9423. )
  9424. .ToList();
  9425. }
  9426. }
  9427. var view = dbResult.Select(x =>
  9428. {
  9429. decimal dp = 0.00M;
  9430. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  9431. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  9432. if (string.IsNullOrWhiteSpace(x.DatePrice))
  9433. {
  9434. if (startB && endB)
  9435. {
  9436. var timesp = endD.Subtract(startD);
  9437. if ((timesp.Days + 1) != 0)
  9438. {
  9439. dp = x.Price / (timesp.Days + 1);
  9440. }
  9441. }
  9442. }
  9443. else
  9444. {
  9445. dp = x.Price;
  9446. }
  9447. return new
  9448. {
  9449. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  9450. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  9451. x.Area,
  9452. x.id,
  9453. price = x.Price.ToString("F2"),
  9454. x.PriceName,
  9455. x.PriceContent,
  9456. x.TeamName,
  9457. x.DatePrice,
  9458. dayPrice = dp.ToString("F2"),
  9459. };
  9460. }).OrderByDescending(x => x.id).ToList();
  9461. jw = JsonView(true, "获取成功!", view);
  9462. }
  9463. catch (Exception e)
  9464. {
  9465. jw = JsonView(false, e.Message);
  9466. }
  9467. return Ok(jw);
  9468. }
  9469. #endregion
  9470. #region 酒店预订 新 雷怡 2023-12-28 17:45
  9471. /// <summary>
  9472. /// 酒店预订
  9473. /// 酒店费用列表 根据团组Id查询
  9474. /// </summary>
  9475. /// <param name="_dto"></param>
  9476. /// <returns></returns>
  9477. [HttpPost]
  9478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9479. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  9480. {
  9481. #region 参数验证
  9482. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9483. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9484. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9485. #region 团组操作权限验证 76 酒店预定模块
  9486. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9487. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9488. #endregion
  9489. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9490. #region 页面操作权限验证
  9491. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9492. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9493. #endregion
  9494. #endregion
  9495. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  9496. }
  9497. /// <summary>
  9498. /// 酒店预订
  9499. /// 基础数据
  9500. /// </summary>
  9501. /// <param name="_dto"></param>
  9502. /// <returns></returns>
  9503. [HttpPost]
  9504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9505. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  9506. {
  9507. #region 参数验证
  9508. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9509. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9510. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9511. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9512. #region 页面操作权限验证
  9513. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9514. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9515. #endregion
  9516. #region 团组操作权限验证 76 酒店预定模块
  9517. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9518. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9519. #endregion
  9520. #endregion
  9521. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  9522. }
  9523. /// <summary>
  9524. /// 酒店预订
  9525. /// 创建 入住卷号码
  9526. /// </summary>
  9527. /// <param name="_dto"></param>
  9528. /// <returns></returns>
  9529. [HttpPost]
  9530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9531. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  9532. {
  9533. #region 参数验证
  9534. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9535. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9536. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9537. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9538. #region 页面操作权限验证
  9539. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9540. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9541. #endregion
  9542. #region 团组操作权限验证 76 酒店预定模块
  9543. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9544. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9545. #endregion
  9546. #endregion
  9547. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  9548. if (data.Code != 0)
  9549. {
  9550. return Ok(JsonView(false, data.Msg));
  9551. }
  9552. return Ok(JsonView(true, data.Msg, data.Data));
  9553. }
  9554. /// <summary>
  9555. /// 酒店预订
  9556. /// 详情
  9557. /// </summary>
  9558. /// <param name="_dto"></param>
  9559. /// <returns></returns>
  9560. [HttpPost]
  9561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9562. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  9563. {
  9564. #region 参数验证
  9565. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  9566. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9567. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  9568. #region 团组操作权限验证 76 酒店预定模块
  9569. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9570. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9571. #endregion
  9572. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9573. #region 页面操作权限验证
  9574. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9575. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9576. #endregion
  9577. #endregion
  9578. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  9579. }
  9580. /// <summary>
  9581. /// 酒店预订
  9582. /// Add Or Edit
  9583. /// </summary>
  9584. /// <param name="_dto"></param>
  9585. /// <returns></returns>
  9586. [HttpPost]
  9587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9588. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  9589. {
  9590. #region 参数验证
  9591. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9592. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9593. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9594. #region 团组操作权限验证 76 酒店预定模块
  9595. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9596. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9597. #endregion
  9598. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9599. #region 页面操作权限验证
  9600. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9601. if (_dto.Id == 0) // Add
  9602. {
  9603. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9604. }
  9605. else if (_dto.Id > 1) // Edit
  9606. {
  9607. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9608. }
  9609. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  9610. #endregion
  9611. #endregion
  9612. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  9613. if (_view.Code != 200)
  9614. {
  9615. return Ok(_view);
  9616. }
  9617. #region 应用推送
  9618. try
  9619. {
  9620. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9621. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9622. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9623. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9624. //自动审核
  9625. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  9626. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  9627. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  9628. //2024-10-21 新增LZ UID
  9629. var userIds = new List<int>() { 21 };
  9630. string title = $"系统通知";
  9631. var diId = _dto.DiId;
  9632. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  9633. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  9634. string content = "";
  9635. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9636. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9637. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  9638. }
  9639. catch (Exception ex)
  9640. {
  9641. }
  9642. #endregion
  9643. return Ok(_view);
  9644. }
  9645. /// <summary>
  9646. /// 酒店自动审核测试
  9647. /// Add Or Edit
  9648. /// </summary>
  9649. /// <param name="_dto"></param>
  9650. /// <returns></returns>
  9651. [HttpPost]
  9652. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9653. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  9654. {
  9655. #region 应用推送
  9656. try
  9657. {
  9658. //自动审核
  9659. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  9660. }
  9661. catch (Exception ex)
  9662. {
  9663. return Ok(JsonView(false, "操作失败"));
  9664. }
  9665. #endregion
  9666. return Ok(JsonView(false, "操作成功"));
  9667. }
  9668. /// <summary>
  9669. /// 酒店预订
  9670. /// Del
  9671. /// </summary>
  9672. /// <param name="_dto"></param>
  9673. /// <returns></returns>
  9674. [HttpPost]
  9675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9676. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  9677. {
  9678. #region 参数验证
  9679. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9680. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9681. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9682. #region 团组操作权限验证 76 酒店预定模块
  9683. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9684. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9685. #endregion
  9686. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9687. #region 页面操作权限验证
  9688. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9689. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9690. #endregion
  9691. #endregion
  9692. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  9693. }
  9694. /// <summary>
  9695. /// 酒店预订
  9696. /// 生成VOUCHER
  9697. /// 2024.05.06 之前版本
  9698. /// </summary>
  9699. /// <param name="_dto"></param>
  9700. /// <returns></returns>
  9701. [HttpPost]
  9702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9703. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  9704. {
  9705. try
  9706. {
  9707. #region 参数验证
  9708. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9709. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9710. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9711. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  9712. #region 团组操作权限验证 76 酒店预定模块
  9713. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9714. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9715. #endregion
  9716. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9717. #region 页面操作权限验证
  9718. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9719. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9720. #endregion
  9721. #endregion
  9722. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  9723. //判断数据是否完整
  9724. if (hr != null)
  9725. {
  9726. if (!string.IsNullOrEmpty(hr.DetermineNo))
  9727. {
  9728. string strFileName = "HotelStatement/";
  9729. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9730. if (dele != null)
  9731. strFileName += dele.TourCode;
  9732. //载入模板
  9733. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  9734. Document doc = new Document(sss);
  9735. DocumentBuilder builder = new DocumentBuilder(doc);
  9736. #region 替换Word模板书签内容
  9737. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9738. //入住卷预定号码
  9739. if (doc.Range.Bookmarks["VNO"] != null)
  9740. {
  9741. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9742. mark.Text = hr.CheckNumber;
  9743. }
  9744. //酒店时间
  9745. if (doc.Range.Bookmarks["Date"] != null)
  9746. {
  9747. Bookmark mark = doc.Range.Bookmarks["Date"];
  9748. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9749. }
  9750. //团号
  9751. if (doc.Range.Bookmarks["TNo"] != null)
  9752. {
  9753. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9754. mark.Text = dele.TourCode;
  9755. }
  9756. //预定号码
  9757. if (doc.Range.Bookmarks["BookingId"] != null)
  9758. {
  9759. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9760. mark.Text = hr.ReservationsNo;
  9761. }
  9762. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9763. {
  9764. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9765. mark.Text = hr.DetermineNo;
  9766. }
  9767. //酒店城市
  9768. if (doc.Range.Bookmarks["City"] != null)
  9769. {
  9770. Bookmark mark = doc.Range.Bookmarks["City"];
  9771. mark.Text = hr.City;
  9772. }
  9773. //酒店名称
  9774. if (doc.Range.Bookmarks["HName"] != null)
  9775. {
  9776. Bookmark mark = doc.Range.Bookmarks["HName"];
  9777. mark.Text = hr.HotelName;
  9778. }
  9779. //酒店地址
  9780. if (doc.Range.Bookmarks["Address"] != null)
  9781. {
  9782. Bookmark mark = doc.Range.Bookmarks["Address"];
  9783. mark.Text = hr.HotelAddress;
  9784. }
  9785. //酒店电话
  9786. if (doc.Range.Bookmarks["Tel"] != null)
  9787. {
  9788. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9789. mark.Text = hr.HotelTel;
  9790. }
  9791. //酒店传真
  9792. if (doc.Range.Bookmarks["Fax"] != null)
  9793. {
  9794. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9795. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9796. {
  9797. mark.Text = hr.HotelFax;
  9798. }
  9799. }
  9800. //入住时间
  9801. if (doc.Range.Bookmarks["CIn"] != null)
  9802. {
  9803. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9804. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9805. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9806. }
  9807. //退房时间
  9808. if (doc.Range.Bookmarks["COut"] != null)
  9809. {
  9810. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9811. Bookmark mark = doc.Range.Bookmarks["COut"];
  9812. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9813. }
  9814. //客户名称
  9815. if (doc.Range.Bookmarks["GName"] != null)
  9816. {
  9817. string guestName = "";
  9818. string[] clients = new string[] { };
  9819. if (hr.GuestName.Contains(","))
  9820. {
  9821. clients = hr.GuestName.Split(",");
  9822. }
  9823. else
  9824. {
  9825. clients = new string[] { hr.GuestName };
  9826. }
  9827. List<int> clientIds_int = new List<int>();
  9828. if (clients.Length > 0)
  9829. {
  9830. foreach (var item in clients)
  9831. {
  9832. if (item.IsNumeric())
  9833. {
  9834. clientIds_int.Add(int.Parse(item));
  9835. }
  9836. }
  9837. }
  9838. if (clientIds_int.Count > 0)
  9839. {
  9840. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9841. foreach (var client in _clientDatas)
  9842. {
  9843. //男
  9844. if (client.Sex == 0) guestName += $"Mr.";
  9845. //女
  9846. else if (client.Sex == 1) guestName += $"Ms.";
  9847. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9848. {
  9849. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9850. }
  9851. //guestName += $"{client.Pinyin},";
  9852. }
  9853. if (guestName.Length > 0)
  9854. {
  9855. guestName = guestName.Substring(0, guestName.Length - 1);
  9856. }
  9857. }
  9858. else
  9859. {
  9860. guestName = hr.GuestName;
  9861. }
  9862. Bookmark mark = doc.Range.Bookmarks["GName"];
  9863. mark.Text = guestName;
  9864. }
  9865. //房间介绍
  9866. if (doc.Range.Bookmarks["ROOM"] != null)
  9867. {
  9868. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9869. mark.Text = hr.RoomExplanation;
  9870. }
  9871. //报价描述
  9872. if (doc.Range.Bookmarks["NOTE"] != null)
  9873. {
  9874. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9875. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9876. if (ss != null)
  9877. mark.Text = ss.Name;
  9878. }
  9879. //入住时间
  9880. if (doc.Range.Bookmarks["CheckIn"] != null)
  9881. {
  9882. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9883. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9884. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9885. }
  9886. //退房时间
  9887. if (doc.Range.Bookmarks["CheckOut"] != null)
  9888. {
  9889. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9890. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9891. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9892. }
  9893. //日期
  9894. if (doc.Range.Bookmarks["DT"] != null)
  9895. {
  9896. Bookmark mark = doc.Range.Bookmarks["DT"];
  9897. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9898. }
  9899. //名称
  9900. if (doc.Range.Bookmarks["VName"] != null)
  9901. {
  9902. Bookmark mark = doc.Range.Bookmarks["VName"];
  9903. mark.Text = hr.HotelName;
  9904. }
  9905. //号码
  9906. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9907. {
  9908. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9909. mark.Text = hr.CheckNumber;
  9910. }
  9911. #endregion
  9912. strFileName += "VOUCHER.doc";
  9913. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9914. doc.Save(fileDir);
  9915. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9916. return Ok(JsonView(true, "操作成功!", Url));
  9917. }
  9918. else
  9919. {
  9920. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9921. }
  9922. }
  9923. else
  9924. {
  9925. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9926. }
  9927. }
  9928. catch (Exception ex)
  9929. {
  9930. return Ok(JsonView(false, ex.Message));
  9931. }
  9932. }
  9933. /// <summary>
  9934. /// 酒店预订
  9935. /// 生成VOUCHER
  9936. /// 2024.05.06 之后版本
  9937. /// </summary>
  9938. /// <param name="_dto"></param>
  9939. /// <returns></returns>
  9940. [HttpPost]
  9941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9942. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9943. {
  9944. #region 参数验证
  9945. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9946. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9947. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9948. #region 团组操作权限验证 76 酒店预定模块
  9949. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9950. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9951. #endregion
  9952. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9953. #region 页面操作权限验证
  9954. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9955. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9956. #endregion
  9957. #endregion
  9958. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9959. //判断数据是否完整
  9960. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9961. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9962. string strFileName = "HotelStatement/";
  9963. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9964. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9965. #region 数据处理
  9966. List<int> guestIds = new List<int>();
  9967. int index = 0;
  9968. foreach (var item in hrDtas)
  9969. {
  9970. if (item.GuestName.Contains(","))
  9971. {
  9972. string[] guestIdArr = item.GuestName.Split(',');
  9973. foreach (var guestIdStr in guestIdArr)
  9974. {
  9975. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9976. if (guestBool)
  9977. {
  9978. guestIds.Add(guestId);
  9979. }
  9980. }
  9981. }
  9982. else guestNames += item.GuestName;
  9983. var voucherInfo = new HotelVoucherInfoView()
  9984. {
  9985. HotelName = item.HotelName,
  9986. CheckInDate = item.CheckInDate,
  9987. CheckOutDate = item.CheckOutDate,
  9988. ConfirmationNumber = item.DetermineNo.Trim(),
  9989. RoomType = item.RoomExplanation
  9990. };
  9991. vouchers.Add(voucherInfo);
  9992. }
  9993. if (guestIds.Count > 0)
  9994. {
  9995. guestIds = guestIds.Distinct().ToList();
  9996. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9997. if (guestDatas.Count > 0)
  9998. {
  9999. guestNames = "";
  10000. foreach (var guest in guestDatas)
  10001. {
  10002. string guestName = "";
  10003. if (guest.Sex == 0) guestName += @"MR.";
  10004. else if (guest.Sex == 1) guestName += @"MS.";
  10005. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  10006. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  10007. guestNames += @$"{guestName.Trim()}、";
  10008. }
  10009. if (guestNames.Length > 0)
  10010. {
  10011. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  10012. }
  10013. }
  10014. }
  10015. #endregion
  10016. //载入模板
  10017. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  10018. Document doc = new Document(sss);
  10019. DocumentBuilder builder = new DocumentBuilder(doc);
  10020. if (doc.Range.Bookmarks["GuestName"] != null)
  10021. {
  10022. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  10023. mark.Text = guestNames;
  10024. }
  10025. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10026. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  10027. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  10028. for (int i = 1; i <= vouchers.Count; i++)
  10029. {
  10030. HotelVoucherInfoView hviv = vouchers[i - 1];
  10031. builder.MoveToCell(0, i, 0, 0);
  10032. builder.Write(hviv.HotelName);
  10033. builder.MoveToCell(0, i, 1, 0);
  10034. builder.Write(hviv.CheckInDate);
  10035. builder.MoveToCell(0, i, 2, 0);
  10036. builder.Write(hviv.CheckOutDate);
  10037. builder.MoveToCell(0, i, 3, 0);
  10038. builder.Write(hviv.RoomType);
  10039. builder.MoveToCell(0, i, 4, 0);
  10040. builder.Write(hviv.ConfirmationNumber);
  10041. }
  10042. //删除多余行
  10043. int currRowIndex = vouchers.Count + 1;
  10044. int delRows = 21 - currRowIndex;
  10045. if (delRows > 0)
  10046. {
  10047. for (int i = 0; i < delRows; i++)
  10048. {
  10049. table.Rows.RemoveAt(currRowIndex);
  10050. //cultivateRowIndex++;
  10051. }
  10052. }
  10053. strFileName += "VOUCHER.docx";
  10054. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10055. doc.Save(fileDir);
  10056. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10057. return Ok(JsonView(true, "操作成功!", Url));
  10058. }
  10059. /// <summary>
  10060. /// 酒店预订
  10061. /// 生成VOUCHER 批量生成
  10062. /// New
  10063. /// </summary>
  10064. /// <param name="_dto"></param>
  10065. /// <returns></returns>
  10066. [HttpPost]
  10067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10068. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  10069. {
  10070. #region 参数验证
  10071. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10072. if (_dto.PageId < 1) _dto.PageId = 28;
  10073. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10074. #region 团组操作权限验证 76 酒店预定模块
  10075. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10076. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10077. #endregion
  10078. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10079. #region 页面操作权限验证
  10080. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10081. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10082. #endregion
  10083. #endregion
  10084. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  10085. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  10086. .OrderBy(x => x.CheckInDate)
  10087. .ToListAsync();
  10088. //判断数据是否完整
  10089. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  10090. string strFileName = "HotelStatement/";
  10091. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  10092. if (dele != null)
  10093. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  10094. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  10095. for (int i = 0; i < hrDtas.Count; i++)
  10096. {
  10097. string guestNames = string.Empty;
  10098. List<int> guestIds = new List<int>();
  10099. var item = hrDtas[i];
  10100. //处理客户姓名
  10101. if (item.GuestName.Contains(","))
  10102. {
  10103. string[] guestIdArr = item.GuestName.Split(',');
  10104. foreach (var guestIdStr in guestIdArr)
  10105. if (int.TryParse(guestIdStr, out int guestId))
  10106. guestIds.Add(guestId);
  10107. }
  10108. else
  10109. {
  10110. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  10111. if (guestIdBool)
  10112. {
  10113. guestIds.Add(guestId);
  10114. }
  10115. //NaN
  10116. if (item.GuestName.Contains("NaN"))
  10117. {
  10118. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  10119. }
  10120. }
  10121. if (guestIds.Count > 0)
  10122. {
  10123. guestIds = guestIds.Distinct().ToList();
  10124. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  10125. if (guestDatas1.Count > 0)
  10126. {
  10127. guestNames = "";
  10128. foreach (var guest in guestDatas1)
  10129. {
  10130. string guestName = "";
  10131. if (guest.Sex == 0) guestName += @"MR.";
  10132. else if (guest.Sex == 1) guestName += @"MS.";
  10133. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  10134. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  10135. guestNames += @$"{guestName.Trim()}、";
  10136. }
  10137. if (guestNames.Length > 0)
  10138. {
  10139. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  10140. }
  10141. }
  10142. }
  10143. //if (!string.IsNullOrEmpty(guestNames))
  10144. //{
  10145. hrDtas[i].GuestName = guestNames;
  10146. //}
  10147. }
  10148. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  10149. Document doc = new Document();
  10150. DocumentBuilder builder = new DocumentBuilder(doc);
  10151. try
  10152. {
  10153. builder.MoveToDocumentStart();
  10154. foreach (var item in hrDtas)
  10155. {
  10156. //标题
  10157. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  10158. builder.ParagraphFormat.LineSpacing = 1;
  10159. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10160. builder.ParagraphFormat.Style.Font.Size = 9;
  10161. builder.ParagraphFormat.Style.Font.Bold = true;
  10162. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  10163. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  10164. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  10165. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  10166. builder.ParagraphFormat.LineSpacing = 1;
  10167. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10168. builder.ParagraphFormat.Style.Font.Size = 9;
  10169. builder.ParagraphFormat.Style.Font.Bold = true;
  10170. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  10171. builder.StartTable();
  10172. // 设置边框颜色
  10173. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  10174. //设置边框样式
  10175. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  10176. //表格
  10177. #region 第一行
  10178. builder.InsertCell();
  10179. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10180. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10181. //builder.CellFormat.AllowAutoFit = false;
  10182. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10183. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10184. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10185. builder.CellFormat.WrapText = true; //自动换行
  10186. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10187. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  10188. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10189. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10190. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10191. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10192. builder.Write("TOUR NO:");
  10193. builder.InsertCell();
  10194. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10195. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10196. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10197. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10198. builder.ParagraphFormat.Style.Font.Bold = false;
  10199. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10200. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10201. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10202. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10203. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10204. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10205. builder.Write($"{dele?.TourCode ?? "-"}");
  10206. builder.InsertCell();
  10207. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10208. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10209. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10210. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10211. builder.ParagraphFormat.Style.Font.Bold = false;
  10212. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10213. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10214. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10215. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10216. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10217. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10218. builder.Write($"CITY:");
  10219. builder.InsertCell();
  10220. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10221. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10222. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10223. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10224. builder.ParagraphFormat.Style.Font.Bold = false;
  10225. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10226. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10227. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10228. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10229. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10230. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10231. builder.Write($"{item.City}");
  10232. builder.EndRow();
  10233. #endregion
  10234. #region 第二行
  10235. builder.InsertCell();
  10236. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10237. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10238. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10239. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10240. builder.ParagraphFormat.Style.Font.Bold = false;
  10241. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10242. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10243. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10244. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10245. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10246. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10247. builder.Write("CONFIRMATION NO:");
  10248. builder.InsertCell();
  10249. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10250. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10251. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10252. builder.ParagraphFormat.Style.Font.Bold = false;
  10253. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10254. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10255. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10256. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10257. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10258. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10259. builder.CellFormat.VerticalMerge = CellMerge.None;
  10260. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10261. builder.Write($"{item.DetermineNo}");
  10262. builder.InsertCell();
  10263. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10264. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10265. builder.InsertCell();
  10266. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10267. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10268. builder.EndRow();
  10269. #endregion
  10270. #region 第三行
  10271. builder.InsertCell();
  10272. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10273. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10274. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10275. builder.ParagraphFormat.Style.Font.Bold = false;
  10276. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10277. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10278. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10279. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10280. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10281. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10282. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10283. builder.Write($"HOTEL NAME:");
  10284. builder.InsertCell();
  10285. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10286. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10287. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10288. builder.ParagraphFormat.Style.Font.Bold = false;
  10289. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10290. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10291. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10292. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10293. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10294. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10295. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10296. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10297. builder.Write($"{item.HotelName}");
  10298. builder.InsertCell();
  10299. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10300. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10301. builder.InsertCell();
  10302. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10303. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10304. builder.EndRow();
  10305. #endregion
  10306. #region 第四行
  10307. builder.InsertCell();
  10308. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10309. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10310. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10311. builder.ParagraphFormat.Style.Font.Bold = false;
  10312. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10313. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10314. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10315. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10316. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10317. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10318. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10319. builder.Write($"HOTEL ADDRESS:");
  10320. builder.InsertCell();
  10321. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10322. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10323. builder.ParagraphFormat.Style.Font.Size = 8;
  10324. builder.ParagraphFormat.Style.Font.Bold = false;
  10325. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10326. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10327. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10328. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10329. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10330. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10331. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10332. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10333. builder.Write($"{item.HotelAddress}");
  10334. builder.InsertCell();
  10335. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10336. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10337. builder.InsertCell();
  10338. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10339. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10340. builder.EndRow();
  10341. #endregion
  10342. #region 第五行
  10343. builder.InsertCell();
  10344. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10345. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10346. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10347. builder.ParagraphFormat.Style.Font.Bold = false;
  10348. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10349. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10350. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10351. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10352. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10353. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10354. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10355. builder.Write("TEL:");
  10356. builder.InsertCell();
  10357. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10358. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10359. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10360. builder.ParagraphFormat.Style.Font.Bold = false;
  10361. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10362. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10363. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10364. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10365. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10366. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10367. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10368. builder.Write($"{item.HotelTel}");
  10369. builder.InsertCell();
  10370. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10371. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10372. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10373. builder.ParagraphFormat.Style.Font.Bold = false;
  10374. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10375. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10376. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10377. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10378. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10379. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10380. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10381. builder.Write($"FAX:");
  10382. builder.InsertCell();
  10383. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10384. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10385. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10386. builder.ParagraphFormat.Style.Font.Bold = false;
  10387. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10388. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10389. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10390. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10391. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10392. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10393. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10394. builder.Write($"{item.HotelFax}");
  10395. builder.EndRow();
  10396. #endregion
  10397. #region 第六行
  10398. builder.InsertCell();
  10399. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10400. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10401. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10402. builder.ParagraphFormat.Style.Font.Bold = false;
  10403. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10404. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10405. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10406. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10407. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10408. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10409. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10410. builder.Write("CHECK IN:");
  10411. builder.InsertCell();
  10412. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10413. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10414. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10415. builder.ParagraphFormat.Style.Font.Bold = false;
  10416. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10417. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10418. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10419. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10420. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10421. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10422. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10423. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  10424. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  10425. builder.Write($"{checkInStr}");
  10426. builder.InsertCell();
  10427. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10428. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10429. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10430. builder.ParagraphFormat.Style.Font.Bold = false;
  10431. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10432. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10433. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10434. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10435. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10436. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10437. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10438. builder.Write($"CHECK OUT:");
  10439. builder.InsertCell();
  10440. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10441. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10442. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10443. builder.ParagraphFormat.Style.Font.Bold = false;
  10444. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10445. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10446. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10447. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10448. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10449. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10450. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10451. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  10452. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  10453. builder.Write($"{checkOutStr}");
  10454. builder.EndRow();
  10455. #endregion
  10456. #region 第七行
  10457. builder.InsertCell();
  10458. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10459. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10460. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10461. builder.ParagraphFormat.Style.Font.Bold = false;
  10462. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10463. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10464. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10465. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10466. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10467. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10468. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10469. builder.Write($"GUEST NAME:");
  10470. builder.InsertCell();
  10471. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10472. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10473. builder.ParagraphFormat.Style.Font.Size = 8;
  10474. builder.ParagraphFormat.Style.Font.Bold = false;
  10475. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10476. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10477. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10478. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10479. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10480. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10481. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10482. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10483. builder.Write($"{item.GuestName}");
  10484. builder.InsertCell();
  10485. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10486. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10487. builder.InsertCell();
  10488. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10489. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10490. builder.EndRow();
  10491. #endregion
  10492. #region 第八行
  10493. builder.InsertCell();
  10494. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10495. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10496. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10497. builder.ParagraphFormat.Style.Font.Bold = false;
  10498. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10499. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10500. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10501. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10502. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10503. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10504. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10505. builder.Write($"ROOM TYPE:");
  10506. builder.InsertCell();
  10507. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10508. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10509. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10510. builder.ParagraphFormat.Style.Font.Bold = false;
  10511. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10512. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10513. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10514. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10515. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10516. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10517. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10518. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10519. builder.Write($"{item.RoomExplanation}");
  10520. builder.InsertCell();
  10521. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10522. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10523. builder.InsertCell();
  10524. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10525. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10526. builder.EndRow();
  10527. #endregion
  10528. #region 第九行
  10529. builder.InsertCell();
  10530. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10531. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10532. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10533. builder.ParagraphFormat.Style.Font.Bold = false;
  10534. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10535. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10536. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10537. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10538. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10539. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10540. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10541. builder.Write($"NOTE:");
  10542. builder.InsertCell();
  10543. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10544. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10545. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10546. builder.ParagraphFormat.Style.Font.Bold = false;
  10547. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10548. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10549. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10550. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10551. 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.");
  10552. builder.InsertCell();
  10553. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10554. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10555. builder.InsertCell();
  10556. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10557. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10558. builder.EndRow();
  10559. #endregion
  10560. builder.EndTable();
  10561. //换行
  10562. builder.Writeln("");
  10563. builder.Writeln("");
  10564. }
  10565. #region 获取文档中的所有表格 设置文字自适应
  10566. // 获取文档中的所有表格。
  10567. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  10568. {
  10569. // 遍历表格中的所有行。
  10570. foreach (Aspose.Words.Tables.Row row in table.Rows)
  10571. {
  10572. foreach (Cell cell in row.Cells)
  10573. {
  10574. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  10575. cellFormat.Width = 0;
  10576. }
  10577. }
  10578. }
  10579. #endregion
  10580. #region 设置页眉
  10581. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  10582. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  10583. if (System.IO.File.Exists(voucherHeaderPath))
  10584. {
  10585. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  10586. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  10587. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  10588. Shape shape = builder.InsertImage(imageBytes);
  10589. // 调整图片位置
  10590. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  10591. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  10592. shape.Top = 50; // 将图片距离页眉上边缘的距离
  10593. shape.Left = 0; // 将图片距离页面左边缘的距离
  10594. shape.Width = 81; // 设置图片宽度
  10595. shape.Height = 36; // 设置图片高度
  10596. }
  10597. //靠右
  10598. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  10599. //// 设置页脚上下边距
  10600. //builder.PageSetup.HeaderDistance = 42;
  10601. // 添加页眉线
  10602. Aspose.Words.Border borderHeader = null;
  10603. try
  10604. {
  10605. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  10606. }
  10607. catch (Exception e)
  10608. {
  10609. // TODO Auto-generated catch block
  10610. //e.printStackTrace();
  10611. }
  10612. borderHeader.Shadow = true;
  10613. borderHeader.DistanceFromText = 2;
  10614. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  10615. #endregion
  10616. }
  10617. catch (Exception ex)
  10618. {
  10619. }
  10620. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10621. doc.Save(fileDir);
  10622. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10623. return Ok(JsonView(true, "操作成功!", Url));
  10624. }
  10625. /// <summary>
  10626. /// 酒店预订
  10627. /// 生成 预定成本 Excel
  10628. /// </summary>
  10629. /// <param name="_dto"></param>
  10630. /// <returns></returns>
  10631. [HttpPost]
  10632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10633. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  10634. {
  10635. #region 参数验证
  10636. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  10637. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  10638. if (!vadalitorRes.IsValid)
  10639. {
  10640. var errors = new StringBuilder();
  10641. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  10642. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  10643. }
  10644. #region 团组操作权限验证 76 酒店预定模块
  10645. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10646. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10647. #endregion
  10648. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10649. #region 页面操作权限验证
  10650. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10651. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10652. #endregion
  10653. #endregion
  10654. decimal _rate = 1.00M;
  10655. string _currency = "";
  10656. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  10657. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  10658. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  10659. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  10660. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  10661. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  10662. {
  10663. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  10664. }
  10665. _currency = _GroupCostParameter.Currency;
  10666. bool isIntType = int.TryParse(_currency, out int currId);
  10667. if (isIntType)
  10668. {
  10669. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  10670. }
  10671. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  10672. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  10673. if (currInfo == null)
  10674. {
  10675. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  10676. }
  10677. if (!_currency.ToUpper().Equals("CNY"))
  10678. {
  10679. _rate = _GroupCostParameter.Rate;
  10680. }
  10681. _rate = currInfo.Rate;
  10682. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10683. string strFileName = "HotelStatement/";
  10684. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10685. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  10686. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10687. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  10688. #region 数据处理
  10689. foreach (var item in hrDtas)
  10690. {
  10691. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  10692. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  10693. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  10694. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  10695. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  10696. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  10697. string singleRoomFeeStr = string.Empty,
  10698. doubleRoomFeeStr = string.Empty,
  10699. suiteRoomFeeStr = string.Empty,
  10700. otherRoomFeeStr = string.Empty,
  10701. payMoneyStr = string.Empty,
  10702. cardPriceStr = string.Empty;
  10703. if (roomCurr.Equals(_currency))
  10704. {
  10705. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  10706. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  10707. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  10708. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  10709. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  10710. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  10711. }
  10712. else
  10713. {
  10714. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10715. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10716. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10717. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10718. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  10719. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  10720. }
  10721. string breakfastPriceStr = string.Empty,
  10722. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  10723. governmentRentStr = string.Empty,
  10724. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  10725. cityTaxStrStr = string.Empty,
  10726. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  10727. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  10728. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  10729. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  10730. int payDId = roomInfo?.PayDId ?? 0;
  10731. pcfds.Add(new HotelReservations_PCFD_View()
  10732. {
  10733. City = item.City,
  10734. HotelName = item.HotelName,
  10735. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  10736. // SingleRoomCount = item.SingleRoomCount,
  10737. SingleRoomPrice = singleRoomFeeStr,
  10738. // DoubleRoomCount = item.DoubleRoomCount,
  10739. DoubleRoomPrice = doubleRoomFeeStr,
  10740. //SuiteRoomCount = item.SuiteRoomCount,
  10741. SuiteRoomPrice = suiteRoomFeeStr,
  10742. OtherRoomPrice = otherRoomFeeStr,
  10743. //OtherRoomCount = item.OtherRoomCount,
  10744. BreakfastPrice = breakfastPriceStr,
  10745. GovernmentRent = governmentRentStr,
  10746. CityTax = cityTaxStrStr,
  10747. RoomExplanation = item.RoomExplanation,
  10748. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  10749. PayTime = roomInfo?.ConsumptionDate,
  10750. BankNo = roomInfo?.BankNo,
  10751. PayMoney = payMoneyStr,
  10752. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  10753. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  10754. CardPrice = cardPriceStr,
  10755. Remark = ccpInfo.Remark
  10756. });
  10757. }
  10758. #endregion
  10759. //载入模板
  10760. WorkbookDesigner designer = new WorkbookDesigner();
  10761. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  10762. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  10763. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  10764. designer.SetDataSource("TourNo", groupInfo.TourCode);
  10765. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  10766. designer.SetDataSource("Opertor", userInfo.CnName);
  10767. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  10768. dt.TableName = "ViewMyHotelReservations";
  10769. designer.SetDataSource(dt);
  10770. designer.Process();
  10771. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10772. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  10773. designer.Workbook.Save(serverPath);
  10774. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  10775. #region 删除指定行
  10776. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  10777. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  10778. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  10779. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  10780. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  10781. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  10782. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  10783. cssIndex = dt.Columns["CityTax"].Ordinal,
  10784. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  10785. remarkIndex = dt.Columns["Remark"].Ordinal;
  10786. //删除指定列
  10787. foreach (DataRow item in dt.Rows)
  10788. {
  10789. string singleStr = item["SingleRoomPrice"].ToString();
  10790. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  10791. if (containsDigitButNotZero1) singleDel = false;
  10792. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  10793. string doubleStr = item["DoubleRoomPrice"].ToString();
  10794. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10795. if (containsDigitButNotZero2) doubleDel = false;
  10796. string suiteStr = item["SuiteRoomPrice"].ToString();
  10797. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10798. if (containsDigitButNotZero3) suiteDel = false;
  10799. string otherStr = item["OtherRoomPrice"].ToString();
  10800. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  10801. if (containsDigitButNotZero4) otherDel = false;
  10802. string zcStr = item["BreakfastPrice"].ToString();
  10803. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  10804. if (containsDigitButNotZero5) zcDel = false;
  10805. string dsStr = item["GovernmentRent"].ToString();
  10806. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  10807. if (containsDigitButNotZero6) dsDel = false;
  10808. string cssStr = item["CityTax"].ToString();
  10809. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  10810. if (containsDigitButNotZero7) cssDel = false;
  10811. string cpStr = item["ConsumptionPatterns"].ToString();
  10812. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  10813. string remarkStr = item["Remark"].ToString();
  10814. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  10815. }
  10816. DeleteColumn(serverPath, remarkIndex, remarkDel);
  10817. DeleteColumn(serverPath, cpIndex, cpDel);
  10818. DeleteColumn(serverPath, dsIndex, dsDel);
  10819. DeleteColumn(serverPath, cssIndex, cssDel);
  10820. DeleteColumn(serverPath, zcIndex, zcDel);
  10821. DeleteColumn(serverPath, otherIndex, otherDel);
  10822. DeleteColumn(serverPath, suiteIndex, suiteDel);
  10823. DeleteColumn(serverPath, doubleIndex, doubleDel);
  10824. DeleteColumn(serverPath, singleIndex, singleDel);
  10825. #endregion
  10826. //只保留第一个表格
  10827. DeleteSheet(serverPath);
  10828. return Ok(JsonView(true, "操作成功", url = rst));
  10829. }
  10830. /// <summary>
  10831. /// 删除指定列
  10832. /// </summary>
  10833. /// <param name="file"></param>
  10834. /// <param name="columnIndex"></param>
  10835. /// <param name="isDel"></param>
  10836. private void DeleteColumn(string file, int columnIndex, bool isDel)
  10837. {
  10838. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10839. //wb.Save(file);
  10840. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  10841. if (sheet1 != null)
  10842. {
  10843. if (isDel)
  10844. {
  10845. Cells cells = sheet1.Cells;
  10846. cells.DeleteColumn(columnIndex);
  10847. }
  10848. }
  10849. wb.Save(file);
  10850. }
  10851. /// <summary>
  10852. /// 删除sheet
  10853. /// </summary>
  10854. /// <param name="file"></param>
  10855. /// <param name="sheetName"></param>
  10856. private void DeleteSheet(string file, string sheetName = "")
  10857. {
  10858. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10859. //wb.Save(file);
  10860. List<string> sheets = new List<string>();
  10861. foreach (var item in wb.Worksheets)
  10862. {
  10863. sheets.Add(item.Name);
  10864. }
  10865. if (sheets.Count > 0)
  10866. {
  10867. sheets.RemoveAt(0);//不删除第一个sheet
  10868. foreach (var item in sheets)
  10869. {
  10870. wb.Worksheets.RemoveAt(item);
  10871. }
  10872. }
  10873. wb.Save(file);
  10874. }
  10875. /// <summary>
  10876. /// 酒店预订
  10877. /// 确认单
  10878. /// </summary>
  10879. /// <param name="_dto"></param>
  10880. /// <returns></returns>
  10881. [HttpPost]
  10882. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10883. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  10884. {
  10885. try
  10886. {
  10887. #region 参数验证
  10888. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10889. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10890. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10891. #region 团组操作权限验证 76 酒店预定模块
  10892. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10893. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10894. #endregion
  10895. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10896. #region 页面操作权限验证
  10897. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10898. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10899. #endregion
  10900. #endregion
  10901. //团组信息
  10902. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  10903. //酒店数据
  10904. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  10905. if (listhoteldata.Count < 0)
  10906. {
  10907. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  10908. }
  10909. //利datatable存储
  10910. DataTable dt = new DataTable();
  10911. dt.Columns.Add("CheckInDate", typeof(string));
  10912. dt.Columns.Add("City", typeof(string));
  10913. dt.Columns.Add("Hotel", typeof(string));
  10914. dt.Columns.Add("Room", typeof(string));
  10915. for (int i = 0; i < listhoteldata.Count; i++)
  10916. {
  10917. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  10918. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  10919. while (dayStart < dayEnd)
  10920. {
  10921. string temp = "";
  10922. DataRow row = dt.NewRow();
  10923. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  10924. row["City"] = listhoteldata[i].City;
  10925. row["Hotel"] = listhoteldata[i].HotelName;
  10926. if (listhoteldata[i].SingleRoomCount > 0)
  10927. {
  10928. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  10929. }
  10930. if (listhoteldata[i].DoubleRoomCount > 0)
  10931. {
  10932. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  10933. }
  10934. if (listhoteldata[i].SuiteRoomCount > 0)
  10935. {
  10936. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  10937. }
  10938. if (listhoteldata[i].OtherRoomCount > 0)
  10939. {
  10940. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  10941. }
  10942. row["Room"] = temp;
  10943. dt.Rows.Add(row);
  10944. dayStart = dayStart.AddDays(1);
  10945. }
  10946. }
  10947. Dictionary<string, string> dic = new Dictionary<string, string>();
  10948. dic.Add("Dele", di.TeamName);
  10949. dic.Add("City", di.VisitCountry);
  10950. //模板路径
  10951. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  10952. //载入模板
  10953. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  10954. DocumentBuilder builder = new DocumentBuilder(doc);
  10955. foreach (var key in dic.Keys)
  10956. {
  10957. builder.MoveToBookmark(key);
  10958. builder.Write(dic[key]);
  10959. }
  10960. //获取word里所有表格
  10961. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10962. //获取所填表格的序数
  10963. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10964. var rowStart = tableOne.Rows[0]; //获取第1行
  10965. //循环赋值
  10966. for (int i = 0; i < dt.Rows.Count; i++)
  10967. {
  10968. builder.MoveToCell(0, i + 1, 0, 0);
  10969. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  10970. builder.MoveToCell(0, i + 1, 1, 0);
  10971. builder.Write(dt.Rows[i]["City"].ToString());
  10972. builder.MoveToCell(0, i + 1, 2, 0);
  10973. builder.Write(dt.Rows[i]["Hotel"].ToString());
  10974. builder.MoveToCell(0, i + 1, 3, 0);
  10975. builder.Write(dt.Rows[i]["Room"].ToString());
  10976. }
  10977. //删除多余行
  10978. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  10979. {
  10980. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  10981. }
  10982. string strFileName = di.TeamName + "酒店确认单.doc";
  10983. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  10984. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  10985. return Ok(JsonView(true, "成功", url));
  10986. }
  10987. catch (Exception ex)
  10988. {
  10989. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  10990. }
  10991. }
  10992. #endregion
  10993. #region 团组状态
  10994. /// <summary>
  10995. /// 团组状态列表 Page
  10996. /// </summary>
  10997. /// <param name="dto">团组列表请求dto</param>
  10998. /// <returns></returns>
  10999. [HttpPost]
  11000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11001. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  11002. {
  11003. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  11004. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  11005. {
  11006. string sqlWhere = string.Empty;
  11007. if (dto.IsSure == 0) //未完成
  11008. {
  11009. sqlWhere += string.Format(@" And IsSure = 0");
  11010. }
  11011. else if (dto.IsSure == 1) //已完成
  11012. {
  11013. sqlWhere += string.Format(@" And IsSure = 1");
  11014. }
  11015. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  11016. {
  11017. string tj = dto.SearchCriteria;
  11018. 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}%')",
  11019. tj, tj, tj, tj, tj);
  11020. }
  11021. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  11022. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  11023. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  11024. From (
  11025. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  11026. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  11027. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  11028. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  11029. From Grp_DelegationInfo gdi
  11030. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  11031. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  11032. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  11033. Where gdi.IsDel = 0 {0}
  11034. ) temp ", sqlWhere);
  11035. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  11036. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  11037. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  11038. }
  11039. else
  11040. {
  11041. return Ok(JsonView(false, "查询失败"));
  11042. }
  11043. }
  11044. /// <summary>
  11045. /// 团组状态
  11046. /// 设置操作完成
  11047. /// </summary>
  11048. /// <param name="dto">团组列表请求dto</param>
  11049. /// <returns></returns>
  11050. [HttpPost]
  11051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11052. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  11053. {
  11054. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  11055. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  11056. {
  11057. Id = dto.Id,
  11058. IsSure = 1
  11059. };
  11060. var result = await _sqlSugar.Updateable(_DelegationInfo)
  11061. .UpdateColumns(it => new { it.IsSure })
  11062. .WhereColumns(it => new { it.Id })
  11063. .ExecuteCommandAsync();
  11064. if (result > 0)
  11065. {
  11066. return Ok(JsonView(true, "操作完成!"));
  11067. }
  11068. return Ok(JsonView(false, "操作失败!"));
  11069. }
  11070. #endregion
  11071. #region 保险费用录入
  11072. /// <summary>
  11073. /// 根据团组Id查询保险费用列表
  11074. /// </summary>
  11075. /// <param name="dto"></param>
  11076. /// <returns></returns>
  11077. [HttpPost]
  11078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11079. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  11080. {
  11081. Result groupData = await _customersRep.CustomersByDiId(dto);
  11082. if (groupData.Code != 0)
  11083. {
  11084. return Ok(JsonView(false, groupData.Msg));
  11085. }
  11086. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11087. }
  11088. /// <summary>
  11089. /// 根据保险费用Id查询保险费用详细
  11090. /// </summary>
  11091. /// <param name="dto"></param>
  11092. /// <returns></returns>
  11093. [HttpPost]
  11094. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11095. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  11096. {
  11097. try
  11098. {
  11099. Result groupData = await _customersRep.CustomersById(dto);
  11100. if (groupData.Code != 0)
  11101. {
  11102. return Ok(JsonView(false, groupData.Msg));
  11103. }
  11104. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11105. }
  11106. catch (Exception ex)
  11107. {
  11108. return Ok(JsonView(false, ex.Message));
  11109. }
  11110. }
  11111. /// <summary>
  11112. /// 保险费用录入页面初始化绑定
  11113. /// </summary>
  11114. /// <param name="dto"></param>
  11115. /// <returns></returns>
  11116. [HttpPost]
  11117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11118. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  11119. {
  11120. try
  11121. {
  11122. Result groupData = await _customersRep.CustomersInitialize(dto);
  11123. if (groupData.Code != 0)
  11124. {
  11125. return Ok(JsonView(false, groupData.Msg));
  11126. }
  11127. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11128. }
  11129. catch (Exception ex)
  11130. {
  11131. return Ok(JsonView(false, ex.Message));
  11132. }
  11133. }
  11134. /// <summary>
  11135. /// 保险费用操作(Status:1.新增,2.修改)
  11136. /// </summary>
  11137. /// <param name="dto"></param>
  11138. /// <returns></returns>
  11139. [HttpPost]
  11140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11141. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  11142. {
  11143. Result groupData = await _customersRep.OpCustomers(dto);
  11144. if (groupData.Code != 0)
  11145. {
  11146. return Ok(JsonView(false, groupData.Msg));
  11147. }
  11148. #region 应用推送
  11149. try
  11150. {
  11151. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11152. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11153. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11154. //2024-10-21 新增LZ UID
  11155. var userIds = new List<int>() { 21 };
  11156. string title = $"系统通知";
  11157. var diId = dto.DiId;
  11158. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11159. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11160. string content = "";
  11161. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11162. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11163. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11164. }
  11165. catch (Exception ex)
  11166. {
  11167. }
  11168. #endregion
  11169. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11170. }
  11171. /// <summary>
  11172. /// 保险文件上传
  11173. /// </summary>
  11174. /// <param name="file"></param>
  11175. /// <returns></returns>
  11176. [HttpPost]
  11177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11178. public async Task<IActionResult> UploadCus(IFormFile file)
  11179. {
  11180. try
  11181. {
  11182. if (file != null)
  11183. {
  11184. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  11185. //文件名称
  11186. string projectFileName = file.FileName;
  11187. //上传的文件的路径
  11188. string filePath = "";
  11189. if (!Directory.Exists(fileDir))
  11190. {
  11191. Directory.CreateDirectory(fileDir);
  11192. }
  11193. //上传的文件的路径
  11194. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  11195. using (FileStream fs = System.IO.File.Create(filePath))
  11196. {
  11197. file.CopyTo(fs);
  11198. fs.Flush();
  11199. }
  11200. return Ok(JsonView(true, "上传成功!", projectFileName));
  11201. }
  11202. else
  11203. {
  11204. return Ok(JsonView(false, "上传失败!"));
  11205. }
  11206. }
  11207. catch (Exception ex)
  11208. {
  11209. return Ok(JsonView(false, "程序错误!"));
  11210. throw;
  11211. }
  11212. }
  11213. /// <summary>
  11214. /// 保险删除指定文件
  11215. /// </summary>
  11216. /// <param name="dto"></param>
  11217. /// <returns></returns>
  11218. [HttpPost]
  11219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11220. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  11221. {
  11222. try
  11223. {
  11224. string filePath = "";
  11225. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  11226. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  11227. //int id = 0;
  11228. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  11229. // 删除该文件
  11230. try
  11231. {
  11232. System.IO.File.Delete(filePath);
  11233. 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()
  11234. {
  11235. Attachment = "",
  11236. }).ExecuteCommandAsync();
  11237. if (result != 0)
  11238. {
  11239. return Ok(JsonView(true, "成功!"));
  11240. }
  11241. else
  11242. {
  11243. return Ok(JsonView(false, "失败!"));
  11244. }
  11245. }
  11246. catch (Exception)
  11247. {
  11248. 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()
  11249. {
  11250. Attachment = "",
  11251. }).ExecuteCommandAsync();
  11252. if (result != 0)
  11253. {
  11254. return Ok(JsonView(true, "成功!"));
  11255. }
  11256. else
  11257. {
  11258. return Ok(JsonView(false, "失败!"));
  11259. }
  11260. }
  11261. }
  11262. catch (Exception ex)
  11263. {
  11264. return Ok(JsonView(false, "程序错误!"));
  11265. throw;
  11266. }
  11267. }
  11268. /// <summary>
  11269. /// 保险费用操作(删除)
  11270. /// </summary>
  11271. /// <param name="dto"></param>
  11272. /// <returns></returns>
  11273. [HttpPost]
  11274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11275. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  11276. {
  11277. try
  11278. {
  11279. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  11280. if (!res)
  11281. {
  11282. return Ok(JsonView(false, "删除失败"));
  11283. }
  11284. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  11285. {
  11286. IsDel = 1,
  11287. DeleteUserId = dto.DeleteUserId,
  11288. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11289. }).ExecuteCommandAsync();
  11290. return Ok(JsonView(true, "删除成功!"));
  11291. }
  11292. catch (Exception ex)
  11293. {
  11294. return Ok(JsonView(false, "程序错误!"));
  11295. throw;
  11296. }
  11297. }
  11298. #endregion
  11299. #region 接团客户名单 PageId 104
  11300. /// <summary>
  11301. /// 接团客户名单
  11302. /// 迁移数据(慎用!)
  11303. /// </summary>
  11304. /// <param name="dto"></param>
  11305. /// <returns></returns>
  11306. [HttpPost]
  11307. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11308. public async Task<IActionResult> PostTourClientListChange()
  11309. {
  11310. try
  11311. {
  11312. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  11313. //var groupClinetData1
  11314. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  11315. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  11316. int updateCount = 0;
  11317. if (oldOAClientList.Count > 0)
  11318. {
  11319. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  11320. _sqlSugar.BeginTran();
  11321. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  11322. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  11323. foreach (var item in oldOAClientList)
  11324. {
  11325. int comId = 0;
  11326. string format = "yyyy-MM-dd HH:mm:ss";
  11327. string data11 = "1990-01-01 00:00";
  11328. var data1 = IsValidDate(item.OPdate, format);
  11329. if (data1) data11 = item.OPdate;
  11330. //客户公司验证
  11331. if (!string.IsNullOrEmpty(item.Company))
  11332. {
  11333. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  11334. if (clientComInfo == null) // add
  11335. {
  11336. var addInfo = new Crm_CustomerCompany()
  11337. {
  11338. CompanyAbbreviation = "",
  11339. CompanyFullName = item.Company,
  11340. Address = "",
  11341. PostCodes = "",
  11342. LastedOpUserId = item.OPer,
  11343. LastedOpDt = Convert.ToDateTime(data11),
  11344. CreateUserId = item.OPer,
  11345. CreateTime = Convert.ToDateTime(data11),
  11346. IsDel = 0
  11347. };
  11348. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  11349. if (comId1 > 0) comId = comId1;
  11350. }
  11351. else comId = clientComInfo.Id;
  11352. }
  11353. //客户人员验证
  11354. int clientId = 0;
  11355. string name = item.LastName + item.Name;
  11356. if (!string.IsNullOrEmpty(name))
  11357. {
  11358. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  11359. if (clientInfo == null)
  11360. {
  11361. DateTime? dateTime = null;
  11362. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  11363. if (isDt) dateTime = birthDayDt;
  11364. var addInfo1 = new Crm_DeleClient()
  11365. {
  11366. CrmCompanyId = comId,
  11367. DiId = -1,
  11368. LastName = item.LastName,
  11369. FirstName = item.Name,
  11370. OldName = "",
  11371. Pinyin = item.Pinyin,
  11372. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  11373. Marriage = 0,
  11374. Phone = item.Phone,
  11375. Job = item.Job,
  11376. BirthDay = dateTime
  11377. };
  11378. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  11379. if (clientId1 > 0) clientId = clientId1;
  11380. }
  11381. else clientId = clientInfo.Id;
  11382. }
  11383. if (clientId < 1)
  11384. {
  11385. continue;
  11386. }
  11387. int airType = 0;
  11388. if (item.AirType == "超经舱") airType = 459;
  11389. else if (item.AirType == "公务舱") airType = 458;
  11390. else if (item.AirType == "经济舱") airType = 460;
  11391. else if (item.AirType == "其他") airType = 565;
  11392. else if (item.AirType == "头等舱") airType = 457;
  11393. var _TourClientListEntity = new Grp_TourClientList()
  11394. {
  11395. DiId = item.Diid,
  11396. ClientId = clientId,
  11397. CreateUserId = item.OPer,
  11398. CreateTime = Convert.ToDateTime(data11),
  11399. Remark = item.Remark,
  11400. IsDel = item.Isdel,
  11401. ShippingSpaceTypeId = airType,
  11402. ShippingSpaceSpecialNeeds = item.AirRemark,
  11403. HotelSpecialNeeds = item.RoomType
  11404. };
  11405. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  11406. if (_TourClientList > 0)
  11407. {
  11408. updateCount++;
  11409. }
  11410. }
  11411. _sqlSugar.CommitTran();
  11412. }
  11413. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  11414. }
  11415. catch (Exception ex)
  11416. {
  11417. _sqlSugar.RollbackTran();
  11418. return Ok(JsonView(false, ex.Message));
  11419. }
  11420. return Ok(JsonView(true));
  11421. }
  11422. private bool IsValidDate(string dateString, string format)
  11423. {
  11424. DateTime dateValue;
  11425. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  11426. return valid;
  11427. }
  11428. /// <summary>
  11429. /// 接团客户名单
  11430. /// 根据团组Id查询List
  11431. /// </summary>
  11432. /// <param name="dto"></param>
  11433. /// <returns></returns>
  11434. [HttpPost]
  11435. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11436. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  11437. {
  11438. #region 参数验证
  11439. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  11440. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  11441. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  11442. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11443. #region 页面操作权限验证
  11444. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11445. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11446. #endregion
  11447. #endregion
  11448. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  11449. if (viewData.Code != 0)
  11450. {
  11451. return Ok(JsonView(false, viewData.Msg));
  11452. }
  11453. return Ok(JsonView(viewData.Data));
  11454. }
  11455. /// <summary>
  11456. /// 接团客户名单
  11457. /// 基础数据 Init
  11458. /// </summary>
  11459. /// <param name="_dto"></param>
  11460. /// <returns></returns>
  11461. [HttpPost]
  11462. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11463. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  11464. {
  11465. #region 参数验证
  11466. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11467. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11468. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11469. #region 页面操作权限验证
  11470. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11471. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11472. #endregion
  11473. #endregion
  11474. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  11475. }
  11476. /// <summary>
  11477. /// 接团客户名单
  11478. /// 根据 Id查询 Details
  11479. /// </summary>
  11480. /// <param name="_dto"></param>
  11481. /// <returns></returns>
  11482. [HttpPost]
  11483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11484. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  11485. {
  11486. #region 参数验证
  11487. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11488. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11489. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11490. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11491. #region 页面操作权限验证
  11492. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11493. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11494. #endregion
  11495. #endregion
  11496. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  11497. if (viewData.Code != 0)
  11498. {
  11499. return Ok(JsonView(false, viewData.Msg));
  11500. }
  11501. return Ok(JsonView(viewData.Data));
  11502. }
  11503. /// <summary>
  11504. /// 接团客户名单
  11505. /// Add Or Edit
  11506. /// </summary>
  11507. /// <param name="_dto"></param>
  11508. /// <returns></returns>
  11509. [HttpPost]
  11510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11511. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  11512. {
  11513. #region 参数验证
  11514. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11515. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11516. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11517. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11518. #region 页面操作权限验证
  11519. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11520. if (_dto.Id == 0) //添加
  11521. {
  11522. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11523. }
  11524. else if (_dto.Id >= 0) //修改
  11525. {
  11526. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  11527. }
  11528. #endregion
  11529. #endregion
  11530. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  11531. if (viewData.Code != 0)
  11532. {
  11533. return Ok(JsonView(false, viewData.Msg));
  11534. }
  11535. return Ok(JsonView(true));
  11536. }
  11537. /// <summary>
  11538. /// 接团客户名单
  11539. /// AddMultiple(添加多个)
  11540. /// </summary>
  11541. /// <param name="_dto"></param>
  11542. /// <returns></returns>
  11543. [HttpPost]
  11544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11545. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  11546. {
  11547. #region 参数验证
  11548. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11549. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11550. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11551. #region 页面操作权限验证
  11552. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11553. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11554. #endregion
  11555. #endregion
  11556. var viewData = await _tourClientListRep._AddMultiple(_dto);
  11557. if (viewData.Code != 0)
  11558. {
  11559. return Ok(JsonView(false, viewData.Msg));
  11560. }
  11561. return Ok(JsonView(true));
  11562. }
  11563. /// <summary>
  11564. /// 接团客户名单
  11565. /// Del
  11566. /// </summary>
  11567. /// <param name="_dto"></param>
  11568. /// <returns></returns>
  11569. [HttpPost]
  11570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11571. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  11572. {
  11573. #region 参数验证
  11574. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11575. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11576. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11577. #region 页面操作权限验证
  11578. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11579. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  11580. #endregion
  11581. #endregion
  11582. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  11583. if (viewData.Code != 0)
  11584. {
  11585. return Ok(JsonView(false, viewData.Msg));
  11586. }
  11587. return Ok(JsonView(true));
  11588. }
  11589. /// <summary>
  11590. /// 接团客户名单
  11591. /// 文件下载 客户名单
  11592. /// </summary>
  11593. /// <param name="_dto"></param>
  11594. /// <returns></returns>
  11595. [HttpPost]
  11596. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11597. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  11598. {
  11599. #region 参数验证
  11600. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11601. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11602. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  11603. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11604. #region 页面操作权限验证
  11605. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11606. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11607. #endregion
  11608. #endregion
  11609. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  11610. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  11611. From Grp_TourClientList tcl
  11612. Left Join
  11613. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  11614. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  11615. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  11616. From Crm_DeleClient dc
  11617. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  11618. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  11619. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  11620. Where dc.IsDel = 0) temp
  11621. On temp.DcId =tcl.ClientId
  11622. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  11623. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  11624. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  11625. //载入模板
  11626. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  11627. if (_dto.Language == 1)
  11628. {
  11629. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  11630. }
  11631. //载入模板
  11632. var doc = new Document(tempPath);
  11633. DocumentBuilder builder = new DocumentBuilder(doc);
  11634. //获取word里所有表格
  11635. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11636. //获取所填表格的序数
  11637. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11638. var rowStart = tableOne.Rows[0]; //获取第1行
  11639. if (_dto.Language == 0)
  11640. {
  11641. //循环赋值
  11642. for (int i = 0; i < DcList.Count; i++)
  11643. {
  11644. builder.MoveToCell(0, i + 1, 0, 0);
  11645. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  11646. builder.MoveToCell(0, i + 1, 1, 0);
  11647. int sex = DcList[i].Sex;
  11648. string sexStr = string.Empty;
  11649. if (sex == 0) sexStr = "男";
  11650. else if (sex == 1) sexStr = "女";
  11651. else sexStr = "未设置";
  11652. builder.Write(sexStr);
  11653. builder.MoveToCell(0, i + 1, 2, 0);
  11654. string birthDay = DcList[i].BirthDay;
  11655. string birthDayStr = string.Empty;
  11656. if (!string.IsNullOrEmpty(birthDay))
  11657. {
  11658. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  11659. }
  11660. builder.Write(birthDayStr);
  11661. builder.MoveToCell(0, i + 1, 3, 0);
  11662. string company = "";
  11663. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11664. {
  11665. company = DcList[i].CompanyFullName.ToString();
  11666. }
  11667. builder.Write(company);
  11668. builder.MoveToCell(0, i + 1, 4, 0);
  11669. builder.Write(DcList[i].Job);
  11670. }
  11671. }
  11672. else if (_dto.Language == 1)
  11673. {
  11674. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  11675. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  11676. List<string> transArrayStr = new List<string>();
  11677. string transStrRes1 = "";
  11678. for (int i = 0; i < DcList.Count; i++)
  11679. {
  11680. var dc = DcList[i];
  11681. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  11682. if (dc.Job.Equals("暂无")) dc.Job = "-";
  11683. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  11684. if (DcList.Count - 1 == i) transStrRes1 += str1;
  11685. else transStrRes1 += $"{str1}|";
  11686. }
  11687. //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";
  11688. string transStrRes = "";
  11689. if (transStrRes1.Length > 0)
  11690. {
  11691. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  11692. }
  11693. //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
  11694. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  11695. //List<string> transArray = new List<string> { };
  11696. List<TranslateInfo> transArray = new List<TranslateInfo>();
  11697. if (transStrRes.Contains("|"))
  11698. {
  11699. string[] transArray1 = transStrRes.Split('|');
  11700. if (transArray1.Length > 0)
  11701. {
  11702. foreach (var item in transArray1)
  11703. {
  11704. if (item.Contains("&"))
  11705. {
  11706. string[] transArray2 = item.Split('&');
  11707. int index = 0;
  11708. string companyName = "", job = "";
  11709. if (transArray2.Length > 0)
  11710. {
  11711. bool success = int.TryParse(transArray2[0].Trim(), out index);
  11712. if (1 < transArray2.Length) companyName = transArray2[1];
  11713. if (2 < transArray2.Length) job = transArray2[2];
  11714. }
  11715. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  11716. }
  11717. }
  11718. }
  11719. }
  11720. //循环赋值
  11721. for (int i = 0; i < DcList.Count; i++)
  11722. {
  11723. string PYName = "";
  11724. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  11725. {
  11726. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  11727. string PY_First = DcList[i].Pinyin.Split('/')[1];
  11728. PYName = PY_First + " " + PY_Last;
  11729. }
  11730. else
  11731. {
  11732. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  11733. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  11734. PYName = PY_First + " " + PY_Last;
  11735. }
  11736. builder.MoveToCell(0, i + 1, 0, 0);
  11737. builder.Write(PYName);
  11738. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  11739. builder.MoveToCell(0, i + 1, 1, 0);
  11740. builder.Write(sex);
  11741. DateTime birthDt;
  11742. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  11743. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  11744. builder.MoveToCell(0, i + 1, 2, 0);
  11745. builder.Write(birthday);
  11746. string company = string.Empty, job = string.Empty;
  11747. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  11748. if (dcTransInfo != null)
  11749. {
  11750. company = dcTransInfo.CompanyName;
  11751. job = dcTransInfo.Job;
  11752. }
  11753. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11754. {
  11755. //查询对照表
  11756. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  11757. if (tempCec != null)
  11758. {
  11759. company = tempCec.enName;
  11760. }
  11761. //翻译
  11762. else
  11763. {
  11764. }
  11765. }
  11766. builder.MoveToCell(0, i + 1, 3, 0);
  11767. builder.Write(company);
  11768. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  11769. {
  11770. //查询对照表
  11771. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  11772. if (tempPec != null)
  11773. {
  11774. job = tempPec.enName;
  11775. }
  11776. //翻译
  11777. else
  11778. {
  11779. }
  11780. }
  11781. builder.MoveToCell(0, i + 1, 4, 0);
  11782. builder.Write(job);
  11783. }
  11784. }
  11785. //删除多余行
  11786. while (tableOne.Rows.Count > DcList.Count + 1)
  11787. {
  11788. tableOne.Rows.RemoveAt(DcList.Count + 1);
  11789. }
  11790. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  11791. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  11792. doc.Save(fileDir);
  11793. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  11794. return Ok(JsonView(true, "操作成功!", Url));
  11795. }
  11796. private class TranslateInfo
  11797. {
  11798. public int Index { get; set; }
  11799. public string CompanyName { get; set; }
  11800. public string Job { get; set; }
  11801. }
  11802. #endregion
  11803. #region 团组倒推表
  11804. /// <summary>
  11805. /// 倒推表基础数据
  11806. /// Init
  11807. /// </summary>
  11808. /// <param name="dto"></param>
  11809. /// <returns></returns>
  11810. [HttpPost]
  11811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11812. public async Task<IActionResult> PostInvertedListInit()
  11813. {
  11814. var viewData = await _invertedListRep._Init();
  11815. if (viewData.Code != 0)
  11816. {
  11817. return Ok(JsonView(false, viewData.Msg));
  11818. }
  11819. return Ok(JsonView(viewData.Data));
  11820. }
  11821. /// <summary>
  11822. /// 倒推表
  11823. /// Info
  11824. /// </summary>
  11825. /// <param name="dto"></param>
  11826. /// <returns></returns>
  11827. [HttpPost]
  11828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11829. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  11830. {
  11831. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  11832. if (viewData.Code != 0)
  11833. {
  11834. return Ok(JsonView(false, viewData.Msg));
  11835. }
  11836. return Ok(JsonView(viewData.Data));
  11837. }
  11838. /// <summary>
  11839. /// 倒推表
  11840. /// Create
  11841. /// </summary>
  11842. /// <param name="dto"></param>
  11843. /// <returns></returns>
  11844. [HttpPost]
  11845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11846. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  11847. {
  11848. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  11849. if (viewData.Code != 0)
  11850. {
  11851. return Ok(JsonView(false, viewData.Msg));
  11852. }
  11853. return Ok(JsonView(viewData.Data));
  11854. }
  11855. /// <summary>
  11856. /// 倒推表
  11857. /// Update
  11858. /// </summary>
  11859. /// <param name="dto"></param>
  11860. /// <returns></returns>
  11861. [HttpPost]
  11862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11863. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  11864. {
  11865. var viewData = await _invertedListRep._Update(dto);
  11866. if (viewData.Code != 0)
  11867. {
  11868. return Ok(JsonView(false, viewData.Msg));
  11869. }
  11870. return Ok(JsonView(viewData.Data));
  11871. }
  11872. /// <summary>
  11873. /// 倒推表
  11874. /// File Download
  11875. /// </summary>
  11876. /// <param name="dto"></param>
  11877. /// <returns></returns>
  11878. [HttpPost]
  11879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11880. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  11881. {
  11882. var info2 = await _invertedListRep._Info(1, dto.DiId);
  11883. if (info2.Code != 0)
  11884. {
  11885. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  11886. }
  11887. var info1 = info2.Data as InvertedListInfoView;
  11888. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  11889. string teamName = "";
  11890. if (info != null) teamName = info.TeamName;
  11891. //载入模板
  11892. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  11893. DocumentBuilder builder = new DocumentBuilder(doc);
  11894. //利用键值对存放数据
  11895. Dictionary<string, string> dic = new Dictionary<string, string>();
  11896. dic.Add("TeamName", teamName);
  11897. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  11898. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  11899. dic.Add("BPRemark", info1.ApprovalDataRemark);
  11900. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  11901. dic.Add("SQRemark", info1.ApprovalRemark);
  11902. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  11903. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  11904. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  11905. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  11906. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  11907. dic.Add("QZRemark", info1.VisaInformationRemark);
  11908. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  11909. dic.Add("SQQZRemark", info1.SendVisaRemark);
  11910. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  11911. dic.Add("CQRemark", info1.IssueVisaRemark);
  11912. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  11913. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  11914. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  11915. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  11916. #region 填充word模板书签内容
  11917. foreach (var key in dic.Keys)
  11918. {
  11919. builder.MoveToBookmark(key);
  11920. builder.Write(dic[key]);
  11921. }
  11922. #endregion
  11923. var fileDir = AppSettingsHelper.Get("WordBasePath");
  11924. string fileName = $"{teamName}团出行准备流程表.doc";
  11925. string filePath = fileDir + $@"InvertedList/{fileName}";
  11926. doc.Save(filePath);
  11927. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  11928. return Ok(JsonView(true, "操作成功!", Url));
  11929. }
  11930. #endregion
  11931. #region 三公签证费用(签证费、代办费)
  11932. /// <summary>
  11933. /// 三公签证费用(签证费、代办费)
  11934. /// List
  11935. /// </summary>
  11936. /// <returns></returns>
  11937. [HttpPost]
  11938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11939. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  11940. {
  11941. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  11942. if (_view.Code != 0)
  11943. {
  11944. return Ok(JsonView(false, _view.Msg));
  11945. }
  11946. return Ok(JsonView(true, "操作成功!", _view.Data));
  11947. }
  11948. /// <summary>
  11949. /// 三公签证费用(签证费、代办费)
  11950. /// Add Or Update
  11951. /// </summary>
  11952. /// <returns></returns>
  11953. [HttpPost]
  11954. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11955. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  11956. {
  11957. var _view = await _visaFeeInfoRep._Update(_dto);
  11958. if (_view.Code != 0)
  11959. {
  11960. return Ok(JsonView(false, _view.Msg));
  11961. }
  11962. return Ok(JsonView(true, _view.Msg));
  11963. }
  11964. #endregion
  11965. #region 酒店询价
  11966. /// <summary>
  11967. /// 酒店询价
  11968. /// Init
  11969. /// </summary>
  11970. /// <param name="dto"></param>
  11971. /// <returns></returns>
  11972. [HttpPost]
  11973. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11974. public async Task<IActionResult> PostHotelInquiryInit()
  11975. {
  11976. var res = await _hotelInquiryRep._Init();
  11977. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11978. return Ok(JsonView(true, res.Msg, res.Data));
  11979. }
  11980. /// <summary>
  11981. /// 酒店询价
  11982. /// page Item
  11983. /// </summary>
  11984. /// <param name="_dto"></param>
  11985. /// <returns></returns>
  11986. [HttpPost]
  11987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11988. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  11989. {
  11990. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  11991. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11992. var view = res.Data as PageDataViewBase;
  11993. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  11994. }
  11995. /// <summary>
  11996. /// 酒店询价
  11997. /// info
  11998. /// </summary>
  11999. /// <param name="_dto"></param>
  12000. /// <returns></returns>
  12001. [HttpPost]
  12002. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12003. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  12004. {
  12005. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  12006. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12007. return Ok(JsonView(true, res.Msg, res.Data));
  12008. }
  12009. /// <summary>
  12010. /// 酒店询价
  12011. /// Add Or Edit
  12012. /// </summary>
  12013. /// <param name="_dto"></param>
  12014. /// <returns></returns>
  12015. [HttpPost]
  12016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12017. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  12018. {
  12019. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  12020. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12021. return Ok(JsonView(true, res.Msg, res.Data));
  12022. }
  12023. /// <summary>
  12024. /// 酒店询价
  12025. /// Del
  12026. /// </summary>
  12027. /// <param name="_dto"></param>
  12028. /// <returns></returns>
  12029. [HttpPost]
  12030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12031. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  12032. {
  12033. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  12034. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12035. return Ok(JsonView(true, res.Msg, res.Data));
  12036. }
  12037. #endregion
  12038. #region 下载匹配op行程单
  12039. /// <summary>
  12040. /// 匹配op行程单
  12041. /// Init
  12042. /// </summary>
  12043. /// <param name="dto">团组列表请求dto</param>
  12044. /// <returns></returns>
  12045. [HttpPost]
  12046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12047. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  12048. {
  12049. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  12050. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12051. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  12052. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  12053. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  12054. .Where(it => it.IsDel == 0)
  12055. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  12056. .OrderByDescending(it => it.CreateUserId)
  12057. .ToList();
  12058. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  12059. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12060. var diids = groupInfos.Select(it => it.Id).ToList();
  12061. List<string> countrys = new List<string>();
  12062. foreach (var item in country)
  12063. {
  12064. var data = _groupRepository.FormartTeamName(item);
  12065. var dataArray = _groupRepository.GroupSplitCountry(data);
  12066. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12067. }
  12068. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  12069. List<string> areaArray = new List<string>(); //GetGroupCityLine
  12070. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  12071. foreach (var item in areaItem)
  12072. {
  12073. string areaStr = item.Value;
  12074. if (!string.IsNullOrEmpty(areaStr))
  12075. {
  12076. string[] str1 = areaStr.Split("-");
  12077. if (str1.Length > 0)
  12078. {
  12079. areaArray.AddRange(str1);
  12080. }
  12081. }
  12082. }
  12083. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  12084. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  12085. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  12086. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  12087. .ToList();
  12088. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  12089. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  12090. .Where(it => countriesIds.Contains(it.Id))
  12091. .Select(it => new { it.Id, Name = it.Name_CN })
  12092. .ToList();
  12093. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  12094. .Select(it => it.TeamName).ToList();
  12095. stopwatch.Stop();
  12096. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  12097. }
  12098. ///// <summary>
  12099. ///// 匹配op行程单
  12100. ///// Init 查询区域数据
  12101. ///// </summary>
  12102. ///// <param name="dto">团组列表请求dto</param>
  12103. ///// <returns></returns>
  12104. //[HttpPost]
  12105. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12106. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  12107. //{
  12108. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  12109. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  12110. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  12111. // if (string.IsNullOrEmpty(countriesDataStr))
  12112. // {
  12113. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  12114. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  12115. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  12116. // }
  12117. // else
  12118. // {
  12119. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  12120. // }
  12121. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  12122. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  12123. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  12124. // List<dynamic> childList = new List<dynamic>();
  12125. // int parentId = dto.CountriesId;
  12126. // if (provinceData.Count > 1)
  12127. // {
  12128. // foreach (var item1 in provinceData)
  12129. // {
  12130. // List<dynamic> childList1 = new List<dynamic>();
  12131. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  12132. // foreach (var item2 in citiesData1)
  12133. // {
  12134. // List<dynamic> childList2 = new List<dynamic>();
  12135. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12136. // foreach (var item3 in countiesData1)
  12137. // {
  12138. // childList2.Add(new
  12139. // {
  12140. // id = item3.Id,
  12141. // parentId = item2.Id,
  12142. // level = "district",
  12143. // name = item3.Name_CN,
  12144. // });
  12145. // }
  12146. // childList1.Add(new
  12147. // {
  12148. // id = item2.Id,
  12149. // parentId = item1.Id,
  12150. // level = "city",
  12151. // name = item2.Name_CN,
  12152. // childList = childList2
  12153. // });
  12154. // }
  12155. // childList.Add(new
  12156. // {
  12157. // id = item1.Id,
  12158. // parentId = parentId,
  12159. // level = "province",
  12160. // name = item1.Name_CN,
  12161. // childList = childList1
  12162. // });
  12163. // }
  12164. // //城市
  12165. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  12166. // foreach (var item2 in citiesData2)
  12167. // {
  12168. // List<dynamic> childList22 = new List<dynamic>();
  12169. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12170. // foreach (var item3 in countiesData1)
  12171. // {
  12172. // childList22.Add(new
  12173. // {
  12174. // id = item3.Id,
  12175. // parentId = item2.Id,
  12176. // level = "district",
  12177. // name = item3.Name_CN,
  12178. // });
  12179. // }
  12180. // childList.Add(new
  12181. // {
  12182. // id = item2.Id,
  12183. // parentId = parentId,
  12184. // level = "city",
  12185. // name = item2.Name_CN,
  12186. // childList = childList22
  12187. // });
  12188. // }
  12189. // }
  12190. // else
  12191. // {
  12192. // foreach (var item2 in citiesData)
  12193. // {
  12194. // string cname = item2.Name_CN;
  12195. // List<dynamic> childList1 = new List<dynamic>();
  12196. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12197. // foreach (var item3 in countiesData1)
  12198. // {
  12199. // childList1.Add(new
  12200. // {
  12201. // Id = item3.Id,
  12202. // parentId = item2.Id,
  12203. // level = "district",
  12204. // name = item3.Name_CN
  12205. // });
  12206. // }
  12207. // childList.Add(new
  12208. // {
  12209. // id = item2.Id,
  12210. // parentId = parentId,
  12211. // level = "city",
  12212. // name = item2.Name_CN,
  12213. // childList = childList1
  12214. // });
  12215. // }
  12216. // }
  12217. // stopwatch.Stop();
  12218. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  12219. //}
  12220. /// <summary>
  12221. /// 匹配op行程单
  12222. /// 接团信息列表 Page
  12223. /// </summary>
  12224. /// <param name="dto">团组列表请求dto</param>
  12225. /// <returns></returns>
  12226. [HttpPost]
  12227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12228. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  12229. {
  12230. var swatch = new Stopwatch();
  12231. swatch.Start();
  12232. #region 参数验证
  12233. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12234. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12235. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12236. #region 页面操作权限验证
  12237. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12238. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  12239. #endregion
  12240. #endregion
  12241. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12242. {
  12243. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  12244. string sqlWhere = "";
  12245. if (!string.IsNullOrEmpty(dto.Country))
  12246. {
  12247. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  12248. }
  12249. if (!string.IsNullOrEmpty(dto.Area))
  12250. {
  12251. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  12252. }
  12253. if (!string.IsNullOrEmpty(dto.TeamName))
  12254. {
  12255. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  12256. }
  12257. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  12258. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  12259. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  12260. swatch.Stop();
  12261. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  12262. }
  12263. else
  12264. {
  12265. return Ok(JsonView(false, "查询失败"));
  12266. }
  12267. }
  12268. /// <summary>
  12269. /// 匹配op行程单
  12270. /// 行程单下载
  12271. /// </summary>
  12272. /// <param name="dto">团组列表请求dto</param>
  12273. /// <returns></returns>
  12274. [HttpPost]
  12275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12276. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  12277. {
  12278. #region 参数验证
  12279. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12280. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12281. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12282. #region 页面操作权限验证
  12283. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12284. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  12285. #endregion
  12286. #endregion
  12287. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12288. {
  12289. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  12290. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  12291. }
  12292. else
  12293. {
  12294. return Ok(JsonView(false, "下载失败!"));
  12295. }
  12296. }
  12297. #endregion
  12298. #region 国家信息 数据 注释
  12299. //[HttpPost]
  12300. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  12301. //{
  12302. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  12303. // foreach (var item in dto)
  12304. // {
  12305. // infos.Add(new Grp_GroupsTaskAssignment()
  12306. // {
  12307. // DIId = item,
  12308. // CTId = 82,
  12309. // UId = 248,
  12310. // IsEnable = 1,
  12311. // CreateUserId = 233,
  12312. // CreateTime = DateTime.Now,
  12313. // IsDel = 0
  12314. // });
  12315. // infos.Add(new Grp_GroupsTaskAssignment()
  12316. // {
  12317. // DIId = item,
  12318. // CTId = 82,
  12319. // UId = 286,
  12320. // IsEnable = 1,
  12321. // CreateUserId = 233,
  12322. // CreateTime = DateTime.Now,
  12323. // IsDel = 0
  12324. // });
  12325. // }
  12326. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  12327. // return Ok("操作成功");
  12328. //}
  12329. //public class paramJsonDto
  12330. //{
  12331. // public List<CountriesInfo> str { get; set; }
  12332. //}
  12333. //[HttpPost]
  12334. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  12335. //{
  12336. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  12337. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  12338. // List<Sys_Cities> cities = new List<Sys_Cities>();
  12339. // List<Sys_Cities> districts = new List<Sys_Cities>();
  12340. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12341. // _sqlSugar.BeginTran();
  12342. // int countitiesIndex = 0;
  12343. // foreach (var item in dto.str)
  12344. // {
  12345. // dynamic data = item.c;
  12346. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  12347. // if (data != null)
  12348. // {
  12349. // countitiesIndex++;
  12350. // foreach (var item1 in data)
  12351. // {
  12352. // string cnname = item1.cn;
  12353. // string enname = item1.en;
  12354. // Sys_Cities provinceInfo = new Sys_Cities()
  12355. // {
  12356. // CountriesId = countriesId,
  12357. // Name_CN = cnname,
  12358. // Name_EN = enname,
  12359. // ParentId = 0,
  12360. // IsCapital = 1,
  12361. // CreateUserId = 208,
  12362. // CreateTime = DateTime.Now,
  12363. // IsDel = 0
  12364. // };
  12365. // if (item1.lv == "province") //省份
  12366. // {
  12367. // provinceInfo.Level = 1;
  12368. // int provinceId = 0;
  12369. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  12370. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  12371. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12372. // var data1 = item1.c;
  12373. // foreach (var item2 in data1)
  12374. // {
  12375. // if (item2.lv == "city")
  12376. // {
  12377. // string citycnname = item2.cn;
  12378. // string cityenname = item2.en;
  12379. // Sys_Cities cityInfo = new Sys_Cities()
  12380. // {
  12381. // CountriesId = countriesId,
  12382. // ParentId = provinceId,
  12383. // Level = 2,
  12384. // Name_CN = citycnname,
  12385. // Name_EN = cityenname,
  12386. // IsCapital = 1,
  12387. // CreateUserId = 208,
  12388. // CreateTime = DateTime.Now,
  12389. // IsDel = 0
  12390. // };
  12391. // if (item2.c != null)
  12392. // {
  12393. // int cityId = 0;
  12394. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  12395. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12396. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  12397. // foreach (var item3 in item2.c)
  12398. // {
  12399. // if (item3.lv == "district")
  12400. // {
  12401. // var districtInfo = new Sys_Cities()
  12402. // {
  12403. // CountriesId = countriesId,
  12404. // Name_CN = item3.cn,
  12405. // Name_EN = item3.en,
  12406. // Level = 3,
  12407. // ParentId = cityId,
  12408. // IsCapital = 1,
  12409. // CreateUserId = 208,
  12410. // CreateTime = DateTime.Now,
  12411. // IsDel = 0
  12412. // };
  12413. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12414. // //{
  12415. // districts.Add(districtInfo);
  12416. // //}
  12417. // }
  12418. // }
  12419. // }
  12420. // else
  12421. // {
  12422. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  12423. // //{
  12424. // cities.Add(cityInfo);
  12425. // //}
  12426. // }
  12427. // }
  12428. // }
  12429. // }
  12430. // else if (item1.lv == "city")//城市
  12431. // {
  12432. // provinceInfo.Level = 2;
  12433. // if (item1.c != null)
  12434. // {
  12435. // int cityId = 0;
  12436. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  12437. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12438. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12439. // foreach (var item3 in item1.c)
  12440. // {
  12441. // if (item3.lv == "district")
  12442. // {
  12443. // var districtInfo = new Sys_Cities()
  12444. // {
  12445. // CountriesId = countriesId,
  12446. // Name_CN = item3.cn,
  12447. // Name_EN = item3.en,
  12448. // Level = 3,
  12449. // ParentId = cityId,
  12450. // IsCapital = 1,
  12451. // CreateUserId = 208,
  12452. // CreateTime = DateTime.Now,
  12453. // IsDel = 0
  12454. // };
  12455. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12456. // //{
  12457. // districts.Add(districtInfo);
  12458. // //}
  12459. // }
  12460. // }
  12461. // }
  12462. // else
  12463. // {
  12464. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  12465. // //{
  12466. // cities.Add(provinceInfo);
  12467. // //}
  12468. // }
  12469. // }
  12470. // }
  12471. // }
  12472. // }
  12473. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  12474. // cities = cities.Distinct().ToList();
  12475. // districts = districts.Distinct().ToList();
  12476. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  12477. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  12478. // cities.AddRange(districts);
  12479. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  12480. // //_sqlSugar.RollbackTran();
  12481. // _sqlSugar.CommitTran();
  12482. // return Ok(JsonView(false, "操作成功!"));
  12483. //}
  12484. //[HttpPost]
  12485. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  12486. //{
  12487. // List<CountitiesInfo> infos = dto.MyProperty;
  12488. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  12489. // _sqlSugar.BeginTran();
  12490. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12491. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  12492. // foreach (var item in infos)
  12493. // {
  12494. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  12495. // if (countryInfo != null)
  12496. // {
  12497. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  12498. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  12499. // if (cityInfo1 != null)
  12500. // {
  12501. // cityInfo1.IsCapital = 0;
  12502. // cityInfos.Add(cityInfo1);
  12503. // }
  12504. // }
  12505. // }
  12506. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  12507. // .UpdateColumns(it => it.IsCapital)
  12508. // .WhereColumns(it => it.Id)
  12509. // .ExecuteCommand();
  12510. // //_sqlSugar.RollbackTran();
  12511. // _sqlSugar.CommitTran();
  12512. // return Ok(JsonView(false, "操作成功!"));
  12513. //}
  12514. //public class CounrtiesDto
  12515. //{
  12516. // public List<CountitiesInfo> MyProperty { get; set; }
  12517. //}
  12518. //public class CountitiesInfo
  12519. //{
  12520. // /// <summary>
  12521. // /// 圣约翰
  12522. // /// </summary>
  12523. // public string capital_name_chinese { get; set; }
  12524. // /// <summary>
  12525. // ///
  12526. // /// </summary>
  12527. // public string capital_name { get; set; }
  12528. // /// <summary>
  12529. // ///
  12530. // /// </summary>
  12531. // public string country_type { get; set; }
  12532. // /// <summary>
  12533. // /// 安提瓜和巴布达
  12534. // /// </summary>
  12535. // public string country_name_chinese { get; set; }
  12536. // /// <summary>
  12537. // /// 安提瓜和巴布达
  12538. // /// </summary>
  12539. // public string country_name_chinese_short { get; set; }
  12540. // /// <summary>
  12541. // /// 安提瓜和巴布达
  12542. // /// </summary>
  12543. // public string country_name_chinese_UN { get; set; }
  12544. // /// <summary>
  12545. // ///
  12546. // /// </summary>
  12547. // public string country_name_english_abbreviation { get; set; }
  12548. // /// <summary>
  12549. // ///
  12550. // /// </summary>
  12551. // public string country_name_english_formal { get; set; }
  12552. // /// <summary>
  12553. // ///
  12554. // /// </summary>
  12555. // public string country_name_english_UN { get; set; }
  12556. // /// <summary>
  12557. // ///
  12558. // /// </summary>
  12559. // public string continent_name { get; set; }
  12560. // /// <summary>
  12561. // ///
  12562. // /// </summary>
  12563. // public string subregion_name { get; set; }
  12564. // /// <summary>
  12565. // ///
  12566. // /// </summary>
  12567. // public string country_code2 { get; set; }
  12568. // /// <summary>
  12569. // ///
  12570. // /// </summary>
  12571. // public string country_code3 { get; set; }
  12572. // /// <summary>
  12573. // ///
  12574. // /// </summary>
  12575. // public string phone_code { get; set; }
  12576. //}
  12577. //public class CountriesInfo : BasicInfo
  12578. //{
  12579. // public List<CitiesInfo> c { get; set; }
  12580. //}
  12581. //public class CitiesInfo : BasicInfo
  12582. //{
  12583. // public List<AreaInfo> c { get; set; }
  12584. //}
  12585. //public class AreaInfo : BasicInfo
  12586. //{
  12587. // public List<AreaInfo> c { get; set; }
  12588. //}
  12589. //public class BasicInfo
  12590. //{
  12591. // public string code { get; set; }
  12592. // public string cn { get; set; }
  12593. // public string lv { get; set; }
  12594. // public string en { get; set; }
  12595. //}
  12596. #endregion
  12597. #region 查看邀请方
  12598. /// <summary>
  12599. /// 查看邀请方
  12600. /// 邀请方信息 Init
  12601. /// </summary>
  12602. /// <param name="dto"></param>
  12603. /// <returns></returns>
  12604. [HttpPost]
  12605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12606. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  12607. {
  12608. string sqlWhere = string.Empty;
  12609. if (!string.IsNullOrEmpty(dto.Search))
  12610. {
  12611. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  12612. }
  12613. string sql = string.Format($@"Select
  12614. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  12615. Id,
  12616. UnitName
  12617. From Res_InvitationOfficialActivityData
  12618. Where IsDel = 0
  12619. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  12620. RefAsync<int> total = 0;
  12621. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12622. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  12623. }
  12624. /// <summary>
  12625. /// 查看邀请方
  12626. /// 国家信息 Init
  12627. /// </summary>
  12628. /// <param name="dto"></param>
  12629. /// <returns></returns>
  12630. [HttpPost]
  12631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12632. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  12633. {
  12634. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  12635. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12636. var diids = groupInfos.Select(it => it.Id).ToList();
  12637. List<string> countrys = new List<string>();
  12638. foreach (var item in country)
  12639. {
  12640. var data = _groupRepository.FormartTeamName(item);
  12641. var dataArray = _groupRepository.GroupSplitCountry(data);
  12642. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12643. }
  12644. countrys = countrys.Distinct().ToList();
  12645. for (int i = 0; i < countrys.Count; i++)
  12646. {
  12647. string item = countrys[i];
  12648. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  12649. {
  12650. countrys.Remove(item);
  12651. i--;
  12652. }
  12653. }
  12654. RefAsync<int> total = 0;
  12655. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  12656. .Where(it => countrys.Contains(it.Name_CN))
  12657. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12658. .Select(it => new { id = it.Id, name = it.Name_CN })
  12659. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12660. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12661. }
  12662. /// <summary>
  12663. /// 查看邀请方
  12664. /// 城市信息 Init
  12665. /// </summary>
  12666. /// <param name="dto"></param>
  12667. /// <returns></returns>
  12668. [HttpPost]
  12669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12670. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  12671. {
  12672. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  12673. RefAsync<int> total = 0;
  12674. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  12675. .Where(it => it.CountriesId == dto.CountiesId)
  12676. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12677. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  12678. .Select(it => new { id = it.Id, name = it.Name_CN })
  12679. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12680. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12681. }
  12682. /// <summary>
  12683. /// 查看邀请方
  12684. /// 团组名称 Init
  12685. /// </summary>
  12686. /// <param name="dto"></param>
  12687. /// <returns></returns>
  12688. [HttpPost]
  12689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12690. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  12691. {
  12692. var watch = new Stopwatch();
  12693. watch.Start();
  12694. RefAsync<int> total = 0;
  12695. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  12696. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  12697. .Where((oa, di) => oa.IsDel == 0)
  12698. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  12699. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  12700. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  12701. .Distinct()
  12702. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12703. watch.Stop();
  12704. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  12705. }
  12706. /// <summary>
  12707. /// 查看邀请方
  12708. /// 团组 & 邀请方信息
  12709. /// </summary>
  12710. /// <param name="dto"></param>
  12711. /// <returns></returns>
  12712. [HttpPost]
  12713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12714. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  12715. {
  12716. var watch = new Stopwatch();
  12717. watch.Start();
  12718. RefAsync<int> total = 0;
  12719. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  12720. .AS("Grp_DelegationInfo")
  12721. .Includes(x => x.InvitingInfos)
  12722. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  12723. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  12724. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  12725. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  12726. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  12727. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  12728. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12729. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  12730. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  12731. infos.ForEach(x =>
  12732. {
  12733. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  12734. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  12735. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  12736. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  12737. });
  12738. watch.Stop();
  12739. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  12740. }
  12741. #endregion
  12742. #region 报批行程
  12743. /// <summary>
  12744. /// 报批行程初始化
  12745. /// </summary>
  12746. /// <param name="dto"></param>
  12747. /// <returns></returns>
  12748. [HttpPost]
  12749. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  12750. {
  12751. const int chiNumber = 5;
  12752. var jw = JsonView(false);
  12753. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  12754. var group = groupList.First();
  12755. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  12756. group = groupList.First(x => x.Id == diid);
  12757. if (group == null)
  12758. {
  12759. jw.Msg = "暂无团组!";
  12760. return Ok(jw);
  12761. }
  12762. var data = new
  12763. {
  12764. groupList = groupList.Select(x => new
  12765. {
  12766. x.TeamName,
  12767. x.Id
  12768. }),
  12769. content = new ArrayList(),
  12770. groupInfo = new
  12771. {
  12772. group.VisitDays,
  12773. group.TourCode,
  12774. group.VisitPNumber,
  12775. group.TeamName,
  12776. group.Id,
  12777. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  12778. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  12779. },
  12780. };
  12781. var resultArr = new ArrayList();
  12782. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  12783. if (content.Count == 0)
  12784. {
  12785. var stay = "-";
  12786. var cityPath = "-";
  12787. //添加城市路径以及住宿地
  12788. //黑屏代码数据
  12789. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12790. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12791. {
  12792. jw = JsonView(true, "黑屏代码有误!", data);
  12793. return Ok(jw);
  12794. }
  12795. foreach (DataRow row in dtBlack.Rows)
  12796. {
  12797. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12798. {
  12799. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  12800. return Ok(jw);
  12801. }
  12802. }
  12803. //黑屏代码获取时间区间
  12804. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12805. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12806. _sqlSugar.BeginTran();
  12807. for (int i = 0; i < timeArr.Count; i++)
  12808. {
  12809. stay = "-";
  12810. cityPath = "-";
  12811. DateTime NewData = DateTime.Parse(timeArr[i]);
  12812. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12813. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12814. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12815. if (tbSelect.Length > 0)
  12816. {
  12817. List<string> threeCodeStr = new List<string>();
  12818. foreach (var item in tbSelect)
  12819. {
  12820. var threeCode = item["Three"].ToString() ?? "";
  12821. if (threeCode.Length == 6)
  12822. {
  12823. var start = threeCode.Substring(0, 3);
  12824. var end = threeCode.Substring(3, 3);
  12825. if (threeCodeStr.Count == 0)
  12826. {
  12827. threeCodeStr.Add(start);
  12828. threeCodeStr.Add(end);
  12829. }
  12830. else
  12831. {
  12832. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12833. {
  12834. threeCodeStr.Add(end);
  12835. }
  12836. else
  12837. {
  12838. threeCodeStr.Add(start);
  12839. threeCodeStr.Add(end);
  12840. }
  12841. }
  12842. }
  12843. }
  12844. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12845. var last = threeCodeStr.Last();
  12846. foreach (var item in threeCodeStr)
  12847. {
  12848. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12849. if (item.Equals(last))
  12850. {
  12851. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12852. }
  12853. }
  12854. cityPath = cityPath.Trim('-');
  12855. }
  12856. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12857. appro.Diid = diid ?? -1;
  12858. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12859. appro.Id = thisId;
  12860. appro.CreateUserId = dto.UserId;
  12861. appro.CreateTime = DateTime.Now;
  12862. content.Add(appro);
  12863. }
  12864. _sqlSugar.CommitTran();
  12865. }
  12866. foreach (var x in content)
  12867. {
  12868. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  12869. if (chiList.Count < chiNumber)
  12870. {
  12871. for (int i = chiList.Count; i < chiNumber; i++)
  12872. {
  12873. chiList.Add(new Grp_ApprovalTravelDetails());
  12874. }
  12875. }
  12876. resultArr.Add(new
  12877. {
  12878. x.Id,
  12879. x.Date,
  12880. x.Diid,
  12881. chiList = chiList.Select(x1 => new
  12882. {
  12883. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12884. x1.Details,
  12885. x1.ParentId,
  12886. x1.Id
  12887. })
  12888. });
  12889. }
  12890. data = data with
  12891. {
  12892. content = resultArr,
  12893. };
  12894. jw = JsonView(true, "获取成功!", data);
  12895. return Ok(jw);
  12896. }
  12897. /// <summary>
  12898. /// 报批行程删除
  12899. /// </summary>
  12900. /// <param name="dto"></param>
  12901. /// <returns></returns>
  12902. [HttpPost]
  12903. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  12904. {
  12905. var jw = JsonView(false);
  12906. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12907. if (group == null)
  12908. {
  12909. jw.Msg = "团组参数有误!";
  12910. return Ok(jw);
  12911. }
  12912. try
  12913. {
  12914. _sqlSugar.BeginTran();
  12915. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  12916. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  12917. {
  12918. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12919. DeleteUserId = dto.uesrId,
  12920. IsDel = 1
  12921. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  12922. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  12923. {
  12924. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12925. DeleteUserId = dto.uesrId,
  12926. IsDel = 1
  12927. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  12928. _sqlSugar.CommitTran();
  12929. jw = JsonView(true, "删除成功");
  12930. }
  12931. catch (Exception ex)
  12932. {
  12933. jw = JsonView(false, ex.Message);
  12934. }
  12935. return Ok(jw);
  12936. }
  12937. /// <summary>
  12938. /// 报批行程保存
  12939. /// </summary>
  12940. /// <param name="dto"></param>
  12941. /// <returns></returns>
  12942. [HttpPost]
  12943. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  12944. {
  12945. var jw = JsonView(false);
  12946. var Find = dto.Arr.Find(x => x.id == 0);
  12947. if (Find != null)
  12948. {
  12949. jw.Msg = "生成的ID为0!";
  12950. return Ok(jw);
  12951. }
  12952. foreach (var item in dto.Arr)
  12953. {
  12954. foreach (var chi in item.chiList)
  12955. {
  12956. if (chi.parentId == 0)
  12957. {
  12958. chi.parentId = item.id;
  12959. }
  12960. }
  12961. }
  12962. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  12963. _sqlSugar.BeginTran();
  12964. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  12965. {
  12966. var parentIds = dto.Arr.Select(x => x.id).ToList();
  12967. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  12968. {
  12969. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12970. DeleteUserId = dto.UserId,
  12971. IsDel = 1
  12972. }).ExecuteCommand();
  12973. }
  12974. try
  12975. {
  12976. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  12977. {
  12978. CreateTime = DateTime.Now,
  12979. CreateUserId = dto.UserId,
  12980. Details = x.details,
  12981. ParentId = x.parentId,
  12982. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12983. Remark = "",
  12984. IsDel = 0
  12985. }).ToList()).ExecuteCommand();
  12986. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  12987. {
  12988. Id = x.id,
  12989. Details = x.details,
  12990. ParentId = x.parentId,
  12991. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12992. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  12993. {
  12994. Details = x.Details,
  12995. ParentId = x.ParentId,
  12996. Time = x.Time
  12997. }).ExecuteCommand();
  12998. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  12999. {
  13000. Id = x.id,
  13001. Date = x.date,
  13002. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  13003. {
  13004. Date = x.Date
  13005. }).ExecuteCommand();
  13006. _sqlSugar.CommitTran();
  13007. jw = JsonView(true, "保存成功!");
  13008. }
  13009. catch (Exception ex)
  13010. {
  13011. _sqlSugar.RollbackTran();
  13012. jw = JsonView(false, "保存失败!" + ex.Message);
  13013. }
  13014. return Ok(jw);
  13015. }
  13016. /// <summary>
  13017. /// 报批行程生成
  13018. /// </summary>
  13019. /// <param name="dto"></param>
  13020. /// <returns></returns>
  13021. [HttpPost]
  13022. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  13023. {
  13024. var jw = JsonView(false);
  13025. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13026. if (group == null)
  13027. {
  13028. jw.Msg = "暂无该团组!";
  13029. return Ok(jw);
  13030. }
  13031. //黑屏代码数据
  13032. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  13033. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  13034. {
  13035. jw.Msg = "黑屏代码有误!";
  13036. return Ok(jw);
  13037. }
  13038. foreach (DataRow row in dtBlack.Rows)
  13039. {
  13040. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13041. {
  13042. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  13043. return Ok(jw);
  13044. }
  13045. }
  13046. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13047. var resultArr = new ArrayList();
  13048. if (officialActivitiesArr.Count == 0)
  13049. {
  13050. jw.Msg = "暂无公务出访信息!";
  13051. return Ok(jw);
  13052. }
  13053. try
  13054. {
  13055. _sqlSugar.BeginTran();
  13056. DeleteApprovalJourney(new
  13057. Domain.Dtos.Groups.DeleteApprovalJourney
  13058. {
  13059. Diid = dto.Diid,
  13060. uesrId = dto.Userid
  13061. });
  13062. var stay = "-";
  13063. var cityPath = "-";
  13064. //添加城市路径以及住宿地
  13065. //黑屏代码获取时间区间
  13066. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  13067. var empty = "【未收入该三字码!请机票同事录入】";
  13068. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  13069. for (int i = 0; i < timeArr.Count; i++)
  13070. {
  13071. stay = "-";
  13072. cityPath = "-";
  13073. var chiarr = new List<Grp_ApprovalTravelDetails>();
  13074. DateTime NewData = DateTime.Parse(timeArr[i]);
  13075. 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();
  13076. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  13077. if (tbSelect.Length > 0)
  13078. {
  13079. List<string> threeCodeStr = new List<string>();
  13080. bool isTrade = false;
  13081. string trip = string.Empty;
  13082. var rowLast = tbSelect.Last();
  13083. var rowFirst = tbSelect.First();
  13084. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  13085. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  13086. var takeOffTime = DateTime.Parse(timeArr[i]);
  13087. var fallToTime = DateTime.Parse(timeArr[i]);
  13088. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  13089. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  13090. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  13091. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  13092. foreach (var item in tbSelect)
  13093. {
  13094. var start = string.Empty;
  13095. var end = string.Empty;
  13096. var threeCode = item["Three"].ToString() ?? "";
  13097. if (threeCode.Length == 6)
  13098. {
  13099. start = threeCode.Substring(0, 3);
  13100. end = threeCode.Substring(3, 3);
  13101. if (threeCodeStr.Count == 0)
  13102. {
  13103. threeCodeStr.Add(start);
  13104. threeCodeStr.Add(end);
  13105. }
  13106. else
  13107. {
  13108. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  13109. {
  13110. threeCodeStr.Add(end);
  13111. }
  13112. else
  13113. {
  13114. threeCodeStr.Add(start);
  13115. threeCodeStr.Add(end);
  13116. }
  13117. }
  13118. }
  13119. //处理机票信息
  13120. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  13121. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  13122. if (start_Object == null)
  13123. {
  13124. start_Object = new Res_ThreeCode()
  13125. {
  13126. AirPort = empty,
  13127. AirPort_En = empty,
  13128. City = empty,
  13129. Country = empty,
  13130. Four = empty,
  13131. Three = empty,
  13132. };
  13133. }
  13134. if (end_Object == null)
  13135. {
  13136. end_Object = new Res_ThreeCode()
  13137. {
  13138. AirPort = empty,
  13139. AirPort_En = empty,
  13140. City = empty,
  13141. Country = empty,
  13142. Four = empty,
  13143. Three = empty,
  13144. };
  13145. }
  13146. //机型判断
  13147. string airModel = item["AirModel"].ToString();
  13148. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  13149. string flightTime = item["FlightTime"].ToString();
  13150. if (flightTime!.Contains(":"))
  13151. {
  13152. flightTime = flightTime.Replace(":", "小时");
  13153. flightTime += "分钟";
  13154. }
  13155. if (flightTime.Contains("H"))
  13156. {
  13157. flightTime = flightTime.Replace("H", "小时");
  13158. }
  13159. if (flightTime.Contains("M"))
  13160. {
  13161. flightTime = flightTime.Replace("M", "分钟");
  13162. }
  13163. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  13164. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  13165. {
  13166. flightTime = flightDataTime.Hour > 0
  13167. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  13168. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  13169. ? flightDataTime.Minute.ToString() + "分钟" : "";
  13170. }
  13171. //航班号
  13172. string flightcode = item["Fliagtcode"].ToString();
  13173. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  13174. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  13175. if (aircompany == null)
  13176. {
  13177. aircompany = new Res_AirCompany
  13178. {
  13179. CnName = hsEmpty,
  13180. EnName = hsEmpty,
  13181. ShortCode = hsEmpty,
  13182. };
  13183. }
  13184. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  13185. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  13186. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  13187. if (isTrade)
  13188. {
  13189. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  13190. }
  13191. else
  13192. {
  13193. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  13194. }
  13195. }
  13196. chiarr.Add(new Grp_ApprovalTravelDetails
  13197. {
  13198. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  13199. CreateTime = DateTime.Now,
  13200. CreateUserId = dto.Userid,
  13201. ParentId = 0,
  13202. Details = trip
  13203. });
  13204. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  13205. var last = threeCodeStr.Last();
  13206. foreach (var item in threeCodeStr)
  13207. {
  13208. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  13209. if (item.Equals(last))
  13210. {
  13211. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  13212. }
  13213. }
  13214. cityPath = cityPath.Trim('-');
  13215. }
  13216. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  13217. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  13218. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  13219. appro.Diid = dto.Diid;
  13220. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  13221. appro.Id = thisId;
  13222. appro.CreateUserId = dto.Userid;
  13223. appro.CreateTime = DateTime.Now;
  13224. foreach (var item in gwinfo)
  13225. {
  13226. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  13227. chi.Details = "拜访" + item.Client;
  13228. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  13229. {
  13230. chi.Details += "," + item.ReqSample;
  13231. }
  13232. chi.ParentId = thisId;
  13233. chi.Time = item.Time;
  13234. chiarr.Add(chi);
  13235. }
  13236. if (chiarr.Count < 5)
  13237. {
  13238. for (int j = chiarr.Count; j < 5; j++)
  13239. {
  13240. chiarr.Add(new
  13241. Grp_ApprovalTravelDetails());
  13242. }
  13243. }
  13244. resultArr.Add(new
  13245. {
  13246. appro.Id,
  13247. appro.Date,
  13248. appro.Diid,
  13249. chiList = chiarr.Select(x1 => new
  13250. {
  13251. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  13252. x1.Details,
  13253. x1.ParentId,
  13254. x1.Id
  13255. })
  13256. });
  13257. }
  13258. _sqlSugar.CommitTran();
  13259. jw = JsonView(true, "生成成功!", resultArr);
  13260. }
  13261. catch (Exception ex)
  13262. {
  13263. jw.Code = 400;
  13264. jw.Msg = "生成失败!" + ex.Message;
  13265. }
  13266. return Ok(jw);
  13267. }
  13268. /// <summary>
  13269. /// 报批行程word导出
  13270. /// </summary>
  13271. /// <param name="dto"></param>
  13272. /// <returns></returns>
  13273. [HttpPost]
  13274. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  13275. {
  13276. var jw = JsonView(false);
  13277. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13278. if (group == null)
  13279. {
  13280. jw.Msg = "暂无该团组!";
  13281. return Ok(jw);
  13282. }
  13283. //模板路径
  13284. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  13285. //载入模板
  13286. Document doc = new Document(tempPath);
  13287. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13288. //获取所填表格的序数
  13289. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13290. Aspose.Words.Tables.Row titleRowClone = null;
  13291. Aspose.Words.Tables.Row CenterRowClone = null;
  13292. int index = 0;
  13293. int indexChi = 0;
  13294. int SetIndex = 0;
  13295. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  13296. //获取数据,放到datatable
  13297. foreach (var item in ApprovalTravelArr)
  13298. {
  13299. if (index > 0)
  13300. {
  13301. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  13302. tableOne.AppendChild(titleRowClone);
  13303. }
  13304. var textTime = item.Date;
  13305. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  13306. SetCells(tableOne, doc, SetIndex, 0, textTime);
  13307. SetIndex++;
  13308. if (ChiRep.Count > 0)
  13309. {
  13310. foreach (var itemChi in ChiRep)
  13311. {
  13312. var txtTime = itemChi.Time;
  13313. var txtDetail = itemChi.Details;
  13314. if (indexChi > 0)
  13315. {
  13316. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13317. tableOne.AppendChild(CenterRowClone);
  13318. }
  13319. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  13320. {
  13321. SetCells(tableOne, doc, SetIndex, 0, "");
  13322. SetCells(tableOne, doc, SetIndex, 1, "");
  13323. indexChi++;
  13324. SetIndex++;
  13325. break;
  13326. }
  13327. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  13328. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  13329. indexChi++;
  13330. SetIndex++;
  13331. }
  13332. }
  13333. else
  13334. {
  13335. if (indexChi > 0)
  13336. {
  13337. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13338. tableOne.AppendChild(CenterRowClone);
  13339. }
  13340. SetCells(tableOne, doc, SetIndex, 0, "");
  13341. SetCells(tableOne, doc, SetIndex, 1, "");
  13342. indexChi++;
  13343. SetIndex++;
  13344. }
  13345. index++;
  13346. }
  13347. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  13348. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13349. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13350. jw.Code = 200;
  13351. jw.Msg = "";
  13352. return Ok(jw);
  13353. }
  13354. private string intToString(int numberVal)
  13355. {
  13356. string numberval = numberVal.ToString();
  13357. Dictionary<char, string> Number = new Dictionary<char, string>();
  13358. Number.Add('1', "一");
  13359. Number.Add('2', "二");
  13360. Number.Add('3', "三");
  13361. Number.Add('4', "四");
  13362. Number.Add('5', "五");
  13363. Number.Add('6', "六");
  13364. Number.Add('7', "七");
  13365. Number.Add('8', "八");
  13366. Number.Add('9', "九");
  13367. string stringNumberVal = string.Empty;
  13368. for (int i = 0; i < numberval.Length; i++)
  13369. {
  13370. if (i == 0)
  13371. {
  13372. stringNumberVal += Number[numberval[i]];
  13373. }
  13374. else if (i >= 1)
  13375. {
  13376. if (numberval[i] == '0')
  13377. {
  13378. stringNumberVal = "十";
  13379. }
  13380. else
  13381. {
  13382. stringNumberVal += "十" + Number[numberval[i]];
  13383. }
  13384. }
  13385. }
  13386. return stringNumberVal;
  13387. }
  13388. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  13389. {
  13390. //获取table中的某个单元格,从0开始
  13391. Cell lshCell = table.Rows[rows].Cells[cells];
  13392. //将单元格中段落移除
  13393. foreach (Node item in lshCell.Paragraphs)
  13394. {
  13395. lshCell.Paragraphs.Remove(item);
  13396. }
  13397. if (val.Contains("\r\n"))
  13398. {
  13399. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  13400. foreach (var item in spArr)
  13401. {
  13402. //新建一个段落
  13403. Paragraph p = new Paragraph(doc);
  13404. var r = new Run(doc, item);
  13405. //把设置的值赋给之前新建的段落
  13406. p.AppendChild(r);
  13407. //将此段落加到单元格内
  13408. lshCell.AppendChild(p);
  13409. }
  13410. }
  13411. else
  13412. {
  13413. //新建一个段落
  13414. Paragraph p = new Paragraph(doc);
  13415. var r = new Run(doc, val);
  13416. //把设置的值赋给之前新建的段落
  13417. p.AppendChild(r);
  13418. //将此段落加到单元格内
  13419. lshCell.AppendChild(p);
  13420. }
  13421. }
  13422. [HttpPost]
  13423. public async Task<IActionResult> ServerHttp(string paramStr)
  13424. {
  13425. paramStr = paramStr.TrimEnd('\'');
  13426. paramStr = paramStr.TrimStart('\'');
  13427. JsonView jw = JsonView(false);
  13428. JObject param = JObject.Parse(paramStr);
  13429. if (!param.ContainsKey("url"))
  13430. {
  13431. jw.Msg = "url null";
  13432. return Ok(jw);
  13433. }
  13434. string url = param["url"]!.ToString();
  13435. var methon = "get";
  13436. Dictionary<string, string> headValues = null;
  13437. string bodyStr = string.Empty;
  13438. if (param.ContainsKey("methon"))
  13439. {
  13440. methon = param["methon"]!.ToString().ToLower();
  13441. }
  13442. if (param.ContainsKey("header"))
  13443. {
  13444. var header = param["header"]!.ToString();
  13445. JObject headerJobject = JObject.Parse(header);
  13446. headValues = new Dictionary<string, string>();
  13447. foreach (JProperty item in headerJobject.Properties())
  13448. {
  13449. var value = item.Value.ToString();
  13450. var head = item.Path;
  13451. headValues.Add(head, value);
  13452. }
  13453. }
  13454. HttpClient client = new HttpClient();
  13455. string responseString = string.Empty;
  13456. StringContent content = null;
  13457. if (headValues != null)
  13458. {
  13459. foreach (var item in headValues.Keys)
  13460. {
  13461. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  13462. {
  13463. if (param.ContainsKey("body"))
  13464. {
  13465. bodyStr = param["body"]!.ToString();
  13466. }
  13467. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  13468. }
  13469. else
  13470. {
  13471. client.DefaultRequestHeaders.Add(item, headValues[item]);
  13472. }
  13473. }
  13474. }
  13475. try
  13476. {
  13477. if (methon == "get")
  13478. {
  13479. responseString = await client.GetStringAsync(url);
  13480. }
  13481. else if (methon == "post")
  13482. {
  13483. var request = new HttpRequestMessage(HttpMethod.Post, url)
  13484. {
  13485. Content = content
  13486. };
  13487. var response = await client.SendAsync(request);
  13488. try
  13489. {
  13490. Stream responseStream = await response.Content.ReadAsStreamAsync();
  13491. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  13492. {
  13493. using (StreamReader reader = new StreamReader(gzipStream))
  13494. {
  13495. responseString = await reader.ReadToEndAsync();
  13496. }
  13497. }
  13498. }
  13499. catch (Exception)
  13500. {
  13501. responseString = await response.Content.ReadAsStringAsync();
  13502. }
  13503. }
  13504. else
  13505. {
  13506. responseString = "methon error";
  13507. }
  13508. jw = JsonView(true, "success", responseString);
  13509. }
  13510. catch (Exception ex)
  13511. {
  13512. jw.Msg = "error " + ex.Message;
  13513. jw.Data = ex.StackTrace;
  13514. }
  13515. finally
  13516. {
  13517. client.Dispose();
  13518. }
  13519. return Ok(jw);
  13520. }
  13521. #endregion
  13522. #region 团组接待意见调查 Grp_ReceptionOpinionSurvey
  13523. /// <summary>
  13524. /// 团组接待意见调查 - 信息管理
  13525. /// 基础数据(团组)
  13526. /// </summary>
  13527. /// <param name="dto"></param>
  13528. /// <returns></returns>
  13529. [HttpGet]
  13530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13531. public async Task<IActionResult> OpinionaireInit()
  13532. {
  13533. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  13534. .Select(x => new
  13535. {
  13536. x.Id,
  13537. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  13538. })
  13539. .OrderByDescending(x => x.Id)
  13540. .ToListAsync();
  13541. return Ok(JsonView(groupData, groupData.Count));
  13542. }
  13543. /// <summary>
  13544. /// 团组接待意见调查 - 信息管理
  13545. /// 列表
  13546. /// </summary>
  13547. /// <param name="groupId"></param>
  13548. /// <returns></returns>
  13549. [HttpGet("{groupId}")]
  13550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13551. public async Task<IActionResult> OpinionaireManageList(int groupId)
  13552. {
  13553. if (groupId < 1) Ok(JsonView(false,"请传入有效的diId"));
  13554. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  13555. .Select(x => new
  13556. {
  13557. x.Id,
  13558. x.TourGuideName,
  13559. x.CityName,
  13560. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  13561. x.CreateTime
  13562. })
  13563. .OrderBy(x => x.Id)
  13564. .ToListAsync();
  13565. return Ok(JsonView(data));
  13566. }
  13567. /// <summary>
  13568. /// 团组接待意见调查 - 信息管理
  13569. /// 保存
  13570. /// </summary>
  13571. /// <param name="dto"></param>
  13572. /// <returns></returns>
  13573. [HttpPost]
  13574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13575. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  13576. {
  13577. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  13578. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  13579. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  13580. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  13581. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  13582. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  13583. _opinionaireRep.BeginTran();
  13584. if (addData != null && addData.Count > 0)
  13585. {
  13586. foreach (var item in addData)
  13587. {
  13588. item.CreateUserId = currUserInfo.UserId;
  13589. item.DiId = dto.DiId;
  13590. }
  13591. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  13592. }
  13593. if (updData != null && updData.Count > 0)
  13594. {
  13595. var upd = await _opinionaireRep._sqlSugar
  13596. .Updateable(updData)
  13597. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  13598. .WhereColumns(x =>new{ x.Id})
  13599. .ExecuteCommandAsync();
  13600. }
  13601. _opinionaireRep.CommitTran();
  13602. return Ok(JsonView("操作成功!"));
  13603. }
  13604. /// <summary>
  13605. /// 团组接待意见调查 - 信息管理
  13606. /// 删除
  13607. /// </summary>
  13608. /// <param name="id"></param>
  13609. /// <returns></returns>
  13610. [HttpDelete("{id}")]
  13611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13612. public async Task<IActionResult> OpinionaireManageDel(int id)
  13613. {
  13614. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  13615. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  13616. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  13617. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  13618. if (!del) return Ok(JsonView("操作失败!"));
  13619. return Ok(JsonView("操作成功!"));
  13620. }
  13621. /// <summary>
  13622. /// 团组接待意见调查 - 用户
  13623. /// 列表
  13624. /// </summary>
  13625. /// <param name="id"></param>
  13626. /// <returns></returns>
  13627. [HttpGet("{diId}")]
  13628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13629. public async Task<IActionResult> OpinionaireUserList(int diId)
  13630. {
  13631. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  13632. var sql = string.Format(@"
  13633. SELECT
  13634. o.Id,
  13635. o.DiId,
  13636. di.TeamName AS 'GroupName',
  13637. di.VisitPNumber AS 'PeopleNumber',
  13638. di.ClientName AS 'LeadGroup',
  13639. di.VisitCountry AS 'Travel',
  13640. di.VisitDays AS 'Days',
  13641. o.CityName,
  13642. o.TourGuideName,
  13643. o.Catering,
  13644. o.CateringReason,
  13645. o.Stay,
  13646. o.StayReason,
  13647. o.[Route],
  13648. o.RouteReason,
  13649. o.OfficialActivity,
  13650. o.OfficialActivityReason,
  13651. o.TourGuide,
  13652. o.TourGuideReason,
  13653. o.[Translate],
  13654. o.TranslateReason,
  13655. o.Trip,
  13656. o.TripReason,
  13657. o.ESFileName,
  13658. o.SignatureDate,
  13659. o.Remark
  13660. FROM
  13661. Grp_Opinionaire o
  13662. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  13663. WHERE
  13664. o.IsDel = 0
  13665. AND o.DiId = {0}
  13666. ORDER BY
  13667. o.Id ASC", diId);
  13668. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  13669. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  13670. return Ok(JsonView(data));
  13671. }
  13672. /// <summary>
  13673. /// 团组接待意见调查 - 用户
  13674. /// 保存
  13675. /// </summary>
  13676. /// <param name="id"></param>
  13677. /// <returns></returns>
  13678. [HttpPost]
  13679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13680. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  13681. {
  13682. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  13683. foreach (var item in dto)
  13684. {
  13685. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  13686. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  13687. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  13688. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  13689. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  13690. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  13691. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  13692. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  13693. }
  13694. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  13695. if (!Directory.Exists(filePathBase))
  13696. {
  13697. Directory.CreateDirectory(filePathBase);
  13698. }
  13699. #region 上传文件
  13700. var filePaths = new List<string>();
  13701. foreach (var item in dto)
  13702. {
  13703. var file = item.File;
  13704. // 将文件保存到指定位置
  13705. var filePath = Path.Combine(filePathBase, file.FileName);
  13706. using (var stream = new FileStream(filePath, FileMode.Create))
  13707. {
  13708. await file.CopyToAsync(stream);
  13709. }
  13710. //验证文件是否上传成功
  13711. if (!System.IO.File.Exists(filePath))
  13712. {
  13713. foreach (var filePathStr in filePaths)
  13714. {
  13715. System.IO.File.Delete(filePathStr);
  13716. }
  13717. return Ok(JsonView(false, "文件上传失败!"));
  13718. }
  13719. item.ESFileName = file.FileName;
  13720. }
  13721. #endregion
  13722. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  13723. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  13724. .UpdateColumns(x => new
  13725. {
  13726. x.Catering,
  13727. x.CateringReason,
  13728. x.Stay,
  13729. x.StayReason,
  13730. x.Route,
  13731. x.RouteReason,
  13732. x.OfficialActivity,
  13733. x.OfficialActivityReason,
  13734. x.TourGuide,
  13735. x.TourGuideReason,
  13736. x.Translate,
  13737. x.TranslateReason,
  13738. x.Trip,
  13739. x.TripReason,
  13740. x.ESFileName,
  13741. x.SignatureDate,
  13742. x.Remark
  13743. })
  13744. .WhereColumns(x => new { x.Id })
  13745. .ExecuteCommandAsync();
  13746. if (upd < 1)
  13747. {
  13748. foreach (var filePathStr in filePaths)
  13749. {
  13750. System.IO.File.Delete(filePathStr);
  13751. }
  13752. return Ok(JsonView(false));
  13753. }
  13754. return Ok(JsonView(true));
  13755. }
  13756. #endregion
  13757. // /// <summary>
  13758. // ///
  13759. // /// </summary>
  13760. // /// <param name="_dto"></param>
  13761. // /// <returns></returns>
  13762. // [HttpPost]
  13763. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13764. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  13765. // {
  13766. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  13767. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  13768. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  13769. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  13770. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  13771. // dic_psg.Add("客人", 974);
  13772. // dic_psg.Add("司机", 975);
  13773. // dic_psg.Add("导游", 976);
  13774. // dic_psg.Add("公司内部人员", 977);
  13775. // dic_psg.Add("司机/导游/公司内部人员", 978);
  13776. // foreach (var item in list_visa)
  13777. // {
  13778. // Grp_VisaInfo temp = new Grp_VisaInfo();
  13779. // temp.Id = item.Id;
  13780. // temp.DIId = item.DIId;
  13781. // temp.VisaClient = item.VisaClient;
  13782. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  13783. // temp.VisaCurrency = item.VisaCurrency;
  13784. // temp.IsThird = item.IsThird;
  13785. // if (dic_psg.ContainsKey(item.PassengerType))
  13786. // {
  13787. // temp.PassengerType = dic_psg[item.PassengerType];
  13788. // }
  13789. // else {
  13790. // temp.PassengerType = -1;
  13791. // }
  13792. // temp.VisaNumber = item.VisaNumber;
  13793. // temp.VisaFreeNumber = item.VisaFreeNumber;
  13794. // temp.CreateUserId = item.Operators;
  13795. // DateTime dt_ct;
  13796. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  13797. // if (b_ct)
  13798. // {
  13799. // temp.CreateTime = dt_ct;
  13800. // }
  13801. // else
  13802. // {
  13803. // temp.CreateTime = DateTime.Now;
  13804. // }
  13805. // temp.DeleteTime = "";
  13806. // temp.DeleteUserId = 0;
  13807. // temp.Remark = item.Remark;
  13808. // if (string.IsNullOrEmpty(temp.Remark)) {
  13809. // temp.Remark = "";
  13810. // }
  13811. // temp.IsDel = item.IsDel;
  13812. // temp.VisaDescription = item.VisaAttachment;
  13813. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  13814. //([Id]
  13815. // ,[DIId]
  13816. // ,[VisaClient]
  13817. // ,[VisaPrice]
  13818. // ,[VisaCurrency]
  13819. // ,[IsThird]
  13820. // ,[PassengerType]
  13821. // ,[VisaNumber]
  13822. // ,[VisaFreeNumber]
  13823. // ,[CreateUserId]
  13824. // ,[CreateTime]
  13825. // ,[DeleteTime]
  13826. // ,[DeleteUserId]
  13827. // ,[Remark]
  13828. // ,[IsDel]
  13829. // ,[visaDescription])
  13830. // VALUES
  13831. // ({0},{1},'{2}',{3},{4}
  13832. //,{5},{6},{7},{8},{9}
  13833. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  13834. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  13835. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  13836. //);
  13837. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  13838. // }
  13839. // return Ok(JsonView(true, "操作成功!"));
  13840. // }
  13841. /// <summary>
  13842. /// 123132123
  13843. /// </summary>
  13844. /// <param name="_dto"></param>
  13845. /// <returns></returns>
  13846. [HttpPost]
  13847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13848. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  13849. {
  13850. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  13851. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  13852. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  13853. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  13854. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  13855. dicDetail.Add(789, 1034);
  13856. dicDetail.Add(790, 1035);
  13857. dicDetail.Add(791, 1036);
  13858. dicDetail.Add(792, 1037);
  13859. dicDetail.Add(793, 1038);
  13860. dicDetail.Add(794, 1039);
  13861. dicDetail.Add(795, 1040);
  13862. dicDetail.Add(796, 1041);
  13863. dicDetail.Add(797, 1042);
  13864. dicDetail.Add(798, 1043);
  13865. dicDetail.Add(801, 1044);
  13866. dicDetail.Add(802, 1045);
  13867. dicDetail.Add(803, 1046);
  13868. Dictionary<int, int> dic = new Dictionary<int, int>();
  13869. dic.Add(806, 1027);
  13870. dic.Add(807, 1028);
  13871. dic.Add(808, 1029);
  13872. dic.Add(809, 1030);
  13873. dic.Add(810, 1031);
  13874. dic.Add(811, 1032);
  13875. dic.Add(812, 1033);
  13876. foreach (var item in list_visa)
  13877. {
  13878. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  13879. temp.Coefficient = item.coefficient;
  13880. DateTime dtCrt;
  13881. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  13882. if (b1)
  13883. {
  13884. temp.CreateTime = dtCrt;
  13885. }
  13886. else
  13887. {
  13888. temp.CreateTime = DateTime.Now;
  13889. }
  13890. temp.CreateUserId = item.Operators;
  13891. temp.DeleteTime = "";
  13892. temp.DeleteUserId = 0;
  13893. temp.DiId = int.Parse(item.DIID);
  13894. temp.FilePath = item.FilePath;
  13895. temp.IsDel = item.IsDel;
  13896. temp.Price = item.Price;
  13897. temp.PriceCount = 1;
  13898. temp.PriceCurrency = item.Currency;
  13899. int detailId = 0;
  13900. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  13901. {
  13902. detailId = dicDetail[item.PriceTypeDetail];
  13903. }
  13904. temp.PriceDetailType = detailId;
  13905. temp.PriceDt = DateTime.Now;
  13906. temp.PriceName = item.PriceName;
  13907. temp.PriceSum = item.Price;
  13908. int tid = 0;
  13909. if (dic.ContainsKey(item.PriceType))
  13910. {
  13911. tid = dic[item.PriceType];
  13912. }
  13913. temp.PriceType = tid;
  13914. temp.Remark = item.Remark;
  13915. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  13916. }
  13917. return Ok(JsonView(true, "操作成功!"));
  13918. }
  13919. }
  13920. }