GroupsController.cs 761 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371
  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 System.Security.Cryptography;
  46. using Ubiety.Dns.Core;
  47. using static NPOI.POIFS.Crypt.CryptoFunctions;
  48. using static OASystem.API.OAMethodLib.JWTHelper;
  49. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  50. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  51. using Bookmark = Aspose.Words.Bookmark;
  52. using Cell = Aspose.Words.Tables.Cell;
  53. using Table = Aspose.Words.Tables.Table;
  54. namespace OASystem.API.Controllers
  55. {
  56. /// <summary>
  57. /// 团组相关
  58. /// </summary>
  59. //[Authorize]
  60. [Route("api/[controller]/[action]")]
  61. public class GroupsController : ControllerBase
  62. {
  63. private readonly ILogger<GroupsController> _logger;
  64. private readonly GrpScheduleRepository _grpScheduleRep;
  65. private readonly IMapper _mapper;
  66. private readonly DelegationInfoRepository _groupRepository;
  67. private readonly TaskAssignmentRepository _taskAssignmentRep;
  68. private readonly AirTicketResRepository _airTicketResRep;
  69. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  70. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  71. private readonly DelegationEnDataRepository _delegationEnDataRep;
  72. private readonly DelegationVisaRepository _delegationVisaRep;
  73. private readonly VisaPriceRepository _visaPriceRep;
  74. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  75. private readonly HotelPriceRepository _hotelPriceRep;
  76. private readonly CustomersRepository _customersRep;
  77. private readonly MessageRepository _message;
  78. private readonly SqlSugarClient _sqlSugar;
  79. private readonly TourClientListRepository _tourClientListRep;
  80. private readonly TeamRateRepository _teamRateRep;
  81. #region 成本相关
  82. private readonly CheckBoxsRepository _checkBoxs;
  83. private readonly GroupCostRepository _GroupCostRepository;
  84. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  85. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  86. #endregion
  87. private readonly SetDataRepository _setDataRep;
  88. private string url;
  89. private string path;
  90. private readonly EnterExitCostRepository _enterExitCostRep;
  91. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  92. private readonly UsersRepository _usersRep;
  93. private readonly IJuHeApiService _juHeApi;
  94. private readonly InvertedListRepository _invertedListRep;
  95. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  96. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  97. private readonly ThreeCodeRepository _threeCodeRepository;
  98. private readonly HotelInquiryRepository _hotelInquiryRep;
  99. private readonly FeeAuditRepository _feeAuditRep;
  100. private readonly VisaCommissionRepository _visaCommissionRep;
  101. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  102. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  103. public GroupsController(
  104. ILogger<GroupsController> logger,
  105. IMapper mapper,
  106. IHubContext<ChatHub, IChatClient> hubContext,
  107. SqlSugarClient sqlSugar,
  108. GrpScheduleRepository grpScheduleRep,
  109. DelegationInfoRepository groupRepository,
  110. TaskAssignmentRepository taskAssignmentRep,
  111. AirTicketResRepository airTicketResRep,
  112. DecreasePaymentsRepository decreasePaymentsRep,
  113. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  114. DelegationEnDataRepository delegationEnDataRep,
  115. EnterExitCostRepository enterExitCostRep,
  116. DelegationVisaRepository delegationVisaRep,
  117. MessageRepository message,
  118. VisaPriceRepository visaPriceRep,
  119. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  120. CheckBoxsRepository checkBoxs,
  121. GroupCostRepository GroupCostRepository,
  122. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  123. GroupCostParameterRepository GroupCostParameterRepository,
  124. HotelPriceRepository hotelPriceRep,
  125. CustomersRepository customersRep,
  126. SetDataRepository setDataRep,
  127. TourClientListRepository tourClientListRep,
  128. TeamRateRepository teamRateRep,
  129. UsersRepository usersRep, IJuHeApiService juHeApi,
  130. InvertedListRepository invertedListRep,
  131. VisaFeeInfoRepository visaFeeInfoRep,
  132. TicketBlackCodeRepository ticketBlackCodeRep,
  133. HotelInquiryRepository hotelInquiryRep,
  134. ThreeCodeRepository threeCodeRepository,
  135. FeeAuditRepository feeAuditRep,
  136. VisaCommissionRepository visaCommissionRep,
  137. ForeignReceivablesRepository ffrRep,
  138. OpinionaireRepository opinionaireRep
  139. )
  140. {
  141. _logger = logger;
  142. _mapper = mapper;
  143. _grpScheduleRep = grpScheduleRep;
  144. _groupRepository = groupRepository;
  145. _taskAssignmentRep = taskAssignmentRep;
  146. _airTicketResRep = airTicketResRep;
  147. _sqlSugar = sqlSugar;
  148. url = AppSettingsHelper.Get("ExcelBaseUrl");
  149. path = AppSettingsHelper.Get("ExcelBasePath");
  150. if (!System.IO.Directory.Exists(path))
  151. {
  152. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  153. }
  154. _decreasePaymentsRep = decreasePaymentsRep;
  155. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  156. _delegationEnDataRep = delegationEnDataRep;
  157. _enterExitCostRep = enterExitCostRep;
  158. _delegationVisaRep = delegationVisaRep;
  159. _message = message;
  160. _visaPriceRep = visaPriceRep;
  161. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  162. _checkBoxs = checkBoxs;
  163. _GroupCostRepository = GroupCostRepository;
  164. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  165. _GroupCostParameterRepository = GroupCostParameterRepository;
  166. _hotelPriceRep = hotelPriceRep;
  167. _customersRep = customersRep;
  168. _setDataRep = setDataRep;
  169. _tourClientListRep = tourClientListRep;
  170. _teamRateRep = teamRateRep;
  171. _hubContext = hubContext;
  172. _usersRep = usersRep;
  173. _juHeApi = juHeApi;
  174. _invertedListRep = invertedListRep;
  175. _visaFeeInfoRep = visaFeeInfoRep;
  176. _ticketBlackCodeRep = ticketBlackCodeRep;
  177. _hotelInquiryRep = hotelInquiryRep;
  178. _threeCodeRepository = threeCodeRepository;
  179. _feeAuditRep = feeAuditRep;
  180. _visaCommissionRep = visaCommissionRep;
  181. _ffrRep = ffrRep;
  182. _opinionaireRep = opinionaireRep;
  183. }
  184. #region 流程管控
  185. /// <summary>
  186. /// 获取团组流程管控信息
  187. /// </summary>
  188. /// <param name="paras">参数Json字符串</param>
  189. /// <returns></returns>
  190. [HttpPost]
  191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  192. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  193. {
  194. if (string.IsNullOrEmpty(_jsonDto.Paras))
  195. {
  196. return Ok(JsonView(false, "参数为空"));
  197. }
  198. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  199. if (_ScheduleDto != null)
  200. {
  201. if (_ScheduleDto.SearchType == 2)//获取列表
  202. {
  203. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  204. return Ok(JsonView(_grpScheduleViewList));
  205. }
  206. else//获取对象
  207. {
  208. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  209. if (_grpScheduleView != null)
  210. {
  211. return Ok(JsonView(_grpScheduleView));
  212. }
  213. }
  214. }
  215. else
  216. {
  217. return Ok(JsonView(false, "参数反序列化失败"));
  218. }
  219. return Ok(JsonView(false, "暂无数据!"));
  220. }
  221. /// <summary>
  222. /// 修改团组流程管控详细表数据
  223. /// </summary>
  224. /// <param name="paras"></param>
  225. /// <returns></returns>
  226. [HttpPost]
  227. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  228. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  229. {
  230. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  231. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  232. .SetColumns(it => it.Duty == _detail.Duty)
  233. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  234. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  235. .SetColumns(it => it.JobContent == _detail.JobContent)
  236. .SetColumns(it => it.Remark == _detail.Remark)
  237. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  238. .Where(s => s.Id == dto.Id)
  239. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  240. .ExecuteCommandAsync();
  241. if (result > 0)
  242. {
  243. return Ok(JsonView(true, "保存成功!"));
  244. }
  245. return Ok(JsonView(false, "保存失败!"));
  246. }
  247. /// <summary>
  248. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  249. /// </summary>
  250. /// <param name="dto"></param>
  251. /// <returns></returns>
  252. [HttpPost]
  253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  254. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  255. {
  256. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  257. _detail.IsDel = 1;
  258. _detail.DeleteUserId = dto.Duty;
  259. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  260. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  261. .SetColumns(it => it.IsDel == _detail.IsDel)
  262. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  263. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  264. .Where(it => it.Id == dto.Id)
  265. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  266. //.WhereColumns(s => s.Id == dto.Id)
  267. .ExecuteCommandAsync();
  268. if (result > 0)
  269. {
  270. return Ok(JsonView(true, "删除成功!"));
  271. }
  272. return Ok(JsonView(false, "删除失败!"));
  273. }
  274. /// <summary>
  275. /// 增加团组流程管控详细表数据
  276. /// </summary>
  277. /// <param name="dto"></param>
  278. /// <returns></returns>
  279. [HttpPost]
  280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  281. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  282. {
  283. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  284. if (DateTime.Now < _detail.ExpectBeginDt)
  285. {
  286. _detail.StepStatus = 0;
  287. }
  288. else
  289. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  290. _detail.StepStatus = 1;
  291. }
  292. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  293. if (result > 0)
  294. {
  295. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  296. return Ok(JsonView(true, "添加成功!", _result));
  297. }
  298. return Ok(JsonView(false, "添加失败!"));
  299. }
  300. #endregion
  301. #region 团组基本信息
  302. /// <summary>
  303. /// 接团信息列表
  304. /// </summary>
  305. /// <param name="dto">团组列表请求dto</param>
  306. /// <returns></returns>
  307. [HttpPost]
  308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  309. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  310. {
  311. var groupData = await _groupRepository.GetGroupList(dto);
  312. if (groupData.Code != 0)
  313. {
  314. return Ok(JsonView(false, groupData.Msg));
  315. }
  316. return Ok(JsonView(groupData.Data));
  317. }
  318. /// <summary>
  319. /// 分页查询团组列表
  320. /// </summary>
  321. /// <param name="dto"></param>
  322. /// <returns></returns>
  323. [HttpPost]
  324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  325. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  326. {
  327. var watch = new Stopwatch();
  328. watch.Start();
  329. RefAsync<int> total = 0;
  330. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  331. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  332. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  333. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  334. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  335. .Distinct()
  336. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  337. watch.Stop();
  338. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  339. }
  340. /// <summary>
  341. /// 接团信息列表 Page
  342. /// </summary>
  343. /// <param name="dto">团组列表请求dto</param>
  344. /// <returns></returns>
  345. [HttpPost]
  346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  347. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  348. {
  349. #region 参数验证
  350. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  351. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  352. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  353. #region 页面操作权限验证
  354. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  355. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  356. #endregion
  357. #endregion
  358. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  359. {
  360. string sqlWhere = string.Empty;
  361. if (dto.IsSure == 0) //未完成
  362. {
  363. sqlWhere += string.Format(@" And IsSure = 0");
  364. }
  365. else if (dto.IsSure == 1) //已完成
  366. {
  367. sqlWhere += string.Format(@" And IsSure = 1");
  368. }
  369. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  370. {
  371. string tj = dto.SearchCriteria;
  372. 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}%')",
  373. tj, tj, tj, tj, tj);
  374. }
  375. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  376. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  377. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  378. JietuanOperator,IsSure,CreateTime,IsBid
  379. From (
  380. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  381. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  382. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  383. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  384. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  385. From Grp_DelegationInfo gdi
  386. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  387. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  388. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  389. Where gdi.IsDel = 0 {0}
  390. ) temp", sqlWhere);
  391. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  392. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  393. #region 处理所属部门
  394. /*
  395. * 1.sq 和 gyy 等显示 市场部
  396. * 2.王鸽和主管及张总还有管理员号统一国交部
  397. * 2-1. 4 管理员 ,21 张海麟
  398. */
  399. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  400. List<int> userIds1 = new List<int>() { 4, 21 };
  401. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  402. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  403. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  404. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  405. .ToList();
  406. foreach (var item in _DelegationList)
  407. {
  408. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  409. }
  410. #endregion
  411. var _view = new
  412. {
  413. PageFuncAuth = pageFunAuthView,
  414. Data = _DelegationList
  415. };
  416. return Ok(JsonView(true, "查询成功!", _view, total));
  417. }
  418. else
  419. {
  420. return Ok(JsonView(false, "查询失败"));
  421. }
  422. }
  423. /// <summary>
  424. /// 团组列表
  425. /// </summary>
  426. /// <returns></returns>
  427. [HttpPost]
  428. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  429. {
  430. #region 参数验证
  431. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  432. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  433. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  434. #region 页面操作权限验证
  435. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  436. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  437. #endregion
  438. #endregion
  439. if (dto.PortType != 1 && dto.PortType != 2)
  440. {
  441. return Ok(JsonView(false, "查询失败!"));
  442. }
  443. string orderbyStr = "order by gdi.CreateTime Desc";
  444. string sqlWhere = string.Empty;
  445. if (dto.IsSure == 0) //未完成
  446. {
  447. sqlWhere += string.Format(@" And IsSure = 0");
  448. }
  449. else if (dto.IsSure == 1) //已完成
  450. {
  451. sqlWhere += string.Format(@" And IsSure = 1");
  452. }
  453. //团组类型
  454. if (dto.TeamDid > 0)
  455. {
  456. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  457. }
  458. //团组名称
  459. if (!string.IsNullOrEmpty(dto.TeamName))
  460. {
  461. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  462. }
  463. //客户名称
  464. if (!string.IsNullOrEmpty(dto.ClientName))
  465. {
  466. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  467. }
  468. //客户单位
  469. if (!string.IsNullOrEmpty(dto.ClientUnit))
  470. {
  471. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  472. }
  473. //出访时间
  474. if (!string.IsNullOrEmpty(dto.visitDataTime))
  475. {
  476. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  477. orderbyStr = "order by gdi.VisitDate";
  478. }
  479. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  480. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  481. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  482. JietuanOperator,IsSure,CreateTime
  483. From (
  484. Select row_number() over({0}) as Row_Number,
  485. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  486. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  487. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  488. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  489. From Grp_DelegationInfo gdi
  490. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  491. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  492. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  493. Where gdi.IsDel = 0 {1}
  494. ) temp ", orderbyStr, sqlWhere);
  495. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  496. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  497. #region 处理所属部门
  498. /*
  499. * 1.sq 和 gyy 等显示 市场部
  500. * 2.王鸽和主管及张总还有管理员号统一国交部
  501. * 2-1. 4 管理员 ,21 张海麟
  502. */
  503. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  504. List<int> userIds1 = new List<int>() { 4, 21 };
  505. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  506. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  507. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  508. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  509. .ToList();
  510. foreach (var item in _DelegationList)
  511. {
  512. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  513. }
  514. #endregion
  515. var _view = new
  516. {
  517. PageFuncAuth = pageFunAuthView,
  518. Data = _DelegationList
  519. };
  520. return Ok(JsonView(true, "查询成功!", _view, total));
  521. }
  522. /// <summary>
  523. /// 接团信息详情
  524. /// </summary>
  525. /// <param name="dto">团组info请求dto</param>
  526. /// <returns></returns>
  527. [HttpPost]
  528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  529. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  530. {
  531. var groupData = await _groupRepository.GetGroupInfo(dto);
  532. if (groupData.Code != 0)
  533. {
  534. return Ok(JsonView(false, groupData.Msg));
  535. }
  536. return Ok(JsonView(groupData.Data));
  537. }
  538. /// <summary>
  539. /// 接团信息 编辑添加
  540. /// 基础信息数据源
  541. /// </summary>
  542. /// <param name="dto"></param>
  543. /// <returns></returns>
  544. [HttpPost]
  545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  546. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  547. {
  548. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  549. if (groupData.Code != 0)
  550. {
  551. return Ok(JsonView(false, groupData.Msg));
  552. }
  553. return Ok(JsonView(groupData.Data));
  554. }
  555. /// <summary>
  556. /// 接团信息 操作(增改)
  557. /// </summary>
  558. /// <param name="dto"></param>
  559. /// <returns></returns>
  560. [HttpPost]
  561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  562. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  563. {
  564. try
  565. {
  566. decimal ffrPrice = 0.00M;
  567. DateTime? visitDt = null;
  568. if (dto.Status == 2)
  569. {
  570. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  571. if (groupInfo != null)
  572. {
  573. ffrPrice = groupInfo.PaymentMoney;
  574. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  575. }
  576. }
  577. var groupData = await _groupRepository.GroupOperation(dto);
  578. if (groupData.Code != 0)
  579. {
  580. return Ok(JsonView(false, groupData.Msg));
  581. }
  582. int diId = 0;
  583. //添加时 默认加入团组汇率
  584. if (dto.Status == 1) //添加
  585. {
  586. diId = groupData.Data;
  587. //添加默认币种
  588. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  589. //默认分配权限
  590. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  591. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  592. var _managerIds = new List<int>() { 22, 32, 21 };
  593. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  594. if (userIds.Count > 0)
  595. {
  596. userIds.Add(208);
  597. //创建团组管控
  598. GroupStepForDelegation.CreateWorkStep(diId);
  599. //发送消息
  600. string groupName = dto.TeamName;
  601. string createGroupUser = string.Empty;
  602. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  603. if (userInfo != null) createGroupUser = userInfo.CnName;
  604. string title = $"系统通知";
  605. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  606. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  607. }
  608. //默认创建倒推表
  609. await _invertedListRep._Create(dto.UserId, diId);
  610. }
  611. else if (dto.Status == 2)
  612. {
  613. diId = dto.Id;
  614. }
  615. #region 签证人员团组时间通知
  616. #region 计算出访起止时间
  617. var startTime = new DateTime();
  618. var endTime = new DateTime();
  619. if (DateTime.TryParse(dto.VisitDate, out startTime))
  620. {
  621. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  622. }
  623. #endregion
  624. if (diId > 0)
  625. {
  626. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  627. }
  628. #endregion
  629. #region 团组操作默认添加/修改收款账单
  630. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  631. {
  632. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  633. .Where(x => x.IsDel == 0 &&
  634. x.Diid == diId &&
  635. x.Remark.Equals("预付款")
  636. )
  637. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  638. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  639. .FirstAsync();
  640. ffrInfo = new Fin_ForeignReceivables()
  641. {
  642. Diid = diId,
  643. PriceName = dto.ClientUnit,
  644. Price = dto.PaymentMoney,
  645. Count = 1,
  646. Unit = $"元",
  647. ItemSumPrice = dto.PaymentMoney,
  648. Rate = 1.0000M,
  649. Currency = 836,
  650. AddingWay = 0,
  651. CreateUserId = dto.UserId,
  652. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  653. Remark = $"预付款"
  654. };
  655. if (ffrInfo == null) //Add
  656. {
  657. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  658. }
  659. else //修改
  660. {
  661. await _sqlSugar.Updateable(ffrInfo)
  662. .UpdateColumns(x => new
  663. {
  664. x.PriceName,
  665. x.Price,
  666. x.ItemSumPrice,
  667. x.CreateTime,
  668. x.CreateUserId
  669. })
  670. .WhereColumns(x => x.Id)
  671. .ExecuteCommandAsync();
  672. }
  673. }
  674. #endregion
  675. return Ok(JsonView(true, "操作成功!", diId));
  676. }
  677. catch (Exception ex)
  678. {
  679. Logs("[response]" + JsonConvert.SerializeObject(dto));
  680. Logs(ex.Message);
  681. return Ok(JsonView(false, ex.Message));
  682. }
  683. }
  684. /// <summary>
  685. /// 接团流程操作(增改)
  686. /// 安卓端使用 建团时添加客户名单
  687. /// </summary>
  688. /// <param name="dto"></param>
  689. /// <returns></returns>
  690. [HttpPost]
  691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  692. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  693. {
  694. try
  695. {
  696. #region 参数验证
  697. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  698. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  699. #region 页面操作权限验证
  700. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  701. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  702. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  703. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  704. #endregion
  705. #endregion
  706. _sqlSugar.BeginTran();
  707. decimal ffrPrice = 0.00M;
  708. DateTime? visitDt = null;
  709. if (dto.Status == 2)
  710. {
  711. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  712. if (groupInfo != null)
  713. {
  714. ffrPrice = groupInfo.PaymentMoney;
  715. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  716. }
  717. }
  718. var _dto = new GroupOperationDto();
  719. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  720. var groupData = await _groupRepository.GroupOperation(_dto);
  721. if (groupData.Code != 0)
  722. {
  723. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  724. }
  725. int diId = 0;
  726. //添加时 默认加入团组汇率
  727. if (dto.Status == 1) //添加
  728. {
  729. diId = groupData.Data;
  730. //添加默认币种
  731. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  732. //默认分配权限
  733. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  734. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  735. List<int> _managerIds = new List<int>() { 21,22, 32 };
  736. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  737. if (userIds.Count > 0)
  738. {
  739. userIds.Add(208);
  740. //创建团组管控
  741. GroupStepForDelegation.CreateWorkStep(diId);
  742. //发送消息
  743. string groupName = dto.TeamName;
  744. string createGroupUser = string.Empty;
  745. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  746. if (userInfo != null) createGroupUser = userInfo.CnName;
  747. string title = $"系统通知";
  748. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  749. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  750. }
  751. #region 应用推送
  752. try
  753. {
  754. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  755. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  756. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  757. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  758. {
  759. List<string> userList = new List<string>() { users.QiyeChatUserId };
  760. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  761. }
  762. }
  763. catch (Exception ex)
  764. {
  765. }
  766. #endregion
  767. //默认创建倒推表
  768. await _invertedListRep._Create(dto.UserId, diId);
  769. }
  770. if (dto.Status == 2)
  771. {
  772. diId = dto.Id;
  773. if (diId == 0)
  774. {
  775. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  776. }
  777. }
  778. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  779. if (viewData.Code != 0)
  780. {
  781. _sqlSugar.RollbackTran();
  782. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  783. }
  784. #region 团组操作默认添加/修改收款账单
  785. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  786. {
  787. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  788. .Where(x => x.IsDel == 0 &&
  789. x.Diid == diId &&
  790. x.Remark.Equals("预付款")
  791. )
  792. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  793. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  794. .FirstAsync();
  795. ffrInfo = new Fin_ForeignReceivables()
  796. {
  797. Diid = diId,
  798. PriceName = dto.ClientUnit,
  799. Price = dto.PaymentMoney,
  800. Count = 1,
  801. Unit = $"元",
  802. ItemSumPrice = dto.PaymentMoney,
  803. Rate = 1.0000M,
  804. Currency = 836,
  805. AddingWay = 0,
  806. CreateUserId = dto.UserId,
  807. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  808. Remark = $"预付款"
  809. };
  810. if (ffrInfo == null) //Add
  811. {
  812. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  813. }
  814. else //修改
  815. {
  816. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  817. .UpdateColumns(x => new
  818. {
  819. x.PriceName,
  820. x.Price,
  821. x.ItemSumPrice,
  822. x.CreateTime,
  823. x.CreateUserId
  824. })
  825. .WhereColumns(x => x.Id)
  826. .ExecuteCommandAsync();
  827. }
  828. }
  829. #endregion
  830. #region 签证人员团组时间通知
  831. #region 计算出访起止时间
  832. var startTime = new DateTime();
  833. var endTime = new DateTime();
  834. if (DateTime.TryParse(dto.VisitDate, out startTime))
  835. {
  836. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  837. }
  838. #endregion
  839. if (diId > 0)
  840. {
  841. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  842. }
  843. #endregion
  844. _sqlSugar.CommitTran();
  845. return Ok(JsonView(true, "添加成功"));
  846. }
  847. catch (Exception ex)
  848. {
  849. _sqlSugar.RollbackTran();
  850. return Ok(JsonView(false, ex.Message));
  851. }
  852. }
  853. /// <summary>
  854. /// 接团信息 操作(删除)
  855. /// </summary>
  856. /// <param name="dto"></param>
  857. /// <returns></returns>
  858. [HttpPost]
  859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  860. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  861. {
  862. try
  863. {
  864. var groupData = await _groupRepository.GroupDel(dto);
  865. if (groupData.Code != 0)
  866. {
  867. return Ok(JsonView(false, groupData.Msg));
  868. }
  869. return Ok(JsonView(true));
  870. }
  871. catch (Exception ex)
  872. {
  873. Logs("[response]" + JsonConvert.SerializeObject(dto));
  874. Logs(ex.Message);
  875. return Ok(JsonView(false, ex.Message));
  876. }
  877. }
  878. /// <summary>
  879. /// 获取团组销售报价号
  880. /// 团组添加时 使用
  881. /// </summary>
  882. /// <returns></returns>
  883. [HttpPost]
  884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  885. public async Task<IActionResult> GetGroupSalesQuoteNo()
  886. {
  887. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  888. if (groupData.Code != 0)
  889. {
  890. return Ok(JsonView(false, groupData.Msg));
  891. }
  892. object salesQuoteNo = new
  893. {
  894. SalesQuoteNo = groupData.Data
  895. };
  896. return Ok(JsonView(salesQuoteNo));
  897. }
  898. /// <summary>
  899. /// 设置确认出团
  900. /// </summary>
  901. /// <param name="dto"></param>
  902. /// <returns></returns>
  903. [HttpPost]
  904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  905. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  906. {
  907. var groupData = await _groupRepository.ConfirmationGroup(dto);
  908. if (groupData.Code != 0)
  909. {
  910. return Ok(JsonView(false, groupData.Msg));
  911. }
  912. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  913. #region OA消息推送
  914. try
  915. {
  916. string groupName = groupInfo.TeamName;
  917. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  918. List<int> userIds = new List<int>();
  919. listUser.ForEach(s => userIds.Add(s.Id));
  920. string title = $"系统通知";
  921. string content = $"团组[{groupName}]已确认出团!";
  922. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  923. }
  924. catch (Exception ex)
  925. {
  926. }
  927. #endregion
  928. #region 应用推送
  929. try
  930. {
  931. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  932. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  933. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  934. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  935. {
  936. List<string> userList = new List<string>() { users.QiyeChatUserId };
  937. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  938. }
  939. }
  940. catch (Exception ex)
  941. {
  942. }
  943. #endregion
  944. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  945. return Ok(JsonView(true, "操作成功!", groupData.Data));
  946. }
  947. /// <summary>
  948. /// 获取团组名称data And 签证国别Data
  949. /// </summary>
  950. /// <param name="dto"></param>
  951. /// <returns></returns>
  952. [HttpPost]
  953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  954. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  955. {
  956. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  957. if (groupData.Code != 0)
  958. {
  959. return Ok(JsonView(false, groupData.Msg));
  960. }
  961. return Ok(JsonView(groupData.Data));
  962. }
  963. /// <summary>
  964. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  965. /// </summary>
  966. /// <returns></returns>
  967. [HttpPost]
  968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  969. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  970. {
  971. try
  972. {
  973. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  974. if (groupData.Code != 0)
  975. {
  976. return Ok(JsonView(false, groupData.Msg));
  977. }
  978. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  979. }
  980. catch (Exception ex)
  981. {
  982. return Ok(JsonView(false, "程序错误!"));
  983. throw;
  984. }
  985. }
  986. /// <summary>
  987. /// 团组清单 Excel
  988. /// </summary>
  989. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  990. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  991. /// <returns></returns>
  992. [HttpGet]
  993. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  994. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  995. {
  996. DateTime _beginDt, _endDt;
  997. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  998. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  999. if (!beginBool && !endBool)
  1000. {
  1001. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1002. }
  1003. string sql = string.Format(@"
  1004. SELECT
  1005. ROW_NUMBER,
  1006. Id,
  1007. SalesQuoteNo,
  1008. TourCode,
  1009. TeamTypeId,
  1010. TeamType,
  1011. TeamLevId,
  1012. TeamLev,
  1013. TeamName,
  1014. ClientName,
  1015. ClientUnit,
  1016. VisitDate,
  1017. VisitDays,
  1018. VisitPNumber,
  1019. JietuanOperatorId,
  1020. JietuanOperator,
  1021. IsSure,
  1022. CreateTime,
  1023. IsBid
  1024. FROM
  1025. (
  1026. SELECT
  1027. ROW_NUMBER() OVER(
  1028. ORDER BY
  1029. gdi.CreateTime Desc
  1030. ) AS ROW_NUMBER,
  1031. gdi.Id,
  1032. SalesQuoteNo,
  1033. TourCode,
  1034. ssd.Id TeamTypeId,
  1035. ssd.Name TeamType,
  1036. ssd1.Id TeamLevId,
  1037. ssd1.Name TeamLev,
  1038. TeamName,
  1039. ClientName,
  1040. ClientUnit,
  1041. VisitDate,
  1042. VisitDays,
  1043. VisitPNumber,
  1044. JietuanOperator JietuanOperatorId,
  1045. su.CnName JietuanOperator,
  1046. IsSure,
  1047. gdi.CreateTime,
  1048. gdi.IsBid
  1049. FROM
  1050. Grp_DelegationInfo gdi
  1051. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1052. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1053. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1054. WHERE
  1055. gdi.IsDel = 0
  1056. AND gdi.IsBid = 0
  1057. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1058. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1059. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1060. #region 处理所属部门
  1061. /*
  1062. * 1.sq 和 gyy 等显示 市场部
  1063. * 2.王鸽和主管及张总还有管理员号统一国交部
  1064. * 2-1. 4 管理员 ,21 张海麟
  1065. */
  1066. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1067. List<int> userIds1 = new List<int>() { 4, 21 };
  1068. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1069. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1070. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1071. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1072. .ToListAsync();
  1073. foreach (var item in groupList)
  1074. {
  1075. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1076. }
  1077. #endregion
  1078. #region Excel
  1079. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1080. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1081. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1082. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1083. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1084. //载入模板
  1085. WorkbookDesigner designer = new WorkbookDesigner();
  1086. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1087. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1088. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1089. dt.TableName = "GroupList";
  1090. designer.SetDataSource(dt);
  1091. designer.Process();
  1092. if (!Directory.Exists(savePath))
  1093. {
  1094. Directory.CreateDirectory(savePath);
  1095. }
  1096. string serverPath = $"{savePath}{fileName}";
  1097. designer.Workbook.Save(serverPath);
  1098. string rst = $"{servicePath}{ftpPath}{fileName}";
  1099. #endregion
  1100. return Ok(JsonView(true, "操作成功!", rst));
  1101. }
  1102. #endregion
  1103. #region 团组&签证
  1104. /// <summary>
  1105. /// 根据团组Id获取签证客户信息List
  1106. /// </summary>
  1107. /// <param name="dto">请求dto</param>
  1108. /// <returns></returns>
  1109. [HttpPost]
  1110. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1111. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1112. {
  1113. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1114. if (groupData.Code != 0)
  1115. {
  1116. return Ok(JsonView(false, groupData.Msg));
  1117. }
  1118. return Ok(JsonView(groupData.Data));
  1119. }
  1120. /// <summary>
  1121. /// IOS获取团组签证拍照上传进度01(团组列表)
  1122. /// </summary>
  1123. /// <param name="dto">请求dto</param>
  1124. /// <returns></returns>
  1125. [HttpPost]
  1126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1127. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1128. {
  1129. if (dto == null)
  1130. {
  1131. return Ok(JsonView(false, "参数为空"));
  1132. }
  1133. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1134. return Ok(JsonView(visaList));
  1135. }
  1136. /// <summary>
  1137. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1138. /// </summary>
  1139. /// <returns></returns>
  1140. [HttpPost]
  1141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1142. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1143. {
  1144. if (dto == null)
  1145. {
  1146. return Ok(JsonView(false, "请求错误:"));
  1147. }
  1148. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1149. return Ok(JsonView(list));
  1150. }
  1151. /// <summary>
  1152. /// IOS获取团组签证拍照上传进度03(相册)
  1153. /// </summary>
  1154. /// <returns></returns>
  1155. [HttpPost]
  1156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1157. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1158. {
  1159. if (dto == null)
  1160. {
  1161. return Ok(JsonView(false, "请求错误:"));
  1162. }
  1163. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1164. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1165. list.ForEach(s => s.url = url);
  1166. return Ok(JsonView(list));
  1167. }
  1168. /// <summary>
  1169. /// IOS获取团组签证拍照上传进度04(图片上传)
  1170. /// </summary>
  1171. /// <param name="dto"></param>
  1172. /// <returns></returns>
  1173. [HttpPost]
  1174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1175. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1176. {
  1177. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1178. //if (!string.IsNullOrEmpty(result))
  1179. //{
  1180. //}
  1181. //else {
  1182. // return Ok(JsonView(false, "上传失败"));
  1183. //}
  1184. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1185. int sucNum = 0;
  1186. try
  1187. {
  1188. foreach (var item in dto.base64DataList)
  1189. {
  1190. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1191. string result = decodeBase64ToImage(item, imageName);
  1192. if (!string.IsNullOrEmpty(result))
  1193. {
  1194. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1195. pic.CreateUserId = dto.CreateUserId;
  1196. pic.PicName = imageName;
  1197. pic.PicPath = result;
  1198. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1199. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1200. if (insertResult > 0)
  1201. {
  1202. sucNum++;
  1203. }
  1204. }
  1205. }
  1206. }
  1207. catch (Exception ex)
  1208. {
  1209. return Ok(JsonView(false, ex.Message));
  1210. }
  1211. string msg = string.Format(@"成功上传{0}张", sucNum);
  1212. return Ok(JsonView(true, msg));
  1213. }
  1214. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1215. {
  1216. string filename = "";//声明一个string类型的相对路径
  1217. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1218. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1219. try//会有异常抛出,try,catch一下
  1220. {
  1221. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1222. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1223. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1224. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1225. //文件名称
  1226. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1227. //上传的文件的路径
  1228. string filePath = "";
  1229. if (!Directory.Exists(fileDir))
  1230. {
  1231. Directory.CreateDirectory(fileDir);
  1232. }
  1233. //上传的文件的路径
  1234. filePath = fileDir + filename;
  1235. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1236. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1237. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1238. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1239. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1240. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1241. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1242. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1243. bitmap.Dispose();
  1244. }
  1245. catch (Exception e)
  1246. {
  1247. string massage = e.Message;
  1248. Logs("IOS图片上传Error:" + massage);
  1249. //filename = e.Message;
  1250. }
  1251. return filename;//返回相对路径
  1252. }
  1253. /// <summary>
  1254. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1255. /// </summary>
  1256. /// <param name="dto"></param>
  1257. /// <returns></returns>
  1258. [HttpPost]
  1259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1260. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1261. {
  1262. if (dto == null)
  1263. {
  1264. return Ok(JsonView(false, "请求错误:"));
  1265. }
  1266. string msg = "参数错误";
  1267. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1268. {
  1269. try
  1270. {
  1271. //_delegationVisaRep.BeginTran();
  1272. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1273. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1274. .Where(s => s.Id == dto.visaProgressCustomerId)
  1275. .ExecuteCommandAsync();
  1276. if (updCount > 0 && dto.publishCode == 1)
  1277. {
  1278. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1279. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1280. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1281. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1282. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1283. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1284. if (groupData == null)
  1285. {
  1286. _delegationVisaRep.RollbackTran();
  1287. }
  1288. string title = string.Format(@"[签证进度更新]");
  1289. string content = string.Format(@"测试文本");
  1290. bool rst = await _message.AddMsg(new MessageDto()
  1291. {
  1292. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1293. IssuerId = dto.publisher,
  1294. Title = title,
  1295. Content = content,
  1296. ReleaseTime = DateTime.Now,
  1297. UIdList = new List<int> {
  1298. 234
  1299. }
  1300. });
  1301. if (rst)
  1302. {
  1303. return Ok(JsonView(true, "发送通知成功"));
  1304. }
  1305. }
  1306. //_delegationVisaRep.CommitTran();
  1307. }
  1308. catch (Exception)
  1309. {
  1310. //_delegationVisaRep.RollbackTran();
  1311. }
  1312. }
  1313. return Ok(JsonView(true, msg));
  1314. }
  1315. #endregion
  1316. #region 团组任务分配
  1317. /// <summary>
  1318. /// 团组任务分配初始化
  1319. /// </summary>
  1320. /// <param name="dto"></param>
  1321. /// <returns></returns>
  1322. [HttpPost]
  1323. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1324. public async Task<IActionResult> GetTaskAssignmen()
  1325. {
  1326. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1327. if (groupData.Code != 0)
  1328. {
  1329. return Ok(JsonView(false, groupData.Msg));
  1330. }
  1331. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1332. }
  1333. /// <summary>
  1334. /// 团组任务分配查询
  1335. /// </summary>
  1336. /// <param name="dto"></param>
  1337. /// <returns></returns>
  1338. [HttpPost]
  1339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1340. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1341. {
  1342. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1343. if (groupData.Code != 0)
  1344. {
  1345. return Ok(JsonView(false, groupData.Msg));
  1346. }
  1347. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1348. }
  1349. /// <summary>
  1350. /// 团组任务分配操作
  1351. /// </summary>
  1352. /// <param name="dto"></param>
  1353. /// <returns></returns>
  1354. [HttpPost]
  1355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1356. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1357. {
  1358. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1359. if (groupData.Code != 0)
  1360. {
  1361. return Ok(JsonView(false, groupData.Msg));
  1362. }
  1363. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1364. }
  1365. /// <summary>
  1366. /// 团组任务分配
  1367. /// 批量分配
  1368. /// 查询团组
  1369. /// </summary>
  1370. /// <param name="dto"></param>
  1371. /// <returns></returns>
  1372. [HttpPost]
  1373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1374. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1375. {
  1376. //参数验证
  1377. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1378. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1379. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1380. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1381. }
  1382. /// <summary>
  1383. /// 团组任务分配
  1384. /// 批量分配
  1385. /// </summary>
  1386. /// <param name="dto"></param>
  1387. /// <returns></returns>
  1388. [HttpPost]
  1389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1390. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1391. {
  1392. //参数验证
  1393. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1394. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1395. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1396. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1397. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1398. }
  1399. #endregion
  1400. #region 团组费用审核
  1401. /// <summary>
  1402. /// 费用审核
  1403. /// 团组列表 Page
  1404. /// </summary>
  1405. /// <param name="_dto">团组列表请求dto</param>
  1406. /// <returns></returns>
  1407. [HttpPost]
  1408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1409. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1410. {
  1411. #region 参数验证
  1412. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1413. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1414. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1415. #region 页面操作权限验证
  1416. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1417. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1418. #endregion
  1419. #endregion
  1420. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1421. {
  1422. string sqlWhere = string.Empty;
  1423. if (_dto.IsSure == 0) //未完成
  1424. {
  1425. sqlWhere += string.Format(@" And IsSure = 0");
  1426. }
  1427. else if (_dto.IsSure == 1) //已完成
  1428. {
  1429. sqlWhere += string.Format(@" And IsSure = 1");
  1430. }
  1431. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1432. {
  1433. string tj = _dto.SearchCriteria;
  1434. 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}%')",
  1435. tj, tj, tj, tj, tj);
  1436. }
  1437. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1438. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1439. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1440. From (
  1441. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1442. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1443. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1444. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1445. From Grp_DelegationInfo gdi
  1446. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1447. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1448. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1449. Where gdi.IsDel = 0 {0}
  1450. ) temp ", sqlWhere);
  1451. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1452. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1453. var _view = new
  1454. {
  1455. PageFuncAuth = pageFunAuthView,
  1456. Data = _DelegationList
  1457. };
  1458. return Ok(JsonView(true, "查询成功!", _view, total));
  1459. }
  1460. else
  1461. {
  1462. return Ok(JsonView(false, "查询失败"));
  1463. }
  1464. }
  1465. /// <summary>
  1466. /// 获取团组费用审核
  1467. /// </summary>
  1468. /// <param name="paras">参数Json字符串</param>
  1469. /// <returns></returns>
  1470. [HttpPost]
  1471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1472. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1473. {
  1474. try
  1475. {
  1476. #region 参数验证
  1477. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1478. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1479. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1480. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1481. #region 页面操作权限验证
  1482. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1483. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1484. #endregion
  1485. #endregion
  1486. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1487. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1488. #region 费用清单
  1489. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1490. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1491. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1492. List<Grp_CreditCardPayment> entityList = _groupRepository
  1493. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1494. .Where(exp.ToExpression())
  1495. .ToList();
  1496. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1497. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1498. /*
  1499. * 76://酒店预订
  1500. */
  1501. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1502. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1503. .ToListAsync();
  1504. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1505. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1506. .ToListAsync();
  1507. /*
  1508. * 79://车/导游地接
  1509. */
  1510. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1511. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1512. .ToListAsync();
  1513. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1514. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1515. .ToListAsync();
  1516. /*
  1517. * 80: //签证
  1518. */
  1519. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1520. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1521. .ToListAsync();
  1522. /*
  1523. *81: //邀请/公务活动
  1524. */
  1525. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1526. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1527. .ToListAsync();
  1528. /*
  1529. * 82: //团组客户保险
  1530. */
  1531. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1532. /*
  1533. * Lable = 85 机票预订
  1534. */
  1535. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1536. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1537. .ToListAsync();
  1538. /*
  1539. * 85 机票预定
  1540. */
  1541. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1542. /*
  1543. * 98 其他款项
  1544. */
  1545. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1546. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1547. .ToListAsync();
  1548. /*
  1549. * 285:收款退还
  1550. */
  1551. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1552. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1553. .ToListAsync();
  1554. /*
  1555. * 1015: //超支费用
  1556. */
  1557. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1558. /*
  1559. * 币种信息
  1560. */
  1561. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1562. /*
  1563. * 车/导游地接 费用类型
  1564. */
  1565. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1566. /*
  1567. * 车/导游地接 费用类型
  1568. */
  1569. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1570. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1571. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1572. /*
  1573. * 用户信息
  1574. */
  1575. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1576. /*
  1577. * 费用模块
  1578. */
  1579. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1580. string priceModule = string.Empty;
  1581. if (sdPriceName != null)
  1582. {
  1583. priceModule = sdPriceName.Name;
  1584. }
  1585. /*
  1586. * 成本信息
  1587. */
  1588. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1589. decimal _groupRate = 0.0000M;
  1590. string _groupCurrencyCode = "-";
  1591. if (groupCost != null)
  1592. {
  1593. _groupRate = groupCost.Rate;
  1594. if (int.TryParse(groupCost.Currency, out int _currency))
  1595. {
  1596. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1597. }
  1598. else _groupCurrencyCode = groupCost.Currency;
  1599. }
  1600. string costContentSql = $"Select * From Grp_GroupCost";
  1601. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1602. //处理日期为空的天数
  1603. for (int i = 0; i < groupCostDetails.Count; i++)
  1604. if (i != 0)
  1605. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1606. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1607. /*
  1608. * 处理详情数据
  1609. */
  1610. foreach (var entity in entityList)
  1611. {
  1612. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1613. _detail.Id = entity.Id;
  1614. _detail.PriceName = priceModule;
  1615. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1616. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1617. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1618. //处理金额
  1619. if (entity.CTable == 1015)
  1620. {
  1621. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1622. if (czInfo != null)
  1623. {
  1624. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1625. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1626. }
  1627. }
  1628. /*
  1629. * 应付款金额
  1630. */
  1631. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1632. string PaymentCurrency_WaitPay = "Unknown";
  1633. string hotelCurrncyCode = "Unknown";
  1634. string hotelCurrncyName = "Unknown";
  1635. if (sdPaymentCurrency_WaitPay != null)
  1636. {
  1637. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1638. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1639. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1640. if (hotelCurrncyCode.Equals("CNY"))
  1641. {
  1642. entity.DayRate = 1.0000M;
  1643. }
  1644. }
  1645. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1646. /*
  1647. * 此次付款金额
  1648. */
  1649. decimal CurrPayStr = 0.00M,
  1650. OriginalCurrPay = 0.00M;
  1651. if (entity.PayPercentage == 0)
  1652. {
  1653. if (entity.PayThenMoney != 0)
  1654. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1655. }
  1656. else
  1657. {
  1658. if (entity.PayMoney != 0)
  1659. {
  1660. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1661. }
  1662. }
  1663. if (_dto.Label == 79)
  1664. {
  1665. string original = string.Empty;
  1666. if (hotelCurrncyCode.Equals("CNY"))
  1667. {
  1668. OriginalCurrPay = CurrPayStr;
  1669. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1670. }
  1671. else
  1672. {
  1673. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1674. //760 EUR(7600.00 CNY)
  1675. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1676. }
  1677. }
  1678. else
  1679. {
  1680. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1681. }
  1682. /*
  1683. * 剩余尾款
  1684. */
  1685. decimal BalanceStr = 0;
  1686. if (CurrPayStr != 0)
  1687. {
  1688. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1689. BalanceStr = 0;
  1690. else
  1691. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1692. }
  1693. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1694. /*
  1695. * Bus名称
  1696. */
  1697. _detail.BusName = "待增加";
  1698. /*
  1699. *费用所属
  1700. */
  1701. switch (entity.CTable)
  1702. {
  1703. case 76://酒店预订
  1704. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1705. if (hotelReservations != null)
  1706. {
  1707. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1708. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1709. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1710. string roomFeeStr = "", roomFeestr1 = "";
  1711. //是否比较房型价格
  1712. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1713. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1714. roomFeeStr += $"<br/>";
  1715. if (hotelReservations.SingleRoomPrice > 0)
  1716. {
  1717. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1718. __isSingle = true;
  1719. }
  1720. if (hotelReservations.DoubleRoomPrice > 0)
  1721. {
  1722. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1723. __isDouble = true;
  1724. }
  1725. if (hotelReservations.SuiteRoomPrice > 0)
  1726. {
  1727. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1728. __isSuite = true;
  1729. }
  1730. if (hotelReservations.OtherRoomPrice > 0)
  1731. {
  1732. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1733. __isOther = true;
  1734. }
  1735. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1736. else roomFeeStr += " 0.00 * 0";
  1737. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1738. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1739. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1740. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1741. /*
  1742. * 费用类型
  1743. * 1:房费
  1744. * 2:早餐
  1745. * 3:地税
  1746. * 4:城市税
  1747. * </summary>
  1748. */
  1749. //地税
  1750. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1751. if (governmentRentData != null)
  1752. {
  1753. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1754. governmentRentFee = governmentRentData.Price;
  1755. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1756. if (governmentRentCurrData != null)
  1757. {
  1758. governmentRentCode = governmentRentCurrData.Name;
  1759. governmentRentName = $"({governmentRentCurrData.Remark})";
  1760. }
  1761. }
  1762. //城市税
  1763. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1764. if (cityTaxData != null)
  1765. {
  1766. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1767. cityTaxFee = cityTaxData.Price;
  1768. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1769. if (cityTaxCurrData != null)
  1770. {
  1771. cityTaxCode = cityTaxCurrData.Name;
  1772. cityTaxName = $"({cityTaxCurrData.Remark})";
  1773. }
  1774. }
  1775. //酒店早餐
  1776. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1777. if (breakfastData != null)
  1778. {
  1779. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1780. breakfastFee = breakfastData.Price;
  1781. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1782. if (breakfastCurrData != null)
  1783. {
  1784. breakfastCode = breakfastCurrData.Name;
  1785. breakfastName = $"({breakfastCurrData.Remark})";
  1786. }
  1787. }
  1788. //房间费用
  1789. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1790. if (roomData != null)
  1791. {
  1792. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1793. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1794. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1795. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1796. roomFee = roomData.Price;
  1797. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1798. if (roomCurrData != null)
  1799. {
  1800. roomCode = roomCurrData.Name;
  1801. roomName = $"({roomCurrData.Remark})";
  1802. }
  1803. }
  1804. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1805. string hotelCostStr = "";
  1806. decimal hotelCsotTotal = 0.00M;
  1807. if (groupCost != null)
  1808. {
  1809. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1810. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1811. }
  1812. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1813. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1814. string hotelCost_day = "";
  1815. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1816. foreach (var item in hotelCostDetails1)
  1817. {
  1818. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1819. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1820. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1821. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1822. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1823. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1824. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1825. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1826. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1827. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1828. hotelCost_day += @$"<br/>";
  1829. }
  1830. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1831. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1832. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1833. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1834. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1835. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1836. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1837. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1838. $"房间说明: {hotelReservations.Remark} <br/>" +
  1839. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1840. $"{hotelBreakfastStr}" +
  1841. $"{hotelGovernmentRentStr}" +
  1842. $"{hotelCityTaxStr}";
  1843. _detail.PriceNameContent = hotelReservations.HotelName;
  1844. }
  1845. break;
  1846. case 79://车/导游地接
  1847. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1848. if (touristGuideGroundReservations != null)
  1849. {
  1850. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1851. {
  1852. _detail.BusName = touristGuideGroundReservations.BusName;
  1853. }
  1854. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1855. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1856. //if (isInt)
  1857. //{
  1858. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1859. // if (cityInfo != null)
  1860. // {
  1861. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1862. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1863. // if (carFeeItem != null)
  1864. // {
  1865. // nameContent += $@"({carFeeItem.Name})";
  1866. // }
  1867. // _detail.PriceNameContent = nameContent;
  1868. // }
  1869. //}
  1870. //else
  1871. //{
  1872. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1873. //}
  1874. var touristGuideGroundReservationsContents =
  1875. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1876. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1877. foreach (var item in touristGuideGroundReservationsContents)
  1878. {
  1879. string typeName = "Unknown";
  1880. string carCurrencyCode = "Unknown";
  1881. string carCurrencyName = "Unknown";
  1882. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1883. if (carTypeData != null) typeName = carTypeData.Name;
  1884. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1885. if (currencyData != null)
  1886. {
  1887. carCurrencyCode = currencyData.Name;
  1888. carCurrencyName = currencyData.Remark;
  1889. }
  1890. //op、成本 币种是否一致
  1891. bool IsCurrencyAgreement = false;
  1892. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1893. string opCostStr = string.Empty;
  1894. decimal opCostTypePrice = 0.00M;
  1895. #region 处理成本各项费用
  1896. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1897. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1898. if (opCost.Count > 0)
  1899. {
  1900. switch (item.SId)
  1901. {
  1902. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1903. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1904. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1905. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1906. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1907. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1908. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1909. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1910. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1911. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1912. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1913. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1914. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1915. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1916. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1917. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1918. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1919. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1920. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1921. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1922. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1923. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1924. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1925. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1926. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1927. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1928. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1929. }
  1930. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1931. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1932. }
  1933. #endregion
  1934. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1935. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1936. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1937. $"{opTypeStr} {opCostStr}<br/>" +
  1938. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1939. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1940. }
  1941. _detail.PriceMsgContent = priceMsg;
  1942. }
  1943. break;
  1944. case 80: //签证
  1945. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1946. if (visaInfo != null)
  1947. {
  1948. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1949. _detail.PriceNameContent = visaInfo.VisaDescription;
  1950. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1951. }
  1952. break;
  1953. case 81: //邀请/公务活动
  1954. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1955. if (_ioa != null)
  1956. {
  1957. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1958. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1959. sendCurrName = "Unknown", //快递费用币种 Name
  1960. sendCurrCode = "Unknown", //快递费用币种 Code
  1961. eventsCurrName = "Unknown", //公务活动费币种 Name
  1962. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1963. translateCurrName = "Unknown", //公务翻译费 Name
  1964. translateCurrCode = "Unknown"; //公务翻译费 Code
  1965. #region 处理费用币种
  1966. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1967. if (inviteCurrData != null)
  1968. {
  1969. inviteCurrName = inviteCurrData.Remark;
  1970. inviteCurrCode = inviteCurrData.Name;
  1971. }
  1972. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1973. if (sendCurrData != null)
  1974. {
  1975. sendCurrName = sendCurrData.Remark;
  1976. sendCurrCode = sendCurrData.Name;
  1977. }
  1978. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1979. if (eventsCurrData != null)
  1980. {
  1981. eventsCurrName = eventsCurrData.Remark;
  1982. eventsCurrCode = eventsCurrData.Name;
  1983. }
  1984. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1985. if (translateCurrData != null)
  1986. {
  1987. translateCurrName = translateCurrData.Remark;
  1988. translateCurrCode = translateCurrData.Name;
  1989. }
  1990. #endregion
  1991. _detail.PriceNameContent = _ioa.InviterArea;
  1992. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1993. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1994. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1995. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1996. $@"备注:" + _ioa.Remark + "<br/>";
  1997. }
  1998. break;
  1999. case 82: //团组客户保险
  2000. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2001. if (customers != null)
  2002. {
  2003. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2004. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2005. }
  2006. break;
  2007. case 85: //机票预订
  2008. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2009. if (jpRes != null)
  2010. {
  2011. string FlightsDescription = jpRes.FlightsDescription;
  2012. string PriceDescription = jpRes.PriceDescription;
  2013. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2014. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2015. }
  2016. break;
  2017. case 98://其他款项
  2018. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2019. if (gdpRes != null)
  2020. {
  2021. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2022. _detail.PriceNameContent = gdpRes.PriceName;
  2023. }
  2024. break;
  2025. case 285://收款退还
  2026. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2027. if (refundAndOtherMoney != null)
  2028. {
  2029. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2030. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2031. }
  2032. break;
  2033. case 751://酒店早餐
  2034. break;
  2035. case 1015://超支费用
  2036. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2037. if (groupExtraCost != null)
  2038. {
  2039. _detail.PriceNameContent = groupExtraCost.PriceName;
  2040. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2041. }
  2042. break;
  2043. default:
  2044. break;
  2045. }
  2046. /*
  2047. * 申请人
  2048. */
  2049. string operatorName = " - ";
  2050. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2051. if (_opUser != null)
  2052. {
  2053. operatorName = _opUser.CnName;
  2054. }
  2055. _detail.OperatorName = operatorName;
  2056. /*
  2057. * 审核人
  2058. */
  2059. string auditOperatorName = "Unknown";
  2060. if (entity.AuditGMOperate == 0)
  2061. auditOperatorName = " - ";
  2062. else if (entity.AuditGMOperate == 4)
  2063. auditOperatorName = "自动审核";
  2064. else
  2065. {
  2066. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2067. if (_adUser != null)
  2068. {
  2069. auditOperatorName = _adUser.CnName;
  2070. }
  2071. }
  2072. _detail.AuditOperatorName = auditOperatorName;
  2073. /*
  2074. * 超预算比例
  2075. */
  2076. string overBudgetStr = "";
  2077. if (entity.ExceedBudget == -1)
  2078. overBudgetStr = sdPriceName.Name + "尚无预算";
  2079. else if (entity.ExceedBudget == 0)
  2080. {
  2081. if (entity.CTable == 76 || entity.CTable == 79)
  2082. {
  2083. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2084. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2085. }
  2086. else
  2087. {
  2088. overBudgetStr = "未超预算";
  2089. }
  2090. }
  2091. else
  2092. overBudgetStr = entity.ExceedBudget.ToString("P");
  2093. _detail.OverBudget = overBudgetStr;
  2094. /*
  2095. * 已审核金额
  2096. */
  2097. decimal auditFee = 0.00M;
  2098. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  2099. /*
  2100. * 费用总计
  2101. */
  2102. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2103. {
  2104. CurrencyId = entity.PaymentCurrency,
  2105. CurrencyName = PaymentCurrency_WaitPay,
  2106. AmountPayable = entity.PayMoney,
  2107. ThisPayment = OriginalCurrPay,
  2108. BalancePayment = BalanceStr,
  2109. AuditedFunds = auditFee
  2110. });
  2111. _detail.IsAuditGM = entity.IsAuditGM;
  2112. detailList.Add(_detail);
  2113. }
  2114. #endregion
  2115. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2116. /*
  2117. * 下方描述处理
  2118. */
  2119. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2120. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2121. if (ccpCurrencyPrice != null)
  2122. {
  2123. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2124. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2125. }
  2126. else
  2127. {
  2128. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2129. }
  2130. string amountPayableStr = string.Format(@"应付款总金额: ");
  2131. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2132. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2133. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2134. foreach (var item in nonDuplicat)
  2135. {
  2136. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2137. if (strs.Count > 0)
  2138. {
  2139. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2140. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2141. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2142. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  2143. //单独处理此次付款金额
  2144. if (item.CurrencyId == 836) //人民币
  2145. {
  2146. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2147. }
  2148. else
  2149. {
  2150. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2151. }
  2152. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  2153. //单独处理已审核费用
  2154. if (item.CurrencyId == 836) //人民币
  2155. {
  2156. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2157. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  2158. }
  2159. else
  2160. {
  2161. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  2162. }
  2163. }
  2164. }
  2165. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2166. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2167. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2168. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  2169. var _view1 = new
  2170. {
  2171. PageFuncAuth = pageFunAuthView,
  2172. Data = _view
  2173. };
  2174. return Ok(JsonView(_view1));
  2175. }
  2176. catch (Exception ex)
  2177. {
  2178. return Ok(JsonView(false, ex.Message));
  2179. }
  2180. }
  2181. /// <summary>
  2182. /// 费用审核
  2183. /// 修改团组费用审核状态
  2184. /// </summary>
  2185. /// <param name="_dto">参数Json字符串</param>
  2186. /// <returns></returns>
  2187. [HttpPost]
  2188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2189. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2190. {
  2191. #region 参数验证
  2192. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2193. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2194. #endregion
  2195. #region 页面操作权限验证
  2196. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2197. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2198. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2199. #endregion
  2200. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2201. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2202. DateTime dtNow = DateTime.Now;
  2203. _groupRepository.BeginTran();
  2204. int rst = 0;
  2205. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2206. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2207. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2208. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2209. List<dynamic> msgDatas = new List<dynamic>();
  2210. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2211. foreach (var item in idList)
  2212. {
  2213. int CreditId = int.Parse(item);
  2214. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2215. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2216. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2217. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2218. .Where(s => s.Id == CreditId)
  2219. .ExecuteCommandAsync();
  2220. if (result < 1)
  2221. {
  2222. rst = -1;
  2223. _groupRepository.RollbackTran();
  2224. return Ok(JsonView(false, "操作失败并回滚!"));
  2225. }
  2226. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2227. if (creditData != null)
  2228. {
  2229. #region 应用通知配置
  2230. try
  2231. {
  2232. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2233. }
  2234. catch (Exception ex)
  2235. {
  2236. }
  2237. #endregion
  2238. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2239. string groupNameStr = string.Empty;
  2240. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2241. if (groupData != null) groupNameStr = groupData.TeamName;
  2242. string creditTypeStr = string.Empty;
  2243. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2244. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2245. string creditCurrency = string.Empty;
  2246. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2247. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2248. if (creditCurrency.Equals("CNY"))
  2249. {
  2250. creditData.DayRate = 1.0000M;
  2251. }
  2252. if (creditData.PayPercentage == 0.00M)
  2253. {
  2254. creditData.PayPercentage = 100M;
  2255. }
  2256. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2257. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2258. string msgContent = "";
  2259. if (creditCurrency.Equals("CNY"))
  2260. {
  2261. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2262. }
  2263. else
  2264. {
  2265. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2266. }
  2267. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2268. }
  2269. }
  2270. if (rst == 0)
  2271. {
  2272. _groupRepository.CommitTran();
  2273. foreach (var item in msgDatas)
  2274. {
  2275. //发送消息
  2276. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2277. }
  2278. #region 应用推送
  2279. try
  2280. {
  2281. foreach (var ccpId in dic_ccp_user.Keys)
  2282. {
  2283. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2284. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2285. }
  2286. }
  2287. catch (Exception)
  2288. {
  2289. }
  2290. #endregion
  2291. return Ok(JsonView(true, "操作成功!"));
  2292. }
  2293. return Ok(JsonView(false, "操作失败!"));
  2294. }
  2295. #endregion
  2296. #region 机票费用录入
  2297. /// <summary>
  2298. /// 机票录入当前登录人可操作团组
  2299. /// </summary>
  2300. /// <param name="dto"></param>
  2301. /// <returns></returns>
  2302. [HttpPost]
  2303. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2304. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2305. {
  2306. try
  2307. {
  2308. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2309. if (groupData.Code != 0)
  2310. {
  2311. return Ok(JsonView(false, groupData.Msg));
  2312. }
  2313. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2314. }
  2315. catch (Exception ex)
  2316. {
  2317. return Ok(JsonView(false, "程序错误!"));
  2318. throw;
  2319. }
  2320. }
  2321. /// <summary>
  2322. /// 机票费用录入列表
  2323. /// </summary>
  2324. /// <param name="dto"></param>
  2325. /// <returns></returns>
  2326. [HttpPost]
  2327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2328. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2329. {
  2330. try
  2331. {
  2332. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2333. if (groupData.Code != 0)
  2334. {
  2335. return Ok(JsonView(false, groupData.Msg));
  2336. }
  2337. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2338. }
  2339. catch (Exception ex)
  2340. {
  2341. return Ok(JsonView(false, ex.Message));
  2342. throw;
  2343. }
  2344. }
  2345. /// <summary>
  2346. /// 根据id查询费用录入信息
  2347. /// </summary>
  2348. /// <param name="dto"></param>
  2349. /// <returns></returns>
  2350. [HttpPost]
  2351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2352. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2353. {
  2354. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2355. if (groupData.Code != 0)
  2356. {
  2357. return Ok(JsonView(false, groupData.Msg));
  2358. }
  2359. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2360. }
  2361. /// <summary>
  2362. /// 机票费用录入操作(Status:1.新增,2.修改)
  2363. /// </summary>
  2364. /// <param name="dto"></param>
  2365. /// <returns></returns>
  2366. [HttpPost]
  2367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2368. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2369. {
  2370. try
  2371. {
  2372. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2373. if (groupData.Code != 0)
  2374. {
  2375. return Ok(JsonView(false, groupData.Msg));
  2376. }
  2377. #region 应用推送
  2378. try
  2379. {
  2380. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2381. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2382. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2383. //2024-10-21 新增LZ UID
  2384. var userIds = new List<int>() { 21 };
  2385. string title = $"系统通知";
  2386. string content = "";
  2387. var diId = dto.AirTicketResOpData.DiId;
  2388. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2389. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2390. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2391. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2392. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2393. }
  2394. catch (Exception ex)
  2395. {
  2396. }
  2397. #endregion
  2398. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2399. }
  2400. catch (Exception ex)
  2401. {
  2402. return Ok(JsonView(false, "程序错误!"));
  2403. throw;
  2404. }
  2405. }
  2406. /// <summary>
  2407. /// 根据舱位类型查询接团客户名单信息
  2408. /// </summary>
  2409. /// <param name="dto"></param>
  2410. /// <returns></returns>
  2411. [HttpPost]
  2412. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2413. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2414. {
  2415. try
  2416. {
  2417. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2418. if (crm_Groups.Count != 0)
  2419. {
  2420. List<dynamic> Customer = new List<dynamic>();
  2421. foreach (var item in crm_Groups)
  2422. {
  2423. var data = new
  2424. {
  2425. Id = item.Id,
  2426. Pinyin = item.Pinyin,
  2427. Name = item.LastName + item.FirstName
  2428. };
  2429. Customer.Add(data);
  2430. }
  2431. return Ok(JsonView(true, "查询成功!", Customer));
  2432. }
  2433. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2434. }
  2435. catch (Exception ex)
  2436. {
  2437. return Ok(JsonView(false, "程序错误!"));
  2438. throw;
  2439. }
  2440. }
  2441. /// <summary>
  2442. /// 根据团号获取客户信息
  2443. /// </summary>
  2444. /// <param name="dto"></param>
  2445. /// <returns></returns>
  2446. [HttpPost]
  2447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2448. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2449. {
  2450. var jw = JsonView(false);
  2451. if (dto.DIID < 1)
  2452. {
  2453. jw.Msg += "请输入正确的diid";
  2454. return Ok(jw);
  2455. }
  2456. var arr = getSimplClientList(dto.DIID);
  2457. jw = JsonView(true, "获取成功!", arr);
  2458. return Ok(jw);
  2459. }
  2460. private List<SimplClientInfo> getSimplClientList(int diId)
  2461. {
  2462. 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);
  2463. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2464. return arr;
  2465. }
  2466. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2467. {
  2468. string result = origin;
  2469. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2470. {
  2471. string[] temparr = origin.Split(',');
  2472. string fistrStr = temparr[0];
  2473. int count = temparr.Count();
  2474. int tempId;
  2475. bool success = int.TryParse(fistrStr, out tempId);
  2476. if (success)
  2477. {
  2478. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2479. if (tempInfo != null)
  2480. {
  2481. if (count > 1)
  2482. {
  2483. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2484. }
  2485. else
  2486. {
  2487. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2488. }
  2489. }
  2490. }
  2491. }
  2492. return result;
  2493. }
  2494. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2495. {
  2496. string result = origin;
  2497. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2498. {
  2499. string[] temparr = origin.Split(',');
  2500. result = "";
  2501. foreach (var item in temparr)
  2502. {
  2503. int tempId;
  2504. bool success = int.TryParse(item, out tempId);
  2505. if (success)
  2506. {
  2507. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2508. if (tempInfo != null)
  2509. {
  2510. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2511. }
  2512. }
  2513. }
  2514. }
  2515. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2516. return result;
  2517. }
  2518. /// <summary>
  2519. /// 机票费用录入,删除
  2520. /// </summary>
  2521. /// <param name="dto"></param>
  2522. /// <returns></returns>
  2523. [HttpPost]
  2524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2525. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2526. {
  2527. try
  2528. {
  2529. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2530. if (res)
  2531. {
  2532. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2533. {
  2534. IsDel = 1,
  2535. DeleteUserId = dto.DeleteUserId,
  2536. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2537. }).ExecuteCommandAsync();
  2538. return Ok(JsonView(true, "删除成功!"));
  2539. }
  2540. return Ok(JsonView(false, "删除失败!"));
  2541. }
  2542. catch (Exception ex)
  2543. {
  2544. return Ok(JsonView(false, "程序错误!"));
  2545. throw;
  2546. }
  2547. }
  2548. /// <summary>
  2549. /// 导出机票录入报表
  2550. /// </summary>
  2551. /// <param name="dto"></param>
  2552. /// <returns></returns>
  2553. [HttpPost]
  2554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2555. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2556. {
  2557. try
  2558. {
  2559. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2560. if (groupData.Code != 0)
  2561. {
  2562. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2563. }
  2564. else
  2565. {
  2566. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2567. if (AirTicketReservations.Count != 0)
  2568. {
  2569. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2570. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2571. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2572. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2573. WorkbookDesigner designer = new WorkbookDesigner();
  2574. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2575. decimal countCost = 0;
  2576. foreach (var item in AirTicketReservations)
  2577. {
  2578. #region 处理客人姓名
  2579. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2580. item.ClientName = clientNames;
  2581. #endregion
  2582. if (item.BankType == "其他")
  2583. {
  2584. item.BankNo = "--";
  2585. }
  2586. else
  2587. {
  2588. if (!string.IsNullOrEmpty(item.BankType))
  2589. {
  2590. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2591. }
  2592. }
  2593. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2594. item.Price = System.Decimal.Round(item.Price, 2);
  2595. countCost += Convert.ToDecimal(item.Price);
  2596. }
  2597. designer.SetDataSource("Export", AirTicketReservations);
  2598. designer.SetDataSource("ExportDiCode", diCode);
  2599. designer.SetDataSource("ExportDiName", diName);
  2600. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2601. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2602. designer.Process();
  2603. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2604. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2605. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2606. return Ok(JsonView(true, "成功", url = rst));
  2607. }
  2608. else
  2609. {
  2610. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2611. }
  2612. }
  2613. }
  2614. catch (Exception ex)
  2615. {
  2616. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2617. throw;
  2618. }
  2619. }
  2620. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2621. /// <summary>
  2622. /// 行程单导出
  2623. /// </summary>
  2624. /// <param name="dto"></param>
  2625. /// <returns></returns>
  2626. [HttpPost]
  2627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2628. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2629. {
  2630. try
  2631. {
  2632. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2633. if (groupData.Code != 0)
  2634. {
  2635. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2636. }
  2637. else
  2638. {
  2639. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2640. if (dto.Language == "CN")
  2641. {
  2642. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2643. DocumentBuilder builder = new DocumentBuilder(doc);
  2644. int tableIndex = 0;//表格索引
  2645. //得到文档中的第一个表格
  2646. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2647. foreach (var item in _AirTicketReservations)
  2648. {
  2649. #region 处理固定数据
  2650. string[] FlightsCode = item.FlightsCode.Split('/');
  2651. if (FlightsCode.Length != 0)
  2652. {
  2653. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2654. if (_AirCompany != null)
  2655. {
  2656. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2657. }
  2658. else
  2659. {
  2660. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2661. }
  2662. }
  2663. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2664. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2665. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2666. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2667. string name = "";
  2668. foreach (string clientName in nameArray)
  2669. {
  2670. if (!name.Contains(clientName))
  2671. {
  2672. name += clientName + ",";
  2673. }
  2674. }
  2675. if (!string.IsNullOrWhiteSpace(name))
  2676. {
  2677. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2678. }
  2679. else
  2680. {
  2681. table.Range.Bookmarks["ClientName"].Text = "--";
  2682. }
  2683. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2684. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2685. table.Range.Bookmarks["JointTicket"].Text = "--";
  2686. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2687. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2688. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2689. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2690. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2691. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2692. #endregion
  2693. #region 循环数据处理
  2694. List<AirInfo> airs = new List<AirInfo>();
  2695. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2696. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2697. for (int i = 0; i < FlightsCode.Length; i++)
  2698. {
  2699. AirInfo air = new AirInfo();
  2700. string[] tempstr = DayArray[i]
  2701. .Replace("\r\n", string.Empty)
  2702. .Replace("\\r\\n", string.Empty)
  2703. .TrimStart().TrimEnd()
  2704. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2705. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2706. string starCity = "";
  2707. if (star_Three != null)
  2708. {
  2709. starCity = star_Three.AirPort;
  2710. }
  2711. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2712. string EndCity = "";
  2713. if (End_Three != null)
  2714. {
  2715. EndCity = End_Three.AirPort;
  2716. }
  2717. air.Destination = starCity + "/" + EndCity;
  2718. air.Flight = FlightsCode[i];
  2719. air.SeatingClass = item.CTypeName;
  2720. string dateTime = tempstr[2];
  2721. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2722. air.FlightDate = DateTemp;
  2723. air.DepartureTime = tempstr[5];
  2724. air.LandingTime = tempstr[6];
  2725. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2726. air.TicketStatus = "--";
  2727. air.Luggage = "--";
  2728. air.DepartureTerminal = "--";
  2729. air.LandingTerminal = "--";
  2730. airs.Add(air);
  2731. }
  2732. int row = 13;
  2733. for (int i = 0; i < airs.Count; i++)
  2734. {
  2735. if (airs.Count > 2)
  2736. {
  2737. for (int j = 0; j < airs.Count - 2; j++)
  2738. {
  2739. var CopyRow = table.Rows[12].Clone(true);
  2740. table.Rows.Add(CopyRow);
  2741. }
  2742. }
  2743. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2744. int index = 0;
  2745. foreach (PropertyInfo property in properties)
  2746. {
  2747. string value = property.GetValue(airs[i]).ToString();
  2748. Cell ishcel0 = table.Rows[row].Cells[index];
  2749. Paragraph p = new Paragraph(doc);
  2750. string s = value;
  2751. p.AppendChild(new Run(doc, s));
  2752. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2753. ishcel0.AppendChild(p);
  2754. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2755. index++;
  2756. }
  2757. row++;
  2758. }
  2759. #endregion
  2760. Paragraph lastParagraph = new Paragraph(doc);
  2761. //第一个表格末尾加段落
  2762. table.ParentNode.InsertAfter(lastParagraph, table);
  2763. //复制第一个表格
  2764. Table cloneTable = (Table)table.Clone(true);
  2765. //在文档末尾段落后面加入复制的表格
  2766. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2767. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2768. {
  2769. int rownewsIndex = 13;
  2770. for (int i = 0; i < 2; i++)
  2771. {
  2772. var CopyRow = table.Rows[12].Clone(true);
  2773. table.Rows.RemoveAt(13);
  2774. table.Rows.Add(CopyRow);
  2775. rownewsIndex++;
  2776. }
  2777. }
  2778. else
  2779. {
  2780. table.Rows.RemoveAt(12);
  2781. }
  2782. cloneTable.Rows.RemoveAt(12);
  2783. }
  2784. if (_AirTicketReservations.Count != 0)
  2785. {
  2786. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2787. if (FlightsCode.Length != 0)
  2788. {
  2789. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2790. if (_AirCompany != null)
  2791. {
  2792. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2793. }
  2794. else
  2795. {
  2796. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2797. }
  2798. }
  2799. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2800. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2801. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2802. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2803. string name = "";
  2804. foreach (string clientName in nameArray)
  2805. {
  2806. if (!name.Contains(clientName))
  2807. {
  2808. name += clientName + ",";
  2809. }
  2810. }
  2811. if (!string.IsNullOrWhiteSpace(name))
  2812. {
  2813. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2814. }
  2815. else
  2816. {
  2817. table.Range.Bookmarks["ClientName"].Text = "--";
  2818. }
  2819. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2820. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2821. table.Range.Bookmarks["JointTicket"].Text = "--";
  2822. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2823. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2824. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2825. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2826. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2827. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2828. }
  2829. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2830. //保存合并后的文档
  2831. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2832. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2833. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2834. return Ok(JsonView(true, "成功!", rst));
  2835. }
  2836. else
  2837. {
  2838. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2839. DocumentBuilder builder = new DocumentBuilder(doc);
  2840. int tableIndex = 0;//表格索引
  2841. //得到文档中的第一个表格
  2842. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2843. List<string> texts = new List<string>();
  2844. foreach (var item in _AirTicketReservations)
  2845. {
  2846. string[] FlightsCode = item.FlightsCode.Split('/');
  2847. if (FlightsCode.Length != 0)
  2848. {
  2849. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2850. if (_AirCompany != null)
  2851. {
  2852. if (!transDic.ContainsKey(_AirCompany.CnName))
  2853. {
  2854. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2855. }
  2856. }
  2857. else
  2858. {
  2859. if (!transDic.ContainsKey("--"))
  2860. {
  2861. transDic.Add("--", "--");
  2862. }
  2863. }
  2864. }
  2865. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2866. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2867. string name = "";
  2868. foreach (string clientName in nameArray)
  2869. {
  2870. name += clientName + ",";
  2871. }
  2872. if (!texts.Contains(name))
  2873. {
  2874. texts.Add(name);
  2875. }
  2876. List<AirInfo> airs = new List<AirInfo>();
  2877. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2878. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2879. for (int i = 0; i < FlightsCode.Length; i++)
  2880. {
  2881. AirInfo air = new AirInfo();
  2882. string[] tempstr = DayArray[i]
  2883. .Replace("\r\n", string.Empty)
  2884. .Replace("\\r\\n", string.Empty)
  2885. .TrimStart().TrimEnd()
  2886. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2887. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2888. if (star_Three != null)
  2889. {
  2890. if (!transDic.ContainsKey(star_Three.AirPort))
  2891. {
  2892. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2893. }
  2894. }
  2895. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2896. if (End_Three != null)
  2897. {
  2898. if (!transDic.ContainsKey(End_Three.AirPort))
  2899. {
  2900. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2901. }
  2902. }
  2903. if (!texts.Contains(item.CTypeName))
  2904. {
  2905. texts.Add(item.CTypeName);
  2906. }
  2907. }
  2908. }
  2909. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2910. if (transData.Count > 0)
  2911. {
  2912. foreach (TranslateResult item in transData)
  2913. {
  2914. if (!transDic.ContainsKey(item.Query))
  2915. {
  2916. transDic.Add(item.Query, item.Translation);
  2917. }
  2918. }
  2919. }
  2920. foreach (var item in _AirTicketReservations)
  2921. {
  2922. #region 处理固定数据
  2923. string[] FlightsCode = item.FlightsCode.Split('/');
  2924. if (FlightsCode.Length != 0)
  2925. {
  2926. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2927. if (_AirCompany != null)
  2928. {
  2929. string str = "--";
  2930. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2931. if (!string.IsNullOrEmpty(translateResult))
  2932. {
  2933. str = translateResult;
  2934. str = _airTicketResRep.Processing(str);
  2935. }
  2936. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2937. }
  2938. else
  2939. {
  2940. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2941. }
  2942. }
  2943. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2944. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2945. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2946. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2947. string names = "";
  2948. foreach (string clientName in nameArray)
  2949. {
  2950. names += clientName + ",";
  2951. }
  2952. if (!string.IsNullOrWhiteSpace(names))
  2953. {
  2954. string str = "--";
  2955. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2956. if (!string.IsNullOrEmpty(translateResult))
  2957. {
  2958. str = translateResult;
  2959. str = _airTicketResRep.Processing(str);
  2960. }
  2961. table.Range.Bookmarks["ClientName"].Text = str;
  2962. }
  2963. else
  2964. {
  2965. table.Range.Bookmarks["ClientName"].Text = "--";
  2966. }
  2967. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2968. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2969. table.Range.Bookmarks["JointTicket"].Text = "--";
  2970. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2971. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2972. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2973. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2974. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2975. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2976. #endregion
  2977. #region 循环数据处理
  2978. List<AirInfo> airs = new List<AirInfo>();
  2979. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2980. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2981. for (int i = 0; i < FlightsCode.Length; i++)
  2982. {
  2983. AirInfo air = new AirInfo();
  2984. string[] tempstr = DayArray[i]
  2985. .Replace("\r\n", string.Empty)
  2986. .Replace("\\r\\n", string.Empty)
  2987. .TrimStart().TrimEnd()
  2988. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2989. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2990. string starCity = "";
  2991. if (star_Three != null)
  2992. {
  2993. string str2 = "--";
  2994. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2995. if (!string.IsNullOrEmpty(translateResult2))
  2996. {
  2997. str2 = translateResult2;
  2998. str2 = _airTicketResRep.Processing(str2);
  2999. }
  3000. starCity = str2;
  3001. }
  3002. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3003. string EndCity = "";
  3004. if (End_Three != null)
  3005. {
  3006. string str1 = "--";
  3007. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3008. if (!string.IsNullOrEmpty(translateResult1))
  3009. {
  3010. str1 = translateResult1;
  3011. str1 = _airTicketResRep.Processing(str1);
  3012. }
  3013. EndCity = str1;
  3014. }
  3015. air.Destination = starCity + "/" + EndCity;
  3016. air.Flight = FlightsCode[i];
  3017. string str = "--";
  3018. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3019. if (!string.IsNullOrEmpty(translateResult))
  3020. {
  3021. str = translateResult;
  3022. str = _airTicketResRep.Processing(str);
  3023. }
  3024. air.SeatingClass = str;
  3025. string dateTime = tempstr[2];
  3026. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3027. air.FlightDate = DateTemp;
  3028. air.DepartureTime = tempstr[5];
  3029. air.LandingTime = tempstr[6];
  3030. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3031. air.TicketStatus = "--";
  3032. air.Luggage = "--";
  3033. air.DepartureTerminal = "--";
  3034. air.LandingTerminal = "--";
  3035. airs.Add(air);
  3036. }
  3037. int row = 13;
  3038. for (int i = 0; i < airs.Count; i++)
  3039. {
  3040. if (airs.Count > 2)
  3041. {
  3042. for (int j = 0; j < airs.Count - 2; j++)
  3043. {
  3044. var CopyRow = table.Rows[12].Clone(true);
  3045. table.Rows.Add(CopyRow);
  3046. }
  3047. }
  3048. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3049. int index = 0;
  3050. foreach (PropertyInfo property in properties)
  3051. {
  3052. string value = property.GetValue(airs[i]).ToString();
  3053. Cell ishcel0 = table.Rows[row].Cells[index];
  3054. Paragraph p = new Paragraph(doc);
  3055. string s = value;
  3056. p.AppendChild(new Run(doc, s));
  3057. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3058. ishcel0.AppendChild(p);
  3059. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3060. //ishcel0.CellFormat.VerticalAlignment=
  3061. index++;
  3062. }
  3063. row++;
  3064. }
  3065. #endregion
  3066. Paragraph lastParagraph = new Paragraph(doc);
  3067. //第一个表格末尾加段落
  3068. table.ParentNode.InsertAfter(lastParagraph, table);
  3069. //复制第一个表格
  3070. Table cloneTable = (Table)table.Clone(true);
  3071. //在文档末尾段落后面加入复制的表格
  3072. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3073. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3074. {
  3075. int rownewsIndex = 13;
  3076. for (int i = 0; i < 2; i++)
  3077. {
  3078. var CopyRow = table.Rows[12].Clone(true);
  3079. table.Rows.RemoveAt(13);
  3080. table.Rows.Add(CopyRow);
  3081. rownewsIndex++;
  3082. }
  3083. }
  3084. else
  3085. {
  3086. table.Rows.RemoveAt(12);
  3087. }
  3088. cloneTable.Rows.RemoveAt(12);
  3089. }
  3090. if (_AirTicketReservations.Count != 0)
  3091. {
  3092. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3093. if (FlightsCode.Length != 0)
  3094. {
  3095. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3096. if (_AirCompany != null)
  3097. {
  3098. string str = "--";
  3099. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3100. if (!string.IsNullOrEmpty(translateResult))
  3101. {
  3102. str = translateResult;
  3103. str = _airTicketResRep.Processing(str);
  3104. }
  3105. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3106. }
  3107. else
  3108. {
  3109. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3110. }
  3111. }
  3112. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3113. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3114. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3115. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3116. string names = "";
  3117. foreach (string clientName in nameArray)
  3118. {
  3119. names += clientName + ",";
  3120. }
  3121. if (!string.IsNullOrWhiteSpace(names))
  3122. {
  3123. string str = "--";
  3124. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3125. if (!string.IsNullOrEmpty(translateResult))
  3126. {
  3127. str = translateResult;
  3128. str = _airTicketResRep.Processing(str);
  3129. }
  3130. table.Range.Bookmarks["ClientName"].Text = str;
  3131. }
  3132. else
  3133. {
  3134. table.Range.Bookmarks["ClientName"].Text = "--";
  3135. }
  3136. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3137. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3138. table.Range.Bookmarks["JointTicket"].Text = "--";
  3139. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3140. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3141. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3142. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3143. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3144. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3145. }
  3146. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3147. //保存合并后的文档
  3148. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3149. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3150. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3151. return Ok(JsonView(true, "成功!", rst));
  3152. }
  3153. }
  3154. }
  3155. catch (Exception ex)
  3156. {
  3157. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3158. throw;
  3159. }
  3160. }
  3161. #endregion
  3162. #region 团组增减款项 --> 其他款项
  3163. /// <summary>
  3164. /// 团组增减款项下拉框绑定
  3165. /// </summary>
  3166. /// <param name="dto"></param>
  3167. /// <returns></returns>
  3168. [HttpPost]
  3169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3170. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3171. {
  3172. #region 参数验证
  3173. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3174. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3175. #endregion
  3176. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3177. }
  3178. /// <summary>
  3179. /// 根据团组Id查询团组增减款项
  3180. /// </summary>
  3181. /// <param name="dto"></param>
  3182. /// <returns></returns>
  3183. [HttpPost]
  3184. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3185. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3186. {
  3187. #region 参数验证
  3188. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3189. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3190. #endregion
  3191. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3192. }
  3193. /// <summary>
  3194. /// 团组增减款项操作(Status:1.新增,2.修改)
  3195. /// </summary>
  3196. /// <param name="dto"></param>
  3197. /// <returns></returns>
  3198. [HttpPost]
  3199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3200. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3201. {
  3202. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3203. if (groupData.Code != 200)
  3204. {
  3205. return Ok(JsonView(false, groupData.Msg));
  3206. }
  3207. #region 应用推送
  3208. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3209. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3210. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3211. //2024-10-21 新增LZ UID
  3212. var userIds = new List<int>() { 21 };
  3213. string title = $"系统通知";
  3214. string content = "";
  3215. var diId = dto.DiId;
  3216. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3217. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3218. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3219. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3220. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3221. #endregion
  3222. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3223. }
  3224. /// <summary>
  3225. /// 团组增减款项操作 删除
  3226. /// </summary>
  3227. /// <param name="dto"></param>
  3228. /// <returns></returns>
  3229. [HttpPost]
  3230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3231. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3232. {
  3233. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3234. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3235. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3236. if (res.Code == 0)
  3237. {
  3238. return Ok(JsonView(true, "删除成功!"));
  3239. }
  3240. return Ok(JsonView(false, "删除失败!"));
  3241. }
  3242. /// <summary>
  3243. /// 根据团组增减款项Id查询
  3244. /// </summary>
  3245. /// <param name="dto"></param>
  3246. /// <returns></returns>
  3247. [HttpPost]
  3248. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3249. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3250. {
  3251. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3252. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3253. }
  3254. /// <summary>
  3255. /// 查询供应商名称
  3256. /// </summary>
  3257. /// <param name="dto"></param>
  3258. /// <returns></returns>
  3259. [HttpPost]
  3260. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3261. {
  3262. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3263. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3264. ?? new List<Grp_DecreasePayments>();
  3265. dbResult = dbResult.Distinct(new
  3266. ProductComparer()).ToList();
  3267. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3268. {
  3269. x.Id,
  3270. x.SupplierAddress,
  3271. x.SupplierArea,
  3272. x.SupplierContact,
  3273. x.SupplierContactNumber,
  3274. x.SupplierEmail,
  3275. x.SupplierName,
  3276. x.SupplierSocialAccount,
  3277. x.SupplierTypeId,
  3278. }).ToList());
  3279. return Ok(jw);
  3280. }
  3281. /// <summary>
  3282. /// 团组增减款项 OTA匹配
  3283. /// </summary>
  3284. /// <param name="file"></param>
  3285. /// <returns></returns>
  3286. [HttpPost]
  3287. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3288. {
  3289. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3290. string fileName = file.FileName;
  3291. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3292. {
  3293. return Ok(JsonView(false, "请上传Excel文件!"));
  3294. }
  3295. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3296. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3297. if (!Directory.Exists(path))
  3298. {
  3299. Directory.CreateDirectory(path);
  3300. }
  3301. var filePath = @$"{path}/{fileName}";
  3302. //保存文件
  3303. using (FileStream fs = System.IO.File.Create(filePath))
  3304. {
  3305. file.CopyTo(fs);
  3306. fs.Flush();
  3307. }
  3308. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3309. //读取ExcelFile
  3310. DataTable dt = ConvertExcelToDataTable(filePath);
  3311. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3312. dt.TableName = "TB";
  3313. //修改table列名
  3314. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3315. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3316. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3317. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3318. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3319. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3320. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3321. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3322. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3323. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3324. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3325. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3326. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3327. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3328. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3329. var otaOrderNos = new List<string>();
  3330. foreach (DataRow item in dt.Rows)
  3331. {
  3332. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3333. }
  3334. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3335. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3336. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3337. .Select((dp, di) => new
  3338. {
  3339. dp.PriceName,
  3340. dp.OTAOrderNo,
  3341. dp.FeeTotal,
  3342. di.TeamName,
  3343. })
  3344. .ToListAsync();
  3345. foreach (DataRow item in dt.Rows)
  3346. {
  3347. var otaOrderNo = item["OTAOrderNo"].ToString();
  3348. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3349. if (oaData == null) continue;
  3350. item["GroupName"] = oaData.TeamName;
  3351. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3352. }
  3353. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3354. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3355. List<DataTable> datas = new List<DataTable>();
  3356. datas.Add(dt);
  3357. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3358. return Ok(JsonView(true, "操作成功", new { url = url }));
  3359. }
  3360. #region
  3361. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3362. {
  3363. // 创建Workbook对象
  3364. Workbook workbook = new Workbook(excelFilePath);
  3365. // 获取第一个工作表
  3366. Worksheet worksheet = workbook.Worksheets[0];
  3367. // 将工作表转换为DataTable
  3368. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3369. return dataTable;
  3370. }
  3371. #endregion
  3372. #endregion
  3373. #region 文件上传、删除
  3374. /// <summary>
  3375. /// region 文件上传 可以带参数
  3376. /// </summary>
  3377. /// <param name="file"></param>
  3378. /// <returns></returns>
  3379. [HttpPost]
  3380. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3381. public async Task<IActionResult> UploadProject(IFormFile file)
  3382. {
  3383. //var TypeName = Request.Headers["TypeName"].ToString();
  3384. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3385. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3386. ////文件名称
  3387. //string projectFileName = file.FileName;
  3388. ////上传的文件的路径
  3389. //string filePath = $"{fileDir}/{projectFileName}";
  3390. //if (TypeName == "A")//A代表团组增减款项
  3391. //{
  3392. // filePath = fileDir + $@"\团组增减款项相关文件";
  3393. // if (!Directory.Exists(filePath))
  3394. // {
  3395. // Directory.CreateDirectory(filePath);
  3396. // }
  3397. // //上传的文件的路径
  3398. // filePath += $@"\{projectFileName}";
  3399. //}
  3400. //else if (TypeName == "B")//B代表商邀相关文件
  3401. //{
  3402. // //上传的文件的路径
  3403. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3404. // if (!Directory.Exists(filePath))
  3405. // {
  3406. // Directory.CreateDirectory(filePath);
  3407. // }
  3408. // //上传的文件的路径
  3409. // filePath = $@"\{projectFileName}";
  3410. //}
  3411. //try
  3412. //{
  3413. // using (FileStream fs = System.IO.File.Create(filePath))
  3414. // {
  3415. // file.CopyTo(fs);
  3416. // fs.Flush();
  3417. // }
  3418. //}
  3419. //catch (Exception ex)
  3420. //{
  3421. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3422. //}
  3423. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3424. try
  3425. {
  3426. var TypeName = Request.Headers["TypeName"].ToString();
  3427. if (file != null)
  3428. {
  3429. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3430. //文件名称
  3431. string projectFileName = file.FileName;
  3432. //上传的文件的路径
  3433. string filePath = $"{fileDir}/{projectFileName}";
  3434. if (TypeName == "A")//A代表团组增减款项
  3435. {
  3436. if (!Directory.Exists(fileDir))
  3437. {
  3438. Directory.CreateDirectory(fileDir);
  3439. }
  3440. //上传的文件的路径
  3441. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3442. }
  3443. else if (TypeName == "B")//B代表商邀相关文件
  3444. {
  3445. if (!Directory.Exists(fileDir))
  3446. {
  3447. Directory.CreateDirectory(fileDir);
  3448. }
  3449. //上传的文件的路径
  3450. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3451. }
  3452. using (FileStream fs = System.IO.File.Create(filePath))
  3453. {
  3454. file.CopyTo(fs);
  3455. fs.Flush();
  3456. }
  3457. return Ok(JsonView(true, "上传成功!", projectFileName));
  3458. }
  3459. else
  3460. {
  3461. return Ok(JsonView(false, "上传失败!"));
  3462. }
  3463. }
  3464. catch (Exception ex)
  3465. {
  3466. return Ok(JsonView(false, "程序错误!"));
  3467. }
  3468. }
  3469. /// <summary>
  3470. /// 删除指定文件
  3471. /// </summary>
  3472. /// <param name="dto"></param>
  3473. /// <returns></returns>
  3474. [HttpPost]
  3475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3476. public async Task<IActionResult> DelFile(DelFileDto dto)
  3477. {
  3478. try
  3479. {
  3480. var TypeName = Request.Headers["TypeName"].ToString();
  3481. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3482. string filePath = "";
  3483. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3484. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3485. int id = 0;
  3486. if (TypeName == "A")
  3487. {
  3488. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3489. // 删除该文件
  3490. System.IO.File.Delete(filePath);
  3491. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3492. .Where(a => a.Id == dto.Id)
  3493. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3494. .ExecuteCommandAsync();
  3495. }
  3496. else if (TypeName == "B")
  3497. {
  3498. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3499. // 删除该文件
  3500. System.IO.File.Delete(filePath);
  3501. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3502. if (info != null)
  3503. {
  3504. string[] files = new string[] { };
  3505. if (!string.IsNullOrEmpty(info.Attachment))
  3506. {
  3507. try
  3508. {
  3509. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3510. }
  3511. catch (Exception)
  3512. {
  3513. files = new List<string>() { info.Attachment }.ToArray();
  3514. }
  3515. }
  3516. if (files.Length > 0)
  3517. {
  3518. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3519. string filePath2 = string.Empty;
  3520. if (files1.Length > 0)
  3521. {
  3522. filePath2 = JsonConvert.SerializeObject( files1);
  3523. }
  3524. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3525. .Where(a => a.Id == dto.Id)
  3526. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3527. .ExecuteCommandAsync();
  3528. }
  3529. }
  3530. }
  3531. if (id != 0)
  3532. {
  3533. return Ok(JsonView(true, "成功!"));
  3534. }
  3535. else
  3536. {
  3537. return Ok(JsonView(false, "失败!"));
  3538. }
  3539. }
  3540. catch (Exception ex)
  3541. {
  3542. return Ok(JsonView(false, "程序错误!"));
  3543. throw;
  3544. }
  3545. }
  3546. /// <summary>
  3547. /// 文件上传多个文件 可以带参数
  3548. /// </summary>
  3549. /// <param name="file"></param>
  3550. /// <returns></returns>
  3551. [HttpPost]
  3552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3553. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3554. {
  3555. try
  3556. {
  3557. var TypeName = Request.Headers["TypeName"].ToString();
  3558. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3559. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3560. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3561. var filePahts = new List<string>();
  3562. foreach (var file in files)
  3563. {
  3564. //文件名称
  3565. string projectFileName = file.FileName;
  3566. //上传的文件的路径
  3567. string filePath = $"{fileDir}/{projectFileName}";
  3568. if (TypeName == "A")//A代表团组增减款项
  3569. {
  3570. if (!Directory.Exists(fileDir))
  3571. {
  3572. Directory.CreateDirectory(fileDir);
  3573. }
  3574. //上传的文件的路径
  3575. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3576. }
  3577. else if (TypeName == "B")//B代表商邀相关文件
  3578. {
  3579. if (!Directory.Exists(fileDir))
  3580. {
  3581. Directory.CreateDirectory(fileDir);
  3582. }
  3583. //上传的文件的路径
  3584. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3585. }
  3586. using (FileStream fs = System.IO.File.Create(filePath))
  3587. {
  3588. file.CopyTo(fs);
  3589. fs.Flush();
  3590. }
  3591. filePahts.Add(projectFileName);
  3592. }
  3593. return Ok(JsonView(true, "上传成功!", filePahts));
  3594. }
  3595. catch (Exception ex)
  3596. {
  3597. return Ok(JsonView(false, "程序错误!"));
  3598. }
  3599. }
  3600. #endregion
  3601. #region 商邀费用录入
  3602. /// <summary>
  3603. /// 根据团组Id查询商邀费用列表
  3604. /// </summary>
  3605. /// <param name="dto"></param>
  3606. /// <returns></returns>
  3607. [HttpPost]
  3608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3609. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3610. {
  3611. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3612. if (groupData.Code != 0)
  3613. {
  3614. return Ok(JsonView(false, groupData.Msg));
  3615. }
  3616. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3617. }
  3618. /// <summary>
  3619. /// 商邀费用列表
  3620. /// 下载文件
  3621. /// </summary>
  3622. /// <param name="dto"></param>
  3623. /// <returns></returns>
  3624. [HttpGet("{id}")]
  3625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3626. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3627. {
  3628. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3629. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3630. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3631. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3632. var filePaths = new List<string>();
  3633. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3634. try
  3635. {
  3636. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3637. }
  3638. catch (Exception ex)
  3639. {
  3640. filePaths.Add(info.Attachment);
  3641. }
  3642. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3643. for (int i = 0; i < filePaths.Count; i++)
  3644. {
  3645. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3646. }
  3647. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3648. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3649. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3650. {
  3651. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3652. {
  3653. foreach (string filePath in filePaths)
  3654. {
  3655. if (System.IO.File.Exists(filePath))
  3656. {
  3657. // 获取文件名
  3658. string fileName = Path.GetFileName(filePath);
  3659. // 将文件添加到ZIP归档中
  3660. zipArchive.CreateEntryFromFile(filePath, fileName);
  3661. }
  3662. }
  3663. }
  3664. }
  3665. return Ok(JsonView(new {url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3666. }
  3667. /// <summary>
  3668. /// 商邀费用 Info Page 基础数据源
  3669. /// </summary>
  3670. /// <param name="dto"></param>
  3671. /// <returns></returns>
  3672. [HttpPost]
  3673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3674. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3675. {
  3676. try
  3677. {
  3678. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3679. if (groupData.Code != 0)
  3680. {
  3681. return Ok(JsonView(false, groupData.Msg));
  3682. }
  3683. return Ok(JsonView(true, "操作成功", groupData.Data));
  3684. }
  3685. catch (Exception ex)
  3686. {
  3687. return Ok(JsonView(false, ex.Message));
  3688. throw;
  3689. }
  3690. }
  3691. /// <summary>
  3692. /// 根据商邀费用ID查询C表和商邀费用数据
  3693. /// </summary>
  3694. /// <param name="dto"></param>
  3695. /// <returns></returns>
  3696. [HttpPost]
  3697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3698. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3699. {
  3700. try
  3701. {
  3702. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3703. if (groupData.Code != 0)
  3704. {
  3705. return Ok(JsonView(false, groupData.Msg));
  3706. }
  3707. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3708. }
  3709. catch (Exception ex)
  3710. {
  3711. return Ok(JsonView(false, ex.Message));
  3712. throw;
  3713. }
  3714. }
  3715. /// <summary>
  3716. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3717. /// </summary>
  3718. /// <param name="dto"></param>
  3719. /// <returns></returns>
  3720. [HttpPost]
  3721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3722. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3723. {
  3724. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3725. if (groupData.Code != 0)
  3726. {
  3727. return Ok(JsonView(false, groupData.Msg));
  3728. }
  3729. #region 应用推送
  3730. try
  3731. {
  3732. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3733. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3734. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3735. //2024-10-21 新增LZ UID
  3736. var userIds = new List<int>() { 21 };
  3737. string title = $"系统通知";
  3738. string content = "";
  3739. var diId = dto.DiId;
  3740. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3741. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3742. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3743. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3744. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3745. }
  3746. catch (Exception ex)
  3747. {
  3748. }
  3749. #endregion
  3750. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3751. }
  3752. /// <summary>
  3753. /// 商邀删除
  3754. /// </summary>
  3755. /// <param name="dto"></param>
  3756. /// <returns></returns>
  3757. [HttpPost]
  3758. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3759. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3760. {
  3761. try
  3762. {
  3763. _sqlSugar.BeginTran();
  3764. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3765. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3766. {
  3767. IsDel = 1,
  3768. DeleteUserId = dto.DeleteUserId,
  3769. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3770. })
  3771. .Where(it => it.Id == dto.Id)
  3772. .ExecuteCommand();
  3773. if (res1 > 0)
  3774. {
  3775. int _diId = 0;
  3776. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3777. if (_ioaInfo != null)
  3778. {
  3779. _diId = _ioaInfo.DiId;
  3780. }
  3781. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3782. .SetColumns(a => new Grp_CreditCardPayment()
  3783. {
  3784. IsDel = 1,
  3785. DeleteUserId = dto.DeleteUserId,
  3786. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3787. })
  3788. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3789. .ExecuteCommand();
  3790. if (res2 > 0)
  3791. {
  3792. _sqlSugar.CommitTran();
  3793. return Ok(JsonView(true, "删除成功!"));
  3794. }
  3795. }
  3796. _sqlSugar.RollbackTran();
  3797. return Ok(JsonView(false, "删除失败"));
  3798. }
  3799. catch (Exception ex)
  3800. {
  3801. _sqlSugar.RollbackTran();
  3802. return Ok(JsonView(false, ex.Message));
  3803. }
  3804. }
  3805. /// <summary>
  3806. /// 团组模块文件上传
  3807. /// </summary>
  3808. /// <param name="dto"></param>
  3809. /// <returns></returns>
  3810. [HttpPost]
  3811. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3812. {
  3813. var jw = JsonView(false);
  3814. long M = 1024 * 1024;
  3815. if (dto.Files == null || dto.Files.Count == 0)
  3816. {
  3817. jw.Msg = "无文件信息!";
  3818. return Ok(jw);
  3819. }
  3820. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3821. {
  3822. jw.Msg = "文件大小超过20M!";
  3823. return Ok(jw);
  3824. }
  3825. //var nameSp = dto.File.FileName.Split(".");
  3826. //if (nameSp.Length < 2)
  3827. //{
  3828. // jw.Msg = "拓展名称有误!";
  3829. // return Ok(jw);
  3830. //}
  3831. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3832. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3833. //{
  3834. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3835. // return Ok(jw);
  3836. //}
  3837. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3838. if (Ctable == null)
  3839. {
  3840. jw.Msg = "Ctable指向有误!";
  3841. return Ok(jw);
  3842. }
  3843. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3844. if (groupInfo == null)
  3845. {
  3846. jw.Msg = "团组信息不存在!";
  3847. return Ok(jw);
  3848. }
  3849. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3850. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3851. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3852. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3853. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3854. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3855. try
  3856. {
  3857. if (!Directory.Exists(fileBase))
  3858. {
  3859. Directory.CreateDirectory(fileBase);
  3860. }
  3861. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3862. foreach (var fileStream in dto.Files)
  3863. {
  3864. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3865. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3866. {
  3867. Cid = dto.Cid,
  3868. CreateTime = DateTime.Now,
  3869. CreateUserId = dto.Userid,
  3870. Ctable = dto.Ctable,
  3871. Diid = dto.Diid,
  3872. IsDel = 0,
  3873. FilePath = saveFilePath,
  3874. FileName = fileStream.FileName
  3875. };
  3876. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3877. {
  3878. fileStream.CopyTo(fs);
  3879. fs.Flush();
  3880. }
  3881. saveArr.Add(file);
  3882. }
  3883. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3884. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3885. jw = JsonView(true, "保存成功!", new
  3886. {
  3887. count = addResult,
  3888. filesName = saveArr.Select(x => x.FileName)
  3889. });
  3890. }
  3891. catch (Exception ex)
  3892. {
  3893. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3894. {
  3895. count = 0,
  3896. filesName = new string[0],
  3897. });
  3898. }
  3899. return Ok(jw);
  3900. }
  3901. /// <summary>
  3902. /// 查询各模块已保存文件
  3903. /// </summary>
  3904. /// <param name="dto"></param>
  3905. /// <returns></returns>
  3906. [HttpPost]
  3907. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3908. {
  3909. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3910. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3911. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3912. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3913. {
  3914. expression = Expressionable.Create<Grp_GroupModelFile>()
  3915. .And(x => visaIds.Contains(x.CreateUserId));
  3916. }
  3917. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3918. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3919. .Where(expression.ToExpression())
  3920. .ToList();
  3921. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3922. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3923. {
  3924. x.FileName,
  3925. x.Id,
  3926. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3927. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3928. })));
  3929. }
  3930. /// <summary>
  3931. /// 下载该团组下的所有文件
  3932. /// </summary>
  3933. /// <param name="dto"></param>
  3934. /// <returns></returns>
  3935. [HttpPost]
  3936. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3937. {
  3938. var jw = JsonView(false);
  3939. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3940. if (groupInfo == null)
  3941. {
  3942. jw.Msg = "团组信息不存在!";
  3943. return Ok(jw);
  3944. }
  3945. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3946. var isModule = Convert.ToBoolean(dto.isModule);
  3947. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3948. IOOperatorHelper io = new IOOperatorHelper();
  3949. if (isModule)
  3950. {
  3951. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3952. foreach (var moduleArr in moduleGroup)
  3953. {
  3954. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3955. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3956. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3957. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3958. foreach (var item in moduleArr)
  3959. {
  3960. if (System.IO.File.Exists(item.FilePath))
  3961. {
  3962. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3963. {
  3964. byte[] bytes = new byte[fileStream.Length];
  3965. fileStream.Read(bytes, 0, bytes.Length);
  3966. fileStream.Close();
  3967. Stream stream = new MemoryStream(bytes);
  3968. chiZips.Add(item.FileName, stream);
  3969. }
  3970. }
  3971. }
  3972. if (chiZips.Count > 0)
  3973. {
  3974. var byts = io.ConvertZipStream(chiZips);
  3975. Stream stream = new MemoryStream(byts);
  3976. Zips.Add(key.Name + "_.zip", stream);
  3977. }
  3978. }
  3979. }
  3980. else
  3981. {
  3982. foreach (var item in dbQuery)
  3983. {
  3984. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3985. {
  3986. byte[] bytes = new byte[fileStream.Length];
  3987. fileStream.Read(bytes, 0, bytes.Length);
  3988. fileStream.Close();
  3989. Stream stream = new MemoryStream(bytes);
  3990. while (Zips.Keys.Contains(item.FileName))
  3991. {
  3992. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3993. }
  3994. Zips.Add(item.FileName, stream);
  3995. }
  3996. }
  3997. }
  3998. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3999. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4000. if (Zips.Count > 0)
  4001. {
  4002. var byts = io.ConvertZipStream(Zips);
  4003. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4004. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4005. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4006. }
  4007. else
  4008. {
  4009. jw.Msg = "暂无生成文件!";
  4010. }
  4011. return Ok(jw);
  4012. }
  4013. /// <summary>
  4014. /// 下载该团组下此模块的所有文件
  4015. /// </summary>
  4016. /// <param name="dto"></param>
  4017. /// <returns></returns>
  4018. [HttpPost]
  4019. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4020. {
  4021. var jw = JsonView(false);
  4022. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4023. if (groupInfo == null)
  4024. {
  4025. jw.Msg = "团组信息不存在!";
  4026. return Ok(jw);
  4027. }
  4028. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4029. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4030. && x.IsDel == 0);
  4031. if (key == null)
  4032. {
  4033. jw.Msg = "Ctable指向错误!";
  4034. return Ok(jw);
  4035. }
  4036. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4037. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4038. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4039. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4040. IOOperatorHelper io = new IOOperatorHelper();
  4041. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4042. foreach (var item in dbQuery)
  4043. {
  4044. if (System.IO.File.Exists(item.FilePath))
  4045. {
  4046. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4047. {
  4048. byte[] bytes = new byte[fileStream.Length];
  4049. fileStream.Read(bytes, 0, bytes.Length);
  4050. fileStream.Close();
  4051. Stream stream = new MemoryStream(bytes);
  4052. while (Zips.Keys.Contains(item.FileName))
  4053. {
  4054. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4055. }
  4056. Zips.Add(item.FileName, stream);
  4057. }
  4058. }
  4059. }
  4060. if (Zips.Count > 0)
  4061. {
  4062. var byts = io.ConvertZipStream(Zips);
  4063. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4064. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4065. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4066. }
  4067. else
  4068. {
  4069. jw.Msg = "暂无生成文件!";
  4070. }
  4071. return Ok(jw);
  4072. }
  4073. /// <summary>
  4074. /// 删除该团组下的指定文件
  4075. /// </summary>
  4076. /// <param name="dto"></param>
  4077. /// <returns></returns>
  4078. [HttpPost]
  4079. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4080. {
  4081. var jw = JsonView(false);
  4082. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4083. if (sing == null)
  4084. {
  4085. jw.Msg = "暂无";
  4086. return Ok(jw);
  4087. }
  4088. if (System.IO.File.Exists(sing.FilePath))
  4089. {
  4090. try
  4091. {
  4092. System.IO.File.Delete(sing.FilePath);
  4093. }
  4094. catch (Exception ex)
  4095. {
  4096. jw.Msg = "删除失败!" + ex.Message;
  4097. return Ok(jw);
  4098. }
  4099. }
  4100. sing.IsDel = 1;
  4101. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4102. sing.DeleteUserId = dto.UserId;
  4103. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4104. jw = JsonView(true, "删除成功!");
  4105. return Ok(jw);
  4106. }
  4107. #endregion
  4108. #region 团组英文资料
  4109. /// <summary>
  4110. /// 查询团组英文所有资料
  4111. /// </summary>
  4112. /// <param name="dto"></param>
  4113. /// <returns></returns>
  4114. [HttpPost]
  4115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4116. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4117. {
  4118. try
  4119. {
  4120. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4121. if (groupData.Code != 0)
  4122. {
  4123. return Ok(JsonView(false, groupData.Msg));
  4124. }
  4125. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4126. }
  4127. catch (Exception ex)
  4128. {
  4129. return Ok(JsonView(false, "程序错误!"));
  4130. throw;
  4131. }
  4132. }
  4133. /// <summary>
  4134. /// 团组英文资料操作(Status:1.新增,2.修改)
  4135. /// </summary>
  4136. /// <param name="dto"></param>
  4137. /// <returns></returns>
  4138. [HttpPost]
  4139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4140. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4141. {
  4142. try
  4143. {
  4144. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4145. if (groupData.Code != 0)
  4146. {
  4147. return Ok(JsonView(false, groupData.Msg));
  4148. }
  4149. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4150. }
  4151. catch (Exception ex)
  4152. {
  4153. return Ok(JsonView(false, "程序错误!"));
  4154. throw;
  4155. }
  4156. }
  4157. /// <summary>
  4158. /// 团组英文资料Id查询数据
  4159. /// </summary>
  4160. /// <param name="dto"></param>
  4161. /// <returns></returns>
  4162. [HttpPost]
  4163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4164. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4165. {
  4166. try
  4167. {
  4168. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4169. if (_DelegationEnData != null)
  4170. {
  4171. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4172. }
  4173. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4174. }
  4175. catch (Exception ex)
  4176. {
  4177. return Ok(JsonView(false, "程序错误!"));
  4178. throw;
  4179. }
  4180. }
  4181. /// <summary>
  4182. /// 团组英文资料删除
  4183. /// </summary>
  4184. /// <param name="dto"></param>
  4185. /// <returns></returns>
  4186. [HttpPost]
  4187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4188. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4189. {
  4190. try
  4191. {
  4192. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4193. if (!res)
  4194. {
  4195. return Ok(JsonView(false, "删除失败"));
  4196. }
  4197. return Ok(JsonView(true, "删除成功!"));
  4198. }
  4199. catch (Exception ex)
  4200. {
  4201. return Ok(JsonView(false, "程序错误!"));
  4202. throw;
  4203. }
  4204. }
  4205. #endregion
  4206. #region 导出邀请函
  4207. /// <summary>
  4208. /// 导出邀请函页面初始化
  4209. /// </summary>
  4210. /// <param name="dto"></param>
  4211. /// <returns></returns>
  4212. [HttpPost]
  4213. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4214. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4215. {
  4216. try
  4217. {
  4218. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4219. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4220. if (dto.DiId == 0)
  4221. {
  4222. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4223. }
  4224. else
  4225. {
  4226. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4227. }
  4228. return Ok(JsonView(true, "查询成功!", new
  4229. {
  4230. deleClient = crm_Deles,
  4231. delegations = grp_Delegations
  4232. }));
  4233. }
  4234. catch (Exception ex)
  4235. {
  4236. return Ok(JsonView(false, "程序错误!"));
  4237. throw;
  4238. }
  4239. }
  4240. /// <summary>
  4241. /// 导出邀请函
  4242. /// </summary>
  4243. /// <param name="dto"></param>
  4244. /// <returns></returns>
  4245. [HttpPost]
  4246. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4247. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4248. {
  4249. #region 参数验证
  4250. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4251. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4252. #endregion
  4253. try
  4254. {
  4255. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4256. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4257. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4258. From Grp_TourClientList tcl
  4259. Left Join
  4260. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4261. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4262. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4263. From Crm_DeleClient dc
  4264. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4265. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4266. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4267. Where dc.IsDel = 0) temp
  4268. On temp.DcId =tcl.ClientId
  4269. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4270. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4271. List<string> texts = new List<string>();
  4272. if (datas.Count != 0)
  4273. {
  4274. foreach (TourClientListDetailsView item in datas)
  4275. {
  4276. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4277. {
  4278. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4279. }
  4280. else
  4281. {
  4282. string name = item.LastName + item.FirstName;
  4283. texts.Add(name);
  4284. }
  4285. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4286. {
  4287. if (!transDic.ContainsKey(item.Job))
  4288. {
  4289. texts.Add(item.Job);
  4290. }
  4291. }
  4292. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4293. {
  4294. texts.Add(item.CompanyFullName);
  4295. }
  4296. }
  4297. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4298. if (transData.Count > 0)
  4299. {
  4300. foreach (TranslateResult item in transData)
  4301. {
  4302. if (!transDic.ContainsKey(item.Query))
  4303. {
  4304. transDic.Add(item.Query, item.Translation);
  4305. }
  4306. }
  4307. }
  4308. List<GuestList> list = new List<GuestList>();
  4309. foreach (TourClientListDetailsView dele in datas)
  4310. {
  4311. GuestList guestList = new GuestList();
  4312. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4313. {
  4314. guestList.Name = dele.Pinyin;
  4315. }
  4316. else
  4317. {
  4318. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4319. guestList.Name = Name;
  4320. }
  4321. if (dele.Sex == 0)
  4322. {
  4323. guestList.Sex = "Male";
  4324. }
  4325. else if (dele.Sex == 1)
  4326. {
  4327. guestList.Sex = "Female";
  4328. }
  4329. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4330. if (!string.IsNullOrEmpty(dele.Job))
  4331. {
  4332. guestList.Job = dele.Job;
  4333. }
  4334. list.Add(guestList);
  4335. }
  4336. //载入模板
  4337. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4338. DocumentBuilder builder = new DocumentBuilder(doc);
  4339. //获取word里所有表格
  4340. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4341. //获取所填表格的序数
  4342. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4343. var rowStart = tableOne.Rows[0]; //获取第1行
  4344. //循环赋值
  4345. for (int i = 0; i < list.Count; i++)
  4346. {
  4347. builder.MoveToCell(0, i + 1, 0, 0);
  4348. builder.Write(list[i].Name.ToString());
  4349. builder.MoveToCell(0, i + 1, 1, 0);
  4350. builder.Write(list[i].Sex.ToString());
  4351. builder.MoveToCell(0, i + 1, 2, 0);
  4352. builder.Write(list[i].DOB.ToString());
  4353. builder.MoveToCell(0, i + 1, 3, 0);
  4354. builder.Write(list[i].Job.ToString());
  4355. }
  4356. //删除多余行
  4357. while (tableOne.Rows.Count > list.Count + 1)
  4358. {
  4359. tableOne.Rows.RemoveAt(list.Count + 1);
  4360. }
  4361. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4362. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4363. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4364. doc.Save(filePath);
  4365. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4366. return Ok(JsonView(true, "操作成功!", Url));
  4367. }
  4368. else
  4369. {
  4370. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4371. }
  4372. }
  4373. catch (Exception ex)
  4374. {
  4375. return Ok(JsonView(false, ex.Message));
  4376. throw;
  4377. }
  4378. }
  4379. #endregion
  4380. #region 团组经理模块 出入境费用
  4381. ///// <summary>
  4382. ///// 团组模块 - 出入境费用
  4383. ///// </summary>
  4384. ///// <returns></returns>
  4385. //[HttpPost]
  4386. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4387. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  4388. //{
  4389. // try
  4390. // {
  4391. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  4392. // if (data.Code != 0)
  4393. // {
  4394. // return Ok(JsonView(false, data.Msg));
  4395. // }
  4396. // return Ok(JsonView(true, "查询成功!"));
  4397. // }
  4398. // catch (Exception ex)
  4399. // {
  4400. // return Ok(JsonView(false, ex.Message));
  4401. // throw;
  4402. // }
  4403. //}
  4404. /// <summary>
  4405. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4406. /// </summary>
  4407. /// <returns></returns>
  4408. [HttpPost]
  4409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4410. public async Task<IActionResult> SetDayAndCostAreaChange()
  4411. {
  4412. try
  4413. {
  4414. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4415. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4416. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4417. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4418. foreach (var item in unite) //处理交集数据
  4419. {
  4420. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4421. }
  4422. foreach (var item in merge) //处理差集数据
  4423. {
  4424. int nationalTravelFeeId = 0;
  4425. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4426. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4427. else
  4428. {
  4429. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4430. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4431. }
  4432. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4433. }
  4434. //只更新dayAndCost 的 nationalTravelFeeId;
  4435. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4436. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4437. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4438. }
  4439. catch (Exception ex)
  4440. {
  4441. return Ok(JsonView(false, ex.Message));
  4442. throw;
  4443. }
  4444. }
  4445. /// <summary>
  4446. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4447. /// </summary>
  4448. /// <returns></returns>
  4449. [HttpPost]
  4450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4451. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4452. {
  4453. try
  4454. {
  4455. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4456. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4457. //SetDataInfoView
  4458. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4459. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4460. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4461. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4462. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4463. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4464. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4465. //默认币种显示
  4466. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4467. {
  4468. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4469. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4470. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4471. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4472. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4473. };
  4474. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4475. if (_currencyRate.Count > 0)
  4476. {
  4477. foreach (var item in _currencyInfos)
  4478. {
  4479. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4480. if (rateInfo != null)
  4481. {
  4482. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4483. rate1 *= 1.035M;
  4484. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4485. }
  4486. }
  4487. }
  4488. return Ok(JsonView(true, "查询成功!", new
  4489. {
  4490. GroupNameData = groupNameData.Data,
  4491. CurrencyData = _CurrencyData,
  4492. WordTypeData = _WordTypeData,
  4493. ExcelTypeData = _ExcelTypeData,
  4494. CurrencyInit = _currencyInfos
  4495. }));
  4496. }
  4497. catch (Exception ex)
  4498. {
  4499. return Ok(JsonView(false, ex.Message));
  4500. throw;
  4501. }
  4502. }
  4503. /// <summary>
  4504. /// 团组模块 - 出入境费用
  4505. /// 实时汇率 tips
  4506. /// 签证费用 tips
  4507. /// </summary>
  4508. /// <returns></returns>
  4509. [HttpPost]
  4510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4511. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4512. {
  4513. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4514. //默认币种显示
  4515. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4516. {
  4517. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4518. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4519. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4520. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4521. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4522. };
  4523. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4524. List<dynamic> reteInfos = new List<dynamic>();
  4525. if (_currencyRate.Count > 0)
  4526. {
  4527. foreach (var item in _currencyInfos)
  4528. {
  4529. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4530. if (rateInfo != null)
  4531. {
  4532. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4533. decimal rate1 = item.Rate;
  4534. rate1 *= 1.03M;
  4535. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4536. reteInfos.Add(new
  4537. {
  4538. currCode = item.CurrencyCode,
  4539. currName = item.CurrencyName,
  4540. rate = rate2,
  4541. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4542. });
  4543. }
  4544. }
  4545. }
  4546. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4547. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4548. return Ok(JsonView(true, "查询成功!", new
  4549. {
  4550. //GroupNameData = groupNameData.Data,
  4551. visaData = visaData.Data,
  4552. airData = airData.Data,
  4553. reteInfos = reteInfos
  4554. }));
  4555. }
  4556. /// <summary>
  4557. /// 团组模块 - 出入境费用 - Info
  4558. /// </summary>
  4559. /// <returns></returns>
  4560. [HttpPost]
  4561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4562. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4563. {
  4564. try
  4565. {
  4566. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  4567. if (data.Code != 0)
  4568. {
  4569. return Ok(JsonView(false, data.Msg));
  4570. }
  4571. return Ok(JsonView(true, "查询成功!", data.Data));
  4572. }
  4573. catch (Exception ex)
  4574. {
  4575. return Ok(JsonView(false, ex.Message));
  4576. }
  4577. }
  4578. /// <summary>
  4579. /// 团组模块 - 出入境费用 - Add And Update
  4580. /// </summary>
  4581. /// <returns></returns>
  4582. [HttpPost]
  4583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4584. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4585. {
  4586. try
  4587. {
  4588. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4589. if (data.Code != 0)
  4590. {
  4591. return Ok(JsonView(false, data.Msg));
  4592. }
  4593. //生成默认文件pdf并且通知人员
  4594. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4595. {
  4596. DiId = dto.DiId,
  4597. ExportType = 1,
  4598. SubTypeId = 1005
  4599. }, "pdf");
  4600. //发送通知
  4601. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4602. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4603. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4604. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4605. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4606. //汇率信息记录
  4607. await GeneralMethod.RateRecordSave(dto.UserId,sign,"出入境费用");
  4608. return Ok(JsonView(true, data.Msg, data.Data));
  4609. }
  4610. catch (Exception ex)
  4611. {
  4612. return Ok(JsonView(false, ex.Message));
  4613. }
  4614. }
  4615. /// <summary>
  4616. /// 团组模块 - 出入境费用 - Confirm 费用
  4617. /// </summary>
  4618. /// <returns></returns>
  4619. [HttpPost]
  4620. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4621. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4622. {
  4623. //TODO:测试完毕需把对应的用户ID更改
  4624. //1、数据表添加字段
  4625. //2、更改字段接口()
  4626. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4627. //3、确认成功 给财务发送消息
  4628. if (_view.Code == 200)
  4629. {
  4630. if (dto.Type == 1)
  4631. {
  4632. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4633. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4634. }
  4635. }
  4636. return Ok(_view);
  4637. }
  4638. /// <summary>
  4639. /// 团组模块 - 出入境费用 - File downlaod
  4640. /// </summary>
  4641. /// <param name="dto"></param>
  4642. /// <returns></returns>
  4643. [HttpPost]
  4644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4645. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4646. {
  4647. try
  4648. {
  4649. if (dto.DiId < 1)
  4650. {
  4651. return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4652. }
  4653. if (dto.ExportType < 1)
  4654. {
  4655. return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4656. }
  4657. if (dto.SubTypeId < 1)
  4658. {
  4659. return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4660. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4661. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4662. 3 团组成员名单 1 团组成员名单", ""));
  4663. }
  4664. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4665. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4666. if (_EnterExitCosts == null)
  4667. {
  4668. return Ok(JsonView(400, "该团组未填写出入境费用;",""));
  4669. }
  4670. //数据源
  4671. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4672. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4673. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4674. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4675. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4676. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4677. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4678. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4679. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4680. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4681. .Select((tcl, dc, cc) => new
  4682. {
  4683. Name = dc.LastName + dc.FirstName,
  4684. Sex = dc.Sex,
  4685. Birthday = dc.BirthDay,
  4686. Company = cc.CompanyFullName,
  4687. Job = dc.Job
  4688. })
  4689. .ToList();
  4690. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4691. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4692. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4693. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4694. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4695. if (dto.ExportType == 1) //明细表
  4696. {
  4697. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4698. {
  4699. //获取模板
  4700. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4701. //载入模板
  4702. Document doc = new Document(tempPath);
  4703. DocumentBuilder builder = new DocumentBuilder(doc);
  4704. //利用键值对存放数据
  4705. Dictionary<string, string> dic = new Dictionary<string, string>();
  4706. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4707. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4708. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4709. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4710. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4711. //境内费用(其他费用)
  4712. if (_EnterExitCosts.ChoiceOne == 1)
  4713. {
  4714. string row1_1 = "";
  4715. if (_EnterExitCosts.Visa > 0)
  4716. {
  4717. //insidePayTotal += _EnterExitCosts.Visa;
  4718. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4719. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4720. {
  4721. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4722. }
  4723. }
  4724. string row1_2 = "";
  4725. if (_EnterExitCosts.YiMiao > 0)
  4726. {
  4727. //insidePayTotal += _EnterExitCosts.YiMiao;
  4728. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4729. }
  4730. if (_EnterExitCosts.HeSuan > 0)
  4731. {
  4732. //insidePayTotal += _EnterExitCosts.HeSuan;
  4733. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4734. }
  4735. if (_EnterExitCosts.Service > 0)
  4736. {
  4737. //insidePayTotal += _EnterExitCosts.Service;
  4738. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4739. }
  4740. string row1_3 = "";
  4741. if (_EnterExitCosts.Safe > 0)
  4742. {
  4743. //insidePayTotal += _EnterExitCosts.Safe;
  4744. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4745. }
  4746. if (_EnterExitCosts.Ticket > 0)
  4747. {
  4748. //insidePayTotal += _EnterExitCosts.Ticket;
  4749. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4750. }
  4751. string row1 = "";
  4752. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4753. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4754. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4755. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4756. dic.Add("Row1Str", row1);
  4757. }
  4758. string airTotalStr = string.Empty,
  4759. airPriceStr = string.Empty;
  4760. //经济舱
  4761. if (_EnterExitCosts.SumJJC == 1)
  4762. {
  4763. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4764. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4765. }
  4766. //公务舱
  4767. if (_EnterExitCosts.SumGWC == 1)
  4768. {
  4769. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4770. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4771. }
  4772. //头等舱
  4773. if (_EnterExitCosts.SumTDC == 1)
  4774. {
  4775. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4776. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4777. }
  4778. dic.Add("AirTotalStr", airTotalStr);
  4779. dic.Add("AirPriceStr", airPriceStr);
  4780. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4781. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4782. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4783. int table1Row = 0,
  4784. table2Row = 0,
  4785. table3Row = 0,
  4786. table4Row = 0;
  4787. //住宿费
  4788. if (_EnterExitCosts.ChoiceThree == 1)
  4789. {
  4790. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4791. table1Row = dac1.Count;
  4792. #region 填充word表格内容
  4793. for (int i = 0; i < dac1.Count; i++)
  4794. {
  4795. Grp_DayAndCost dac = dac1[i];
  4796. if (dac == null) continue;
  4797. builder.MoveToCell(0, i, 0, 0);
  4798. builder.Write("第" + dac.Days.ToString() + "晚:");
  4799. builder.MoveToCell(0, i, 1, 0);
  4800. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4801. //builder.Write(dac.Place == null ? "" : dac.Place);
  4802. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4803. builder.MoveToCell(0, i, 2, 0);
  4804. builder.Write("费用标准:");
  4805. string curr = "";
  4806. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4807. if (currData != null)
  4808. {
  4809. curr = currData.Name;
  4810. }
  4811. builder.MoveToCell(0, i, 3, 0);
  4812. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4813. builder.MoveToCell(0, i, 4, 0);
  4814. builder.Write("费用小计:");
  4815. builder.MoveToCell(0, i, 5, 0);
  4816. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4817. }
  4818. #endregion
  4819. }
  4820. else dic.Add("SubZS", "0.00");
  4821. //删除多余行
  4822. while (table1.Rows.Count > table1Row)
  4823. {
  4824. table1.Rows.RemoveAt(table1Row);
  4825. }
  4826. //伙食费
  4827. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4828. if (_EnterExitCosts.ChoiceFour == 1)
  4829. {
  4830. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4831. table2Row = dac2.Count;
  4832. #region 填充word表格内容
  4833. for (int i = 0; i < dac2.Count; i++)
  4834. {
  4835. Grp_DayAndCost dac = dac2[i];
  4836. if (dac == null) continue;
  4837. builder.MoveToCell(1, i, 0, 0);
  4838. builder.Write("第" + dac.Days.ToString() + "天:");
  4839. builder.MoveToCell(1, i, 1, 0);
  4840. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4841. builder.MoveToCell(1, i, 2, 0);
  4842. builder.Write("费用标准:");
  4843. string curr = "";
  4844. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4845. if (currData != null)
  4846. {
  4847. curr = currData.Name;
  4848. }
  4849. builder.MoveToCell(1, i, 3, 0);
  4850. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4851. builder.MoveToCell(1, i, 4, 0);
  4852. builder.Write("费用小计:");
  4853. builder.MoveToCell(1, i, 5, 0);
  4854. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4855. }
  4856. #endregion
  4857. }
  4858. else dic.Add("SubHS", "0.00");
  4859. //删除多余行
  4860. while (table2.Rows.Count > table2Row)
  4861. {
  4862. table2.Rows.RemoveAt(table2Row);
  4863. }
  4864. //公杂费
  4865. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4866. if (_EnterExitCosts.ChoiceFive == 1)
  4867. {
  4868. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4869. table3Row = dac3.Count;
  4870. #region 填充word表格内容
  4871. for (int i = 0; i < dac3.Count; i++)
  4872. {
  4873. Grp_DayAndCost dac = dac3[i];
  4874. if (dac == null) continue;
  4875. builder.MoveToCell(2, i, 0, 0);
  4876. builder.Write("第" + dac.Days.ToString() + "天:");
  4877. builder.MoveToCell(2, i, 1, 0);
  4878. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4879. builder.MoveToCell(2, i, 2, 0);
  4880. builder.Write("费用标准:");
  4881. string curr = "";
  4882. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4883. if (currData != null)
  4884. {
  4885. curr = currData.Name;
  4886. }
  4887. builder.MoveToCell(2, i, 3, 0);
  4888. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4889. builder.MoveToCell(2, i, 4, 0);
  4890. builder.Write("费用小计:");
  4891. builder.MoveToCell(2, i, 5, 0);
  4892. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4893. }
  4894. //删除多余行
  4895. while (table3.Rows.Count > table3Row)
  4896. {
  4897. table3.Rows.RemoveAt(table3Row);
  4898. }
  4899. #endregion
  4900. }
  4901. else dic.Add("SubGZF", "0.00");
  4902. //删除多余行
  4903. while (table3.Rows.Count > table3Row)
  4904. {
  4905. table3.Rows.RemoveAt(table3Row);
  4906. }
  4907. //培训费
  4908. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4909. if (_EnterExitCosts.ChoiceSix == 1)
  4910. {
  4911. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4912. dic.Add("SubPX", pxStr);
  4913. table4Row = dac4.Count;
  4914. #region 填充word表格内容
  4915. for (int i = 0; i < dac4.Count; i++)
  4916. {
  4917. Grp_DayAndCost dac = dac4[i];
  4918. if (dac == null) continue;
  4919. builder.MoveToCell(3, i, 0, 0);
  4920. builder.Write("第" + dac.Days.ToString() + "天:");
  4921. builder.MoveToCell(3, i, 1, 0);
  4922. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4923. builder.MoveToCell(3, i, 2, 0);
  4924. builder.Write("费用标准:");
  4925. string curr = "";
  4926. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4927. if (currData != null)
  4928. {
  4929. curr = currData.Name;
  4930. }
  4931. builder.MoveToCell(3, i, 3, 0);
  4932. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4933. builder.MoveToCell(3, i, 4, 0);
  4934. builder.Write("费用小计:");
  4935. builder.MoveToCell(3, i, 5, 0);
  4936. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4937. }
  4938. #endregion
  4939. }
  4940. //else dic.Add("SubPX","0.00");
  4941. //删除多余行
  4942. while (table4.Rows.Count > table4Row)
  4943. {
  4944. table4.Rows.RemoveAt(table4Row);
  4945. }
  4946. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
  4947. decimal subJJC = 0.00M,
  4948. subGWC = 0.00M,
  4949. subTDC = 0.00M;
  4950. //经济舱
  4951. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  4952. //公务舱
  4953. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  4954. //头等舱
  4955. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  4956. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4957. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4958. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  4959. #region 填充word模板书签内容
  4960. foreach (var key in dic.Keys)
  4961. {
  4962. builder.MoveToBookmark(key);
  4963. builder.Write(dic[key]);
  4964. }
  4965. #endregion
  4966. //文件名
  4967. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  4968. AsposeHelper.removewatermark_v2180();
  4969. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4970. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4971. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  4972. else if (dto.PortType == 2 ) return Ok(JsonView(true, "成功", url));
  4973. }
  4974. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4975. {
  4976. //获取模板
  4977. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4978. //载入模板
  4979. Document doc = new Document(tempPath);
  4980. DocumentBuilder builder = new DocumentBuilder(doc);
  4981. Dictionary<string, string> dic = new Dictionary<string, string>();
  4982. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4983. {
  4984. List<string> list = new List<string>();
  4985. try
  4986. {
  4987. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4988. foreach (var item in spilitArr)
  4989. {
  4990. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4991. var depCode = spDotandEmpty[2].Substring(0, 3);
  4992. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4993. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4994. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4995. list.Add(depName);
  4996. list.Add(arrName);
  4997. }
  4998. list = list.Distinct().ToList();
  4999. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5000. }
  5001. catch (Exception)
  5002. {
  5003. dic.Add("ReturnCode", "行程录入不正确!");
  5004. }
  5005. }
  5006. else
  5007. {
  5008. dic.Add("ReturnCode", "未录入行程!");
  5009. }
  5010. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5011. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5012. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5013. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5014. {
  5015. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5016. dic.Add("Day", sp.Days.ToString());
  5017. }
  5018. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5019. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5020. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5021. //dic.Add("Names", Names);
  5022. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5023. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5024. decimal dac1totalPrice = 0.00M;
  5025. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5026. foreach (var dac in dac1)
  5027. {
  5028. if (dac.SubTotal == 0.00M)
  5029. {
  5030. continue;
  5031. }
  5032. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5033. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5034. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5035. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5036. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5037. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5038. builder.Write(currency);//币种
  5039. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5040. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5041. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5042. builder.Write("");//人数
  5043. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5044. builder.Write("");//天数
  5045. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5046. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5047. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5048. decimal rate = 0.00M;
  5049. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5050. builder.Write(rate.ToString("#0.0000"));//汇率
  5051. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5052. decimal rbmPrice = dac.SubTotal;
  5053. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5054. accommodationStartIndex++;
  5055. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5056. }
  5057. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5058. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5059. {
  5060. table1.Rows.RemoveAt(i - 1);
  5061. foodandotherStartIndex--;
  5062. }
  5063. if (dac2.Count == dac3.Count)//国家 币种 金额
  5064. {
  5065. for (int i = 0; i < dac2.Count; i++)
  5066. {
  5067. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5068. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5069. }
  5070. }
  5071. decimal dac2totalPrice = 0.00M;
  5072. foreach (var dac in dac2)
  5073. {
  5074. if (dac.SubTotal == 0)
  5075. {
  5076. continue;
  5077. }
  5078. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5079. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5080. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5081. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5082. builder.Write(currency);//币种
  5083. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5084. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5085. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5086. builder.Write("");//人数
  5087. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5088. builder.Write("");//天数
  5089. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5090. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5091. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5092. decimal rate = 0.00M;
  5093. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5094. builder.Write(rate.ToString("#0.0000"));//汇率
  5095. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5096. decimal rbmPrice = dac.SubTotal;
  5097. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5098. foodandotherStartIndex++;
  5099. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5100. }
  5101. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5102. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5103. {
  5104. table1.Rows.RemoveAt(i - 1);
  5105. }
  5106. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5107. string otherFeeStr = "";
  5108. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5109. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5110. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5111. if (otherFeeStr.Length > 0)
  5112. {
  5113. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5114. otherFeeStr = $"({otherFeeStr})";
  5115. dic.Add("OtherFeeStr", otherFeeStr);
  5116. }
  5117. //总计
  5118. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5119. //国际旅费
  5120. string outsideAir = string.Empty;
  5121. string allPriceAir = string.Empty;
  5122. if (_EnterExitCosts.SumJJC == 1)
  5123. {
  5124. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5125. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5126. }
  5127. if (_EnterExitCosts.SumGWC == 1)
  5128. {
  5129. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5130. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5131. }
  5132. if (_EnterExitCosts.SumTDC == 1)
  5133. {
  5134. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5135. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5136. }
  5137. dic.Add("InTravelPrice", $"({outsideAir})");
  5138. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5139. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5140. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5141. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5142. foreach (var key in dic.Keys)
  5143. {
  5144. builder.MoveToBookmark(key);
  5145. builder.Write(dic[key]);
  5146. }
  5147. //模板文件名
  5148. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5149. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5150. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5151. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5152. else if (dto.PortType == 2 ) return Ok(JsonView(true, "成功", url));
  5153. }
  5154. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5155. {
  5156. //获取模板
  5157. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5158. //载入模板
  5159. WorkbookDesigner designer = new WorkbookDesigner();
  5160. designer.Workbook = new Workbook(tempPath);
  5161. Dictionary<string, string> dic = new Dictionary<string, string>();
  5162. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5163. {
  5164. List<string> list = new List<string>();
  5165. try
  5166. {
  5167. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5168. foreach (var item in spilitArr)
  5169. {
  5170. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5171. var depCode = spDotandEmpty[2].Substring(0, 3);
  5172. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5173. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5174. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5175. list.Add(depName);
  5176. list.Add(arrName);
  5177. }
  5178. list = list.Distinct().ToList();
  5179. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5180. }
  5181. catch (Exception)
  5182. {
  5183. dic.Add("ReturnCode", "行程录入不正确!");
  5184. }
  5185. }
  5186. else
  5187. {
  5188. dic.Add("ReturnCode", "未录入行程!");
  5189. }
  5190. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5191. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5192. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5193. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5194. {
  5195. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5196. dic.Add("Day", sp.Days.ToString());
  5197. }
  5198. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5199. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5200. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5201. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5202. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5203. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5204. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5205. designer.SetDataSource("Name", Names);
  5206. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5207. designer.SetDataSource("Day", dic["Day"] + "天");
  5208. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5209. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5210. int startIndex = 10;
  5211. const int startIndexcopy = 10;
  5212. if (dac2.Count == dac3.Count)//国家 币种 金额
  5213. {
  5214. for (int i = 0; i < dac2.Count; i++)
  5215. {
  5216. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5217. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5218. }
  5219. }
  5220. DataTable dtdac1 = new DataTable();
  5221. List<string> place = new List<string>();
  5222. dtdac1.Columns.AddRange(new DataColumn[] {
  5223. new DataColumn(){ ColumnName = "city"},
  5224. new DataColumn(){ ColumnName = "curr"},
  5225. new DataColumn(){ ColumnName = "criterion"},
  5226. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5227. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5228. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5229. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5230. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5231. });
  5232. DataTable dtdac2 = new DataTable();
  5233. dtdac2.Columns.AddRange(new DataColumn[] {
  5234. new DataColumn(){ ColumnName = "city"},
  5235. new DataColumn(){ ColumnName = "curr"},
  5236. new DataColumn(){ ColumnName = "criterion"},
  5237. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5238. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5239. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5240. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5241. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5242. });
  5243. dtdac1.TableName = "tb1";
  5244. dtdac2.TableName = "tb2";
  5245. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5246. foreach (var item in dac1)
  5247. {
  5248. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5249. if (place.Contains(item.Place))
  5250. {
  5251. continue;
  5252. }
  5253. DataRow row = dtdac1.NewRow();
  5254. row["city"] = item.Place;
  5255. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5256. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5257. row["curr"] = currency;
  5258. row["rate"] = rate.ToString("#0.0000");
  5259. row["criterion"] = item.Cost.ToString("#0.00");
  5260. row["number"] = 1;
  5261. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5262. //row["costRMB"] = rbmPrice;
  5263. dtdac1.Rows.Add(row);
  5264. place.Add(item.Place);
  5265. }
  5266. place = new List<string>();
  5267. foreach (var item in dac2)
  5268. {
  5269. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5270. if (place.Contains(item.Place))
  5271. {
  5272. continue;
  5273. }
  5274. DataRow row = dtdac2.NewRow();
  5275. row["city"] = item.Place;
  5276. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5277. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5278. row["curr"] = currency;
  5279. row["rate"] = rate.ToString("#0.0000");
  5280. row["criterion"] = item.Cost.ToString("#0.00");
  5281. row["number"] = 1;
  5282. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5283. //row["cost"] = item.SubTotal;
  5284. //row["costRMB"] = rbmPrice;
  5285. dtdac2.Rows.Add(row);
  5286. place.Add(item.Place);
  5287. //dac2totalPrice += rbmPrice;
  5288. }
  5289. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5290. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5291. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5292. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5293. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5294. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5295. string cell4Str1 = string.Empty;
  5296. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5297. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5298. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5299. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5300. string cellStr = $" 5.其他费用(";
  5301. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5302. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5303. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5304. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5305. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5306. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5307. if (cellStr.Length > 8)
  5308. {
  5309. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5310. }
  5311. cellStr += ")";
  5312. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  5313. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5314. decimal pxFee = dac4.Sum(it => it.Cost);
  5315. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5316. string celllastStr1 = "";
  5317. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5318. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5319. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5320. celllastStr1 += $",国际旅费 元";
  5321. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5322. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5323. designer.SetDataSource("cell4Str", cell4Str);
  5324. designer.SetDataSource("cellStr", cellStr);
  5325. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  5326. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5327. designer.SetDataSource("celllastStr", celllastStr);
  5328. Workbook wb = designer.Workbook;
  5329. var sheet = wb.Worksheets[0];
  5330. //绑定datatable数据集
  5331. designer.SetDataSource(dtdac1);
  5332. designer.SetDataSource(dtdac2);
  5333. designer.Process();
  5334. var rowStart = dtdac1.Rows.Count;
  5335. while (rowStart > 0)
  5336. {
  5337. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5338. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5339. startIndex++;
  5340. rowStart--;
  5341. }
  5342. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5343. startIndex += 1; //总计行
  5344. rowStart = dtdac2.Rows.Count;
  5345. while (rowStart > 0)
  5346. {
  5347. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5348. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5349. startIndex++;
  5350. rowStart--;
  5351. }
  5352. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5353. wb.CalculateFormula(true);
  5354. //模板文件名
  5355. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5356. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5357. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5358. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5359. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5360. }
  5361. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5362. {
  5363. //获取模板
  5364. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5365. //载入模板
  5366. Document doc = new Document(tempPath);
  5367. DocumentBuilder builder = new DocumentBuilder(doc);
  5368. Dictionary<string, string> dic = new Dictionary<string, string>();
  5369. dic.Add("GroupName", _DelegationInfo.TeamName);
  5370. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5371. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5372. string missionLeaderJob = "";//负责人job
  5373. int groupNumber = 0; //团人数
  5374. if (DeleClientList.Count > 0)
  5375. {
  5376. missionLeader = DeleClientList[0]?.Name ?? "";
  5377. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5378. }
  5379. dic.Add("MissionLeader", missionLeader); //团负责人
  5380. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5381. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5382. #region MyRegion
  5383. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5384. //{
  5385. // List<string> list = new List<string>();
  5386. // try
  5387. // {
  5388. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5389. // foreach (var item in spilitArr)
  5390. // {
  5391. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5392. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5393. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5394. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5395. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5396. // list.Add(depName);
  5397. // list.Add(arrName);
  5398. // }
  5399. // list = list.Distinct().ToList();
  5400. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5401. // }
  5402. // catch (Exception)
  5403. // {
  5404. // dic.Add("ReturnCode", "行程录入不正确!");
  5405. // }
  5406. //}
  5407. //else
  5408. //{
  5409. // dic.Add("ReturnCode", "未录入行程!");
  5410. //}
  5411. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5412. dic.Add("ReturnCode", string.Join("、", countrys));
  5413. #endregion
  5414. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5415. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5416. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5417. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5418. //{
  5419. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5420. // dic.Add("Day", sp.Days.ToString());
  5421. //}
  5422. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5423. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5424. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5425. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5426. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5427. //培训人员名单
  5428. int cultivateRowIndex = 7;
  5429. foreach (var item in DeleClientList)
  5430. {
  5431. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5432. builder.Write(item.Name);
  5433. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5434. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5435. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5436. string birthDay = "";
  5437. if (item.Birthday != null)
  5438. {
  5439. DateTime dt = Convert.ToDateTime(item.Birthday);
  5440. birthDay = $"{dt.Year}.{dt.Month}";
  5441. }
  5442. builder.Write(birthDay);
  5443. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5444. builder.Write(item.Company);
  5445. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5446. builder.Write(item.Job);
  5447. cultivateRowIndex++;
  5448. }
  5449. //删除多余行
  5450. //cultivateRowIndex -= 2;
  5451. int delRows = 10 + 7 - cultivateRowIndex;
  5452. if (delRows > 0)
  5453. {
  5454. for (int i = 0; i < delRows; i++)
  5455. {
  5456. table1.Rows.RemoveAt(cultivateRowIndex);
  5457. //cultivateRowIndex++;
  5458. }
  5459. }
  5460. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5461. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5462. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5463. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5464. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5465. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5466. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5467. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5468. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5469. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5470. //其他费用
  5471. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  5472. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5473. //其他费用合计
  5474. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5475. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5476. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5477. //公务舱合计
  5478. //国际旅费
  5479. string outsideJJ = "";
  5480. string allPriceJJ = "";
  5481. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5482. {
  5483. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5484. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5485. }
  5486. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5487. {
  5488. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5489. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5490. }
  5491. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5492. {
  5493. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5494. dic.Add("AirFeeTotal", airFeeTotalStr);
  5495. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5496. dic.Add("FeeTotal", feeTotalStr);
  5497. }
  5498. foreach (var key in dic.Keys)
  5499. {
  5500. builder.MoveToBookmark(key);
  5501. builder.Write(dic[key]);
  5502. }
  5503. //模板文件名
  5504. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5505. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5506. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5507. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5508. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5509. }
  5510. }
  5511. else if (dto.ExportType == 2) //表格
  5512. {
  5513. //利用键值对存放数据
  5514. Dictionary<string, string> dic = new Dictionary<string, string>();
  5515. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5516. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5517. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5518. dic.Add("Day", sp.Days.ToString());
  5519. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5520. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5521. {
  5522. //获取模板
  5523. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5524. //载入模板
  5525. Document doc = new Document(tempPath);
  5526. DocumentBuilder builder = new DocumentBuilder(doc);
  5527. dic.Add("TeamName", _DelegationInfo.TeamName);
  5528. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5529. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5530. string missionLeaderName = "",
  5531. missionLeaderJob = "";
  5532. if (DeleClientList.Count > 0)
  5533. {
  5534. missionLeaderName = DeleClientList[0].Name;
  5535. missionLeaderJob = DeleClientList[0].Job;
  5536. }
  5537. dic.Add("MissionLeaderName", missionLeaderName);
  5538. dic.Add("MissionLeaderJob", missionLeaderJob);
  5539. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5540. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5541. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5542. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5543. int rowCount = 10;//总人数行
  5544. int startRowIndex = 7; //起始行
  5545. for (int i = 0; i < DeleClientList.Count; i++)
  5546. {
  5547. builder.MoveToCell(0, startRowIndex, 0, 0);
  5548. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5549. builder.MoveToCell(0, startRowIndex, 1, 0);
  5550. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5551. builder.Write(sex);//性别
  5552. builder.MoveToCell(0, startRowIndex, 2, 0);
  5553. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5554. builder.MoveToCell(0, startRowIndex, 3, 0);
  5555. builder.Write(DeleClientList[i].Company);//工作单位
  5556. builder.MoveToCell(0, startRowIndex, 4, 0);
  5557. builder.Write(DeleClientList[i].Job);//职务及级别
  5558. builder.MoveToCell(0, startRowIndex, 5, 0);
  5559. builder.Write("");//人员属性
  5560. builder.MoveToCell(0, startRowIndex, 6, 0);
  5561. builder.Write("");//上次出国时间
  5562. startRowIndex++;
  5563. }
  5564. int nullRow = rowCount - DeleClientList.Count;//空行
  5565. for (int i = 0; i < nullRow; i++)
  5566. {
  5567. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5568. }
  5569. foreach (var key in dic.Keys)
  5570. {
  5571. builder.MoveToBookmark(key);
  5572. builder.Write(dic[key]);
  5573. }
  5574. //模板文件名
  5575. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5576. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5577. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5578. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5579. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5580. }
  5581. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5582. {
  5583. //获取模板
  5584. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5585. //载入模板
  5586. Document doc = new Document(tempPath);
  5587. DocumentBuilder builder = new DocumentBuilder(doc);
  5588. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5589. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5590. dic.Add("Names", Names);
  5591. int accommodationRows = 12, foodandotherRows = 12;
  5592. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5593. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5594. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5595. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5596. int accommodationStartIndex = 6;
  5597. decimal dac1totalPrice = 0.00M;
  5598. foreach (var dac in dac1)
  5599. {
  5600. if (dac.SubTotal == 0)
  5601. {
  5602. continue;
  5603. }
  5604. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5605. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5606. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5607. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5608. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5609. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5610. builder.Write(currency);//币种
  5611. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5612. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5613. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5614. builder.Write("");//人数
  5615. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5616. builder.Write("");//天数
  5617. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5618. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5619. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5620. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5621. builder.Write(rate.ToString("#0.0000"));//汇率
  5622. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5623. decimal rbmPrice = rate * dac.SubTotal;
  5624. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5625. accommodationStartIndex++;
  5626. dac1totalPrice += rbmPrice;
  5627. }
  5628. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5629. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5630. builder.Write("小计");
  5631. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5632. builder.Write(dac1totalPrice.ToString("#0.00"));
  5633. accommodationStartIndex++;
  5634. int nullRow = accommodationRows - dac1.Count;
  5635. //删除空行
  5636. //if (nullRow > 0)
  5637. //{
  5638. // int rowIndex = accommodationStartIndex;
  5639. // for (int i = 0; i < nullRow; i++)
  5640. // {
  5641. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5642. // row.Remove();
  5643. // rowIndex++;
  5644. // }
  5645. //}
  5646. if (dac2.Count == dac3.Count)//国家 币种 金额
  5647. {
  5648. for (int i = 0; i < dac2.Count; i++)
  5649. {
  5650. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5651. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5652. }
  5653. }
  5654. int foodandotherStartIndex = 19;//
  5655. decimal dac2totalPrice = 0.00M;
  5656. foreach (var dac in dac2)
  5657. {
  5658. if (dac.SubTotal == 0)
  5659. {
  5660. continue;
  5661. }
  5662. //foodandotherStartIndex = 12;
  5663. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5664. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5665. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5666. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5667. builder.Write(currency);//币种
  5668. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5669. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5670. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5671. builder.Write("");//人数
  5672. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5673. builder.Write("");//天数
  5674. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5675. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5676. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5677. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5678. builder.Write(rate.ToString("#0.0000"));//汇率
  5679. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5680. decimal rbmPrice = rate * dac.SubTotal;
  5681. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5682. foodandotherStartIndex++;
  5683. dac2totalPrice += rbmPrice;
  5684. }
  5685. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5686. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5687. //删除空行
  5688. //if (dac2.Count < foodandotherRows)
  5689. //{
  5690. // while (table2.Rows.Count > dac2.Count)
  5691. // {
  5692. // table2.Rows.RemoveAt(dac2.Count);
  5693. // }
  5694. //}
  5695. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5696. string otherFeeStr = "";
  5697. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5698. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5699. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5700. if (otherFeeStr.Length > 0)
  5701. {
  5702. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5703. otherFeeStr = $"({otherFeeStr})";
  5704. dic.Add("OtherFeeStr", otherFeeStr);
  5705. }
  5706. foreach (var key in dic.Keys)
  5707. {
  5708. builder.MoveToBookmark(key);
  5709. builder.Write(dic[key]);
  5710. }
  5711. //模板文件名
  5712. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5713. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5714. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5715. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5716. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5717. }
  5718. }
  5719. else if (dto.ExportType == 3)
  5720. {
  5721. if (dto.SubTypeId == 1) //团组成员名单
  5722. {
  5723. if (DeleClientList.Count < 1)
  5724. {
  5725. return Ok(JsonView(false, "团组成员暂未录入!!!",""));
  5726. }
  5727. //获取模板
  5728. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5729. //载入模板
  5730. Document doc = new Document(tempPath);
  5731. DocumentBuilder builder = new DocumentBuilder(doc);
  5732. //获取word里所有表格
  5733. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5734. //获取所填表格的序数
  5735. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5736. var rowStart = tableOne.Rows[0]; //获取第1行
  5737. //循环赋值
  5738. for (int i = 0; i < DeleClientList.Count; i++)
  5739. {
  5740. builder.MoveToCell(0, i + 1, 0, 0);
  5741. builder.Write(DeleClientList[i].Name);
  5742. builder.MoveToCell(0, i + 1, 1, 0);
  5743. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5744. builder.Write(sex);
  5745. builder.MoveToCell(0, i + 1, 2, 0);
  5746. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5747. builder.MoveToCell(0, i + 1, 3, 0);
  5748. builder.Write(DeleClientList[i].Company);
  5749. builder.MoveToCell(0, i + 1, 4, 0);
  5750. builder.Write(DeleClientList[i].Job);
  5751. }
  5752. //删除多余行
  5753. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5754. {
  5755. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5756. }
  5757. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5758. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5759. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5760. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5761. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5762. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5763. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5764. }
  5765. }
  5766. return Ok(JsonView(400, "操作失败!", ""));
  5767. }
  5768. catch (Exception ex)
  5769. {
  5770. return Ok(JsonView(400, ex.Message, ""));
  5771. }
  5772. }
  5773. /// <summary>
  5774. /// 获取三公费用标准city
  5775. /// </summary>
  5776. /// <param name="placeData"></param>
  5777. /// <param name="nationalTravelFeeId"></param>
  5778. /// <returns></returns>
  5779. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5780. {
  5781. string _city = string.Empty;
  5782. if (placeData.Count < 1) return _city;
  5783. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5784. if (data == null) return _city;
  5785. string country = data.Country;
  5786. string city = data.City;
  5787. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5788. else _city = city;
  5789. return _city;
  5790. }
  5791. /// <summary>
  5792. /// 团组模块 - 出入境费用 - 明细表导出
  5793. /// </summary>
  5794. /// <returns></returns>
  5795. [HttpPost]
  5796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5797. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5798. {
  5799. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5800. if (data.Code != 0)
  5801. {
  5802. return Ok(JsonView(false, data.Msg));
  5803. }
  5804. return Ok(JsonView(true, data.Msg, data.Data));
  5805. }
  5806. /// <summary>
  5807. /// 团组模块 - 出入境费用 - 一键清空
  5808. /// </summary>
  5809. /// <returns></returns>
  5810. [HttpPost]
  5811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5812. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5813. {
  5814. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5815. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5816. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5817. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5818. if (_view.Code == 0)
  5819. {
  5820. return Ok(JsonView(true, "操作成功"));
  5821. }
  5822. return Ok(JsonView(false, "操作失败"));
  5823. }
  5824. /// <summary>
  5825. /// 团组模块 - 出入境费用 - 子项删除
  5826. /// </summary>
  5827. /// <returns></returns>
  5828. [HttpPost]
  5829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5830. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5831. {
  5832. try
  5833. {
  5834. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5835. if (data.Code != 0)
  5836. {
  5837. return Ok(JsonView(false, data.Msg));
  5838. }
  5839. return Ok(JsonView(true, "操作成功!", data.Data));
  5840. }
  5841. catch (Exception ex)
  5842. {
  5843. return Ok(JsonView(false, ex.Message));
  5844. }
  5845. }
  5846. /// <summary>
  5847. /// 团组模块 - 出入境国家费用标准 List
  5848. /// </summary>
  5849. /// <returns></returns>
  5850. [HttpPost]
  5851. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5852. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5853. {
  5854. try
  5855. {
  5856. Stopwatch sw = new Stopwatch();
  5857. sw.Start();
  5858. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5859. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5860. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5861. Where gntf.Isdel = 0");
  5862. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5863. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5864. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  5865. //foreach (var item in nationalTravel)
  5866. //{
  5867. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  5868. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  5869. // if (otherData != null)
  5870. // {
  5871. // cityData.Remove(otherData);
  5872. // cityData.Add(otherData);
  5873. // }
  5874. // nationalTravelFeeData1.Add(new
  5875. // {
  5876. // Country = item.Country,
  5877. // CityData = cityData
  5878. // });
  5879. //}
  5880. sw.Stop();
  5881. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  5882. }
  5883. catch (Exception ex)
  5884. {
  5885. return Ok(JsonView(false, ex.Message));
  5886. throw;
  5887. }
  5888. }
  5889. /// <summary>
  5890. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  5891. /// </summary>
  5892. /// <returns></returns>
  5893. [HttpPost]
  5894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5895. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  5896. {
  5897. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  5898. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  5899. List<string> countryData = new List<string>();
  5900. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  5901. countryData = countryData.Distinct().ToList();
  5902. List<dynamic> dataSource = new List<dynamic>();
  5903. foreach (var item in countryData)
  5904. {
  5905. List<string> cityData1 = new List<string>();
  5906. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  5907. var countryData2 = new
  5908. {
  5909. CountryName = item,
  5910. CityData = cityData1
  5911. };
  5912. dataSource.Add(countryData2);
  5913. }
  5914. return Ok(JsonView(true, "查询成功!", dataSource));
  5915. }
  5916. /// <summary>
  5917. /// 团组模块 - 出入境国家费用标准 Page List
  5918. /// </summary>
  5919. /// <returns></returns>
  5920. [HttpPost]
  5921. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5922. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  5923. {
  5924. int portId = dto.PortType;
  5925. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5926. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  5927. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  5928. string whereSql = string.Empty;
  5929. if (!string.IsNullOrEmpty(dto.Country))
  5930. {
  5931. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  5932. }
  5933. if (!string.IsNullOrEmpty(dto.City))
  5934. {
  5935. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  5936. }
  5937. string pageSql = string.Format(@"Select * From (
  5938. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  5939. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  5940. From Grp_NationalTravelFee gntf
  5941. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5942. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5943. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  5944. RefAsync<int> total = 0;
  5945. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  5946. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  5947. }
  5948. /// <summary>
  5949. /// 团组模块 - 出入境国家费用标准 根据城市查询
  5950. /// </summary>
  5951. /// <returns></returns>
  5952. [HttpPost]
  5953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5954. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  5955. {
  5956. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  5957. int portId = dto.PortType;
  5958. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5959. string whereSql = string.Empty;
  5960. if (!string.IsNullOrEmpty(dto.Country))
  5961. {
  5962. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  5963. }
  5964. if (!string.IsNullOrEmpty(dto.City))
  5965. {
  5966. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  5967. }
  5968. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  5969. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  5970. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  5971. From Grp_NationalTravelFee gntf
  5972. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5973. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5974. Where gntf.Isdel = 0 {0} ", whereSql);
  5975. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  5976. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  5977. }
  5978. /// <summary>
  5979. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  5980. /// </summary>
  5981. /// <returns></returns>
  5982. [HttpPost]
  5983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5984. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  5985. {
  5986. try
  5987. {
  5988. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  5989. if (data.Code != 0)
  5990. {
  5991. return Ok(JsonView(false, data.Msg));
  5992. }
  5993. return Ok(JsonView(true, "操作成功!", data.Data));
  5994. }
  5995. catch (Exception ex)
  5996. {
  5997. return Ok(JsonView(false, ex.Message));
  5998. }
  5999. }
  6000. /// <summary>
  6001. /// 团组模块 - 出入境国家费用标准 - Del
  6002. /// </summary>
  6003. /// <returns></returns>
  6004. [HttpPost]
  6005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6006. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6007. {
  6008. try
  6009. {
  6010. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6011. {
  6012. Id = dto.Id,
  6013. DeleteUserId = dto.DeleteUserId,
  6014. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6015. IsDel = 1
  6016. };
  6017. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6018. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6019. .WhereColumns(it => new { it.Id })
  6020. .ExecuteCommandAsync();
  6021. if (delStatus <= 0)
  6022. {
  6023. return Ok(JsonView(false, "删除失败!"));
  6024. }
  6025. return Ok(JsonView(true, "操作成功!"));
  6026. }
  6027. catch (Exception ex)
  6028. {
  6029. return Ok(JsonView(false, ex.Message));
  6030. }
  6031. }
  6032. /// <summary>
  6033. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6034. /// 注:Get 请求Headers 加 Token
  6035. /// </summary>
  6036. /// <param name="groupId"></param>
  6037. /// <returns></returns>
  6038. [HttpGet("{groupId}")]
  6039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6040. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6041. {
  6042. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6043. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6044. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6045. data.ForEach(x =>
  6046. {
  6047. x.CreateUserId = _currUserInfo.UserId;
  6048. });
  6049. if (data.Count > 0)
  6050. {
  6051. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6052. if (add > 0)
  6053. {
  6054. return Ok(JsonView(true, "操作成功!"));
  6055. }
  6056. }
  6057. return Ok(JsonView(false, "未操作!"));
  6058. }
  6059. #endregion
  6060. #region 签证费用录入
  6061. /// <summary>
  6062. /// 根据diid查询签证费用列表
  6063. /// </summary>
  6064. /// <param name="dto"></param>
  6065. /// <returns></returns>
  6066. [HttpPost]
  6067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6068. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  6069. {
  6070. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  6071. if (groupData.Code != 0)
  6072. {
  6073. return Ok(JsonView(false, groupData.Msg));
  6074. }
  6075. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6076. }
  6077. /// <summary>
  6078. /// 根据签证费用Id查询单条数据及c表数据
  6079. /// </summary>
  6080. /// <param name="dto"></param>
  6081. /// <returns></returns>
  6082. [HttpPost]
  6083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6084. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  6085. {
  6086. Result groupData = await _visaPriceRep.PostVisaById(dto);
  6087. if (groupData.Code != 0)
  6088. {
  6089. return Ok(JsonView(false, groupData.Msg));
  6090. }
  6091. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6092. }
  6093. /// <summary>
  6094. /// 签证费用删除
  6095. /// </summary>
  6096. /// <param name="dto"></param>
  6097. /// <returns></returns>
  6098. [HttpPost]
  6099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6100. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  6101. {
  6102. _sqlSugar.BeginTran();
  6103. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  6104. if (!res)
  6105. {
  6106. _sqlSugar.RollbackTran();
  6107. return Ok(JsonView(false, "删除失败"));
  6108. }
  6109. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  6110. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  6111. .SetColumns(a => new Grp_CreditCardPayment()
  6112. {
  6113. IsDel = 1,
  6114. DeleteUserId = dto.DeleteUserId,
  6115. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6116. })
  6117. .ExecuteCommand();
  6118. if (resSub < 1)
  6119. {
  6120. _sqlSugar.RollbackTran();
  6121. return Ok(JsonView(false, "删除失败"));
  6122. }
  6123. _sqlSugar.CommitTran();
  6124. return Ok(JsonView(true, "删除成功!"));
  6125. }
  6126. /// <summary>
  6127. /// 签证费用录入下拉框初始化
  6128. /// </summary>
  6129. /// <returns></returns>
  6130. [HttpPost]
  6131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6132. public async Task<IActionResult> VisaPriceAddSelect()
  6133. {
  6134. //支付方式
  6135. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  6136. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  6137. //币种
  6138. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  6139. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  6140. //乘客类型
  6141. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  6142. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  6143. //卡类型
  6144. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  6145. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  6146. //代办费类型
  6147. var agencyFeeTypeData = new List<dynamic>() {
  6148. new { id = 0 , Text = "未选择" },
  6149. new { id = 1 , Text = "小公务" },
  6150. new { id = 2 , Text = "大公务" },
  6151. };
  6152. //签证费用标准国家Data
  6153. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  6154. var data = new
  6155. {
  6156. Payment = _Payment,
  6157. CurrencyList = _CurrencyList,
  6158. PassengerType = _PassengerType,
  6159. BankCard = _BankCard,
  6160. AgencyFeeType = agencyFeeTypeData,
  6161. CountryFeeData = visaCountryFeeData
  6162. };
  6163. return Ok(JsonView(true, "查询成功!", data));
  6164. }
  6165. /// <summary>
  6166. /// 签证费用录入操作(Status:1.新增,2.修改)
  6167. /// </summary>
  6168. /// <param name="dto"></param>
  6169. /// <returns></returns>
  6170. [HttpPost]
  6171. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6172. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  6173. {
  6174. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  6175. if (groupData.Code != 0)
  6176. {
  6177. return Ok(JsonView(false, groupData.Msg));
  6178. }
  6179. #region 应用推送
  6180. try
  6181. {
  6182. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6183. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6184. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6185. //2024-10-21 新增LZ UID
  6186. var userIds = new List<int>() { 21 };
  6187. string title = $"系统通知";
  6188. string content = "";
  6189. var diId = dto.DiId;
  6190. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6191. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6192. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6193. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6194. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6195. }
  6196. catch (Exception ex)
  6197. {
  6198. }
  6199. #endregion
  6200. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6201. }
  6202. #endregion
  6203. #region 签证提成录入
  6204. /// <summary>
  6205. /// 签证提成录入
  6206. /// 基础数据
  6207. /// </summary>
  6208. /// <param name="_dto"></param>
  6209. /// <returns></returns>
  6210. [HttpGet]
  6211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6212. public async Task<IActionResult> VisaCommissionInit()
  6213. {
  6214. return Ok(await _visaCommissionRep.Init());
  6215. }
  6216. /// <summary>
  6217. /// 签证提成录入
  6218. /// Item
  6219. /// </summary>
  6220. /// <param name="_dto"></param>
  6221. /// <returns></returns>
  6222. [HttpPost]
  6223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6224. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  6225. {
  6226. var validator = new VisaCommissionItemDtoValidator();
  6227. var validatorRes = await validator.ValidateAsync(_dto);
  6228. if (!validatorRes.IsValid)
  6229. {
  6230. StringBuilder sb = new StringBuilder();
  6231. foreach (var item in validatorRes.Errors)
  6232. {
  6233. sb.AppendLine(item.ErrorMessage);
  6234. }
  6235. return Ok(JsonView(false, sb.ToString()));
  6236. }
  6237. return Ok(await _visaCommissionRep.Item(_dto));
  6238. }
  6239. /// <summary>
  6240. /// 签证提成录入
  6241. /// Save
  6242. /// </summary>
  6243. /// <param name="_dto"></param>
  6244. /// <returns></returns>
  6245. [HttpPost]
  6246. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6247. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  6248. {
  6249. //参数验证
  6250. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  6251. foreach (var item in _dto.Items)
  6252. {
  6253. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  6254. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  6255. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  6256. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  6257. }
  6258. return Ok(await _visaCommissionRep.Save(_dto));
  6259. }
  6260. /// <summary>
  6261. /// 签证提成录入
  6262. /// Create
  6263. /// </summary>
  6264. /// <param name="_dto"></param>
  6265. /// <returns></returns>
  6266. [HttpPost]
  6267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6268. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  6269. {
  6270. var validator = new VisaCommissionCreateDtoValidator();
  6271. var validatorRes = await validator.ValidateAsync(_dto);
  6272. if (!validatorRes.IsValid)
  6273. {
  6274. StringBuilder sb = new StringBuilder();
  6275. foreach (var item in validatorRes.Errors)
  6276. {
  6277. sb.AppendLine(item.ErrorMessage);
  6278. }
  6279. return Ok(JsonView(false, sb.ToString()));
  6280. }
  6281. return Ok(await _visaCommissionRep.Create(_dto));
  6282. }
  6283. /// <summary>
  6284. /// 签证提成录入
  6285. /// Put(编辑)
  6286. /// </summary>
  6287. /// <param name="id"></param>
  6288. /// <param name="_dto"></param>
  6289. /// <returns></returns>
  6290. [HttpPut]
  6291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6292. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  6293. {
  6294. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6295. var validator = new VisaCommissionCreateDtoValidator();
  6296. var validatorRes = await validator.ValidateAsync(_dto);
  6297. if (!validatorRes.IsValid)
  6298. {
  6299. StringBuilder sb = new StringBuilder();
  6300. foreach (var item in validatorRes.Errors)
  6301. {
  6302. sb.AppendLine(item.ErrorMessage);
  6303. }
  6304. return Ok(JsonView(false, sb.ToString()));
  6305. }
  6306. return Ok(await _visaCommissionRep.Edit(id, _dto));
  6307. }
  6308. /// <summary>
  6309. /// 签证提成录入
  6310. /// Del
  6311. /// </summary>
  6312. /// <param name="id"></param>
  6313. /// <param name="currUserId"></param>
  6314. /// <returns></returns>
  6315. [HttpPost]
  6316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6317. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  6318. {
  6319. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  6320. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  6321. return Ok(await _visaCommissionRep.Del(id, currUserId));
  6322. }
  6323. #endregion
  6324. #region op费用录入
  6325. /// <summary>
  6326. /// 根据diid查询op费用列表
  6327. /// </summary>
  6328. /// <param name="dto"></param>
  6329. /// <returns></returns>
  6330. [HttpPost]
  6331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6332. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  6333. {
  6334. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  6335. if (groupData.Code != 0)
  6336. {
  6337. return Ok(JsonView(false, groupData.Msg));
  6338. }
  6339. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6340. }
  6341. /// <summary>
  6342. /// 根据op费用Id查询单条数据及c表数据
  6343. /// </summary>
  6344. /// <param name="dto"></param>
  6345. /// <returns></returns>
  6346. [HttpPost]
  6347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6348. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  6349. {
  6350. try
  6351. {
  6352. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  6353. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  6354. var data = new
  6355. {
  6356. CarTouristGuideGround = _groupData,
  6357. CreditCardPayment = _creditCardPayment
  6358. };
  6359. return Ok(JsonView(true, "查询成功!", data));
  6360. }
  6361. catch (Exception ex)
  6362. {
  6363. return Ok(JsonView(false, "程序错误!"));
  6364. }
  6365. }
  6366. /// <summary>
  6367. /// op费用删除
  6368. /// </summary>
  6369. /// <param name="dto"></param>
  6370. /// <returns></returns>
  6371. [HttpPost]
  6372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6373. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  6374. {
  6375. try
  6376. {
  6377. _sqlSugar.BeginTran();
  6378. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  6379. if (!res)
  6380. {
  6381. return Ok(JsonView(false, "删除失败"));
  6382. }
  6383. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  6384. {
  6385. IsDel = 1,
  6386. DeleteUserId = dto.DeleteUserId,
  6387. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6388. }).ExecuteCommandAsync();
  6389. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  6390. {
  6391. IsDel = 1,
  6392. DeleteUserId = dto.DeleteUserId,
  6393. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6394. }).ExecuteCommandAsync();
  6395. #region 删除超支相关数据
  6396. //删除导入的超支数据
  6397. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  6398. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  6399. {
  6400. IsDel = 1,
  6401. DeleteUserId = dto.DeleteUserId,
  6402. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6403. }).ExecuteCommand();
  6404. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  6405. {
  6406. IsDel = 1,
  6407. DeleteUserId = dto.DeleteUserId,
  6408. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6409. }).ExecuteCommand();
  6410. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  6411. {
  6412. IsDel = 1,
  6413. DeleteUserId = dto.DeleteUserId,
  6414. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6415. }).ExecuteCommand();
  6416. #endregion
  6417. _sqlSugar.CommitTran();
  6418. return Ok(JsonView(true, "删除成功!"));
  6419. }
  6420. catch (Exception ex)
  6421. {
  6422. _sqlSugar.RollbackTran();
  6423. return Ok(JsonView(false, "程序错误!" + ex.Message));
  6424. }
  6425. }
  6426. /// <summary>
  6427. /// op费用录入操作(Status:1.新增,2.修改)
  6428. /// </summary>
  6429. /// <param name="dto"></param>
  6430. /// <returns></returns>
  6431. [HttpPost]
  6432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6433. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  6434. {
  6435. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  6436. if (groupData.Code != 0)
  6437. {
  6438. return Ok(JsonView(false, groupData.Msg));
  6439. }
  6440. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6441. }
  6442. /// <summary>
  6443. /// 填写费用详细页面初始化绑定
  6444. /// </summary>
  6445. /// <param name="dto"></param>
  6446. /// <returns></returns>
  6447. [HttpPost]
  6448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6449. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  6450. {
  6451. try
  6452. {
  6453. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  6454. if (groupData.Code != 0)
  6455. {
  6456. return Ok(JsonView(false, groupData.Msg));
  6457. }
  6458. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6459. }
  6460. catch (Exception ex)
  6461. {
  6462. return Ok(JsonView(false, ex.Message));
  6463. }
  6464. }
  6465. /// <summary>
  6466. /// 根据op费用Id查询详细数据
  6467. /// </summary>
  6468. /// <param name="dto"></param>
  6469. /// <returns></returns>
  6470. [HttpPost]
  6471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6472. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  6473. {
  6474. try
  6475. {
  6476. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  6477. if (groupData.Code != 0)
  6478. {
  6479. return Ok(JsonView(false, groupData.Msg));
  6480. }
  6481. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6482. }
  6483. catch (Exception ex)
  6484. {
  6485. return Ok(JsonView(false, ex.Message));
  6486. }
  6487. }
  6488. /// <summary>
  6489. /// OP费用录入填写详情
  6490. /// </summary>
  6491. /// <param name="dto"></param>
  6492. /// <returns></returns>
  6493. [HttpPost]
  6494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6495. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  6496. {
  6497. try
  6498. {
  6499. #region 参数校验
  6500. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  6501. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  6502. if (di == null) return Ok(JsonView(false, "团组错误!"));
  6503. #endregion
  6504. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  6505. if (groupData.Code != 0)
  6506. {
  6507. return Ok(JsonView(false, groupData.Msg));
  6508. }
  6509. //自动审核
  6510. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  6511. #region 应用推送
  6512. try
  6513. {
  6514. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6515. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6516. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6517. //2024-10-21 新增LZ UID
  6518. var userIds = new List<int>() { 21 };
  6519. string title = $"系统通知";
  6520. var diId = dto.DiId;
  6521. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6522. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6523. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  6524. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6525. }
  6526. catch (Exception ex)
  6527. {
  6528. }
  6529. #endregion
  6530. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6531. }
  6532. catch (Exception ex)
  6533. {
  6534. return Ok(JsonView(false, ex.Message));
  6535. }
  6536. }
  6537. /// <summary>
  6538. /// 获取三公详细所有城市
  6539. /// </summary>
  6540. /// <returns></returns>
  6541. [HttpGet]
  6542. public IActionResult OpCarCityResult()
  6543. {
  6544. var jw = JsonView(false);
  6545. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  6546. {
  6547. x.Id,
  6548. x.Country,
  6549. x.City,
  6550. }).ToList();
  6551. if (data.Count > 0)
  6552. {
  6553. jw = JsonView(true, "获取成功!", data);
  6554. }
  6555. else
  6556. {
  6557. jw.Msg = "城市数据为空!";
  6558. jw.Data = new string[0];
  6559. }
  6560. return Ok(jw);
  6561. }
  6562. /// <summary>
  6563. /// 导出地接费用明细
  6564. /// </summary>
  6565. /// <param name="dto"></param>
  6566. /// <returns></returns>
  6567. [HttpPost]
  6568. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  6569. {
  6570. var jw = JsonView(false);
  6571. if (dto.Diid < 1)
  6572. {
  6573. jw.Msg = "请输入正确的diid!";
  6574. return Ok(jw);
  6575. }
  6576. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6577. if (group == null)
  6578. {
  6579. jw.Msg = "未找到团组信息!";
  6580. return Ok(jw);
  6581. }
  6582. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  6583. if (localGuideArr.Count == 0)
  6584. {
  6585. jw.Msg = "该团组暂无地接信息!";
  6586. return Ok(jw);
  6587. }
  6588. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  6589. var overspendSoure = new Dictionary<int, int>
  6590. {
  6591. { 91, 982 }, //车
  6592. { 92 , 1059} ,//导游
  6593. { 994 , 1073}, //翻译
  6594. { 988 , 1074 }, //早餐
  6595. { 93 , 1075 }, //午餐
  6596. { 989 , 1076 }, //晚餐
  6597. };
  6598. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  6599. foreach (var groupArr in localGroup)
  6600. {
  6601. var keyValue = groupArr.Key;
  6602. if (int.TryParse(keyValue, out int cityid))
  6603. {
  6604. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  6605. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  6606. }
  6607. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  6608. foreach (var item in groupArr)
  6609. {
  6610. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  6611. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  6612. new Grp_CarTouristGuideGroundReservationsContentExtend
  6613. {
  6614. Count = a.Count,
  6615. CreateTime = a.CreateTime,
  6616. CreateUserId = a.CreateUserId,
  6617. CTGGRId = a.CTGGRId,
  6618. Currency = a.Currency,
  6619. DatePrice = a.DatePrice,
  6620. DeleteTime = a.DeleteTime,
  6621. DeleteUserId = a.DeleteUserId,
  6622. DiId = a.DiId,
  6623. Id = a.Id,
  6624. IsDel = a.IsDel,
  6625. Price = a.Price,
  6626. PriceContent = a.PriceContent,
  6627. Remark = a.Remark,
  6628. SId = a.SId,
  6629. SidName = b.Name,
  6630. Units = a.Units,
  6631. }
  6632. ).ToList();
  6633. if (content.Count > 0)
  6634. {
  6635. contentArr.Add(content);
  6636. }
  6637. }
  6638. //open excel
  6639. //set excel
  6640. //save excel
  6641. try
  6642. {
  6643. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  6644. IWorkbook workbook;
  6645. if (Path.GetExtension(filePath).ToLower() == ".xls")
  6646. {
  6647. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6648. }
  6649. else
  6650. {
  6651. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  6652. }
  6653. ISheet sheet = workbook.GetSheetAt(0);
  6654. var rowStartIndex = 2;
  6655. var clounmCount = 10;
  6656. var initStyleRow = sheet.GetRow(2);
  6657. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  6658. //var overspendArrDetail =
  6659. var existsId = new List<CarCompare>();
  6660. var lastElem = arr.Last();
  6661. var thisSid = -1;
  6662. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  6663. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  6664. {
  6665. Name = "未知币种!",
  6666. Remark = "未知币种!",
  6667. };
  6668. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  6669. Action cloneRowFn = () =>
  6670. {
  6671. rowStartIndex++;
  6672. var cloneRow = sheet.CreateRow(rowStartIndex);
  6673. // 复制样式
  6674. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  6675. {
  6676. ICell sourceCell = initStyleRow.GetCell(i);
  6677. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  6678. // 确保单元格存在样式
  6679. if (sourceCell.CellStyle != null)
  6680. {
  6681. targetCell.CellStyle = sourceCell.CellStyle;
  6682. }
  6683. }
  6684. };
  6685. var mergeRow = () =>
  6686. {
  6687. for (int i = 2; i < sheet.LastRowNum; i++)
  6688. {
  6689. var row = sheet.GetRow(i);
  6690. var cellFirst = row.GetCell(0);
  6691. var thisIndex = i + 1;
  6692. while (thisIndex < sheet.LastRowNum)
  6693. {
  6694. var nextRow = sheet.GetRow(thisIndex);
  6695. var nextCellFirst = nextRow.GetCell(0);
  6696. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  6697. {
  6698. thisIndex++;
  6699. }
  6700. else
  6701. {
  6702. break;
  6703. }
  6704. }
  6705. thisIndex--;
  6706. if (thisIndex != i)
  6707. {
  6708. //合并row
  6709. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6710. i, // 起始行索引(0-based)
  6711. thisIndex, // 结束行索引(0-based)
  6712. 0, // 起始列索引(0-based)
  6713. 0 // 结束列索引(0-based)
  6714. );
  6715. sheet.AddMergedRegion(cellRangeAddress);
  6716. i = thisIndex;
  6717. }
  6718. }
  6719. };
  6720. var chaoshiNumber = 0;
  6721. var totalNumber = 0.00M;
  6722. string lastStr = "";
  6723. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  6724. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  6725. {
  6726. b.IsAuditGM,
  6727. x.Id,
  6728. x.Area,
  6729. b.PayPercentage,
  6730. b.PayMoney,
  6731. }).ToList();
  6732. string yesPayment = "", noPayment = "";
  6733. foreach (var item in queryCarArrByCityAndDiid)
  6734. {
  6735. if (item.IsAuditGM == 1)
  6736. {
  6737. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6738. }
  6739. else
  6740. {
  6741. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6742. }
  6743. }
  6744. lastStr = yesPayment + noPayment;
  6745. foreach (var item in arr)
  6746. {
  6747. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  6748. {
  6749. if (thisSid != item.SId)
  6750. {
  6751. if (thisSid == -1)
  6752. {
  6753. thisSid = item.SId;
  6754. }
  6755. else
  6756. {
  6757. //合并小计行
  6758. //创建合并区域的实例
  6759. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6760. rowStartIndex, // 起始行索引(0-based)
  6761. rowStartIndex, // 结束行索引(0-based)
  6762. 0, // 起始列索引(0-based)
  6763. 3 // 结束列索引(0-based)
  6764. );
  6765. sheet.AddMergedRegion(cellRangeAddress);
  6766. var CellStyle = workbook.CreateCellStyle();
  6767. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6768. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6769. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6770. for (int i = 0; i <= clounmCount; i++)
  6771. {
  6772. if (i > 6)
  6773. {
  6774. var CellStyle1 = workbook.CreateCellStyle();
  6775. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6776. IFont Font = workbook.CreateFont(); // 创建字体
  6777. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6778. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6779. CellStyle1.SetFont(Font);
  6780. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6781. }
  6782. else
  6783. {
  6784. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6785. }
  6786. }
  6787. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6788. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6789. //超时合计
  6790. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6791. //超时数
  6792. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6793. //超时合计费用
  6794. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6795. thisSid = item.SId;
  6796. cloneRowFn();
  6797. chaoshiNumber = 0;
  6798. totalNumber = 0;
  6799. }
  6800. }
  6801. IRow row = sheet.GetRow(rowStartIndex);
  6802. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6803. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6804. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6805. if (isOpenOverspendSoure)
  6806. {
  6807. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6808. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6809. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6810. }
  6811. for (int i = 0; i <= clounmCount; i++)
  6812. {
  6813. var cell = row.GetCell(i);
  6814. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6815. if (cell == null)
  6816. {
  6817. cell = row.CreateCell(i);
  6818. }
  6819. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6820. fontRed.CloneStyleFrom(cell.CellStyle);
  6821. IFont Font = workbook.CreateFont(); // 创建字体
  6822. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6823. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6824. fontRed.SetFont(Font);
  6825. byte[] rgb = new byte[3] { 255, 242, 204 };
  6826. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6827. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6828. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6829. if (workbook is XSSFWorkbook)
  6830. {
  6831. BackgroundColor255_242_204.FillForegroundColor = 0;
  6832. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6833. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6834. }
  6835. else
  6836. {
  6837. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6838. }
  6839. if (i == 1 || i > 6)
  6840. {
  6841. if (i > 6)
  6842. {
  6843. fontRed.FillForegroundColor = 0;
  6844. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6845. fontRed.FillPattern = FillPattern.SolidForeground;
  6846. }
  6847. cell.CellStyle = fontRed;
  6848. }
  6849. if (i > 2 && i < 7)
  6850. {
  6851. cell.CellStyle = BackgroundColor255_242_204;
  6852. }
  6853. cell.SetCellValue(setCellValue); //写入单元格
  6854. }
  6855. if (overspendSoure.ContainsKey(thisSid))
  6856. {
  6857. var overspendId = overspendSoure[thisSid];
  6858. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6859. }
  6860. cloneRowFn();
  6861. existsId.Add(new CarCompare
  6862. {
  6863. DataPrice = item.DatePrice.ObjToDate(),
  6864. Sid = item.SId
  6865. });
  6866. }
  6867. if (item.Equals(lastElem))
  6868. {
  6869. //合并小计行
  6870. //创建合并区域的实例
  6871. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6872. rowStartIndex, // 起始行索引(0-based)
  6873. rowStartIndex, // 结束行索引(0-based)
  6874. 0, // 起始列索引(0-based)
  6875. 3 // 结束列索引(0-based)
  6876. );
  6877. sheet.AddMergedRegion(cellRangeAddress);
  6878. var CellStyle = workbook.CreateCellStyle();
  6879. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6880. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6881. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6882. for (int i = 0; i <= clounmCount; i++)
  6883. {
  6884. if (i > 6)
  6885. {
  6886. var CellStyle1 = workbook.CreateCellStyle();
  6887. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6888. IFont Font = workbook.CreateFont(); // 创建字体
  6889. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6890. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6891. CellStyle1.SetFont(Font);
  6892. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6893. }
  6894. else
  6895. {
  6896. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6897. }
  6898. }
  6899. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6900. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6901. //超时合计
  6902. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6903. //超时数
  6904. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6905. //超时合计费用
  6906. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6907. cloneRowFn();
  6908. // 创建合并区域的实例
  6909. cellRangeAddress = new CellRangeAddress(
  6910. rowStartIndex, // 起始行索引(0-based)
  6911. rowStartIndex, // 结束行索引(0-based)
  6912. 0, // 起始列索引(0-based)
  6913. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  6914. );
  6915. // 添加合并区域
  6916. sheet.AddMergedRegion(cellRangeAddress);
  6917. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  6918. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  6919. }
  6920. }
  6921. mergeRow();
  6922. // 保存修改后的Excel文件到新文件
  6923. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  6924. // new FileStream(newFilePath, FileMode.CreateNew)
  6925. using (var stream = new MemoryStream())
  6926. {
  6927. workbook.Write(stream, true);
  6928. stream.Flush();
  6929. stream.Seek(0, SeekOrigin.Begin);
  6930. MemoryStream memoryStream = new MemoryStream();
  6931. stream.CopyTo(memoryStream);
  6932. memoryStream.Seek(0, SeekOrigin.Begin);
  6933. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  6934. }
  6935. workbook.Close();
  6936. workbook.Dispose();
  6937. }
  6938. catch (Exception ex)
  6939. {
  6940. jw.Msg = "出现异常!" + ex.Message;
  6941. return Ok(jw);
  6942. }
  6943. }
  6944. if (Zips.Count > 0)
  6945. {
  6946. IOOperatorHelper io = new IOOperatorHelper();
  6947. var byts = io.ConvertZipStream(Zips);
  6948. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  6949. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  6950. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  6951. }
  6952. else
  6953. {
  6954. jw.Msg = "暂无生成文件!";
  6955. }
  6956. return Ok(jw);
  6957. }
  6958. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  6959. {
  6960. string outStr = string.Empty;
  6961. switch (i)
  6962. {
  6963. case 0:
  6964. outStr = arr[0].SidName;
  6965. break;
  6966. case 1:
  6967. outStr = arr[0].DataPriceStr;
  6968. break;
  6969. case 2:
  6970. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  6971. break;
  6972. case 4:
  6973. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  6974. break;
  6975. case 7:
  6976. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6977. {
  6978. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  6979. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  6980. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  6981. }
  6982. break;
  6983. case 8:
  6984. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6985. {
  6986. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  6987. }
  6988. break;
  6989. case 9:
  6990. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6991. {
  6992. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  6993. }
  6994. break;
  6995. case 10:
  6996. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6997. {
  6998. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  6999. }
  7000. break;
  7001. }
  7002. return outStr;
  7003. }
  7004. #region OP行程单
  7005. /// <summary>
  7006. /// OP行程单初始化
  7007. /// </summary>
  7008. /// <param name="dto"></param>
  7009. /// <returns></returns>
  7010. [HttpPost]
  7011. public IActionResult InitOpTravel(InitOpTravelDto dto)
  7012. {
  7013. var jw = JsonView(false);
  7014. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  7015. var group = groupList.First();
  7016. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  7017. if (group == null)
  7018. {
  7019. jw.Msg = "暂无团组!";
  7020. return Ok(jw);
  7021. }
  7022. group = groupList.Find(x => x.Id == diid);
  7023. if (group == null)
  7024. {
  7025. jw.Msg = "请输入正确的团组ID!";
  7026. return Ok(jw);
  7027. }
  7028. string city = string.Empty;
  7029. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  7030. if (blackCode.Count > 0)
  7031. {
  7032. var black = blackCode.First();
  7033. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  7034. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  7035. if (blackSp.Length > 0)
  7036. {
  7037. try
  7038. {
  7039. var cityArrCode = new List<string>(20);
  7040. foreach (var item in blackSp)
  7041. {
  7042. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  7043. var IndexSelect = itemSp[2];
  7044. var cityArrCodeLength = cityArrCode.Count - 1;
  7045. var startCity = IndexSelect.Substring(0, 3);
  7046. if (cityArrCodeLength > 0)
  7047. {
  7048. var arrEndCity = cityArrCode[cityArrCodeLength];
  7049. if (arrEndCity != startCity)
  7050. {
  7051. cityArrCode.Add(startCity.ToUpper());
  7052. }
  7053. }
  7054. else
  7055. {
  7056. cityArrCode.Add(startCity.ToUpper());
  7057. }
  7058. var endCity = IndexSelect.Substring(3, 3);
  7059. cityArrCode.Add(endCity.ToUpper());
  7060. }
  7061. var cityThree = string.Empty;
  7062. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  7063. cityThree = cityThree.TrimEnd(',');
  7064. if (string.IsNullOrWhiteSpace(cityThree))
  7065. {
  7066. throw new
  7067. Exception("error");
  7068. }
  7069. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  7070. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  7071. foreach (var item in cityArrCode)
  7072. {
  7073. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  7074. if (find != null)
  7075. {
  7076. city += find.City + "/";
  7077. }
  7078. else
  7079. {
  7080. city += item + "三字码未收入/";
  7081. }
  7082. }
  7083. city = city.TrimEnd('/');
  7084. }
  7085. catch (Exception e)
  7086. {
  7087. city = "黑屏代码格式不正确!";
  7088. }
  7089. }
  7090. }
  7091. else
  7092. {
  7093. city = "未录入黑屏代码";
  7094. }
  7095. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  7096. {
  7097. Date = x.Date,
  7098. Days = x.Days,
  7099. Diffgroup = x.Diffgroup,
  7100. Diid = x.Diid,
  7101. Traffic_First = x.Traffic_First,
  7102. Traffic_Second = x.Traffic_Second,
  7103. Trip = x.Trip,
  7104. WeekDay = x.WeekDay,
  7105. Id = x.Id
  7106. }).ToList();
  7107. jw.Data = new
  7108. {
  7109. groupList = groupList.Select(x => new
  7110. {
  7111. x.Id,
  7112. x.TeamName,
  7113. x.TourCode
  7114. }).ToList(),
  7115. groupInfo = new
  7116. {
  7117. group.VisitDays,
  7118. group.TourCode,
  7119. group.VisitPNumber,
  7120. group.TeamName,
  7121. city
  7122. },
  7123. OpTravelList
  7124. };
  7125. jw.Code = 200;
  7126. jw.Msg = "操作成功!";
  7127. return Ok(jw);
  7128. }
  7129. /// <summary>
  7130. /// 删除团组行程单
  7131. /// </summary>
  7132. /// <returns></returns>
  7133. [HttpPost]
  7134. public IActionResult DelTravel(DelOpTravelDto dto)
  7135. {
  7136. var jw = JsonView(false);
  7137. if (dto.UserId <= 0 || dto.Diid <= 0)
  7138. {
  7139. jw.Msg = "请输入正确的参数!";
  7140. return Ok(jw);
  7141. }
  7142. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  7143. .SetColumns(x => new Grp_TravelList
  7144. {
  7145. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7146. DeleteUserId = dto.UserId,
  7147. IsDel = 1,
  7148. }).ExecuteCommand();
  7149. jw = JsonView(true);
  7150. return Ok(jw);
  7151. }
  7152. /// <summary>
  7153. /// 行程单保存
  7154. /// </summary>
  7155. /// <returns></returns>
  7156. [HttpPost]
  7157. public IActionResult TravelSave(TravelSaveDto dto)
  7158. {
  7159. var jw = JsonView(false);
  7160. if (dto.Arr.Count > 0)
  7161. {
  7162. try
  7163. {
  7164. _sqlSugar.BeginTran();
  7165. foreach (var item in dto.Arr)
  7166. {
  7167. if (item.Id == 0)
  7168. {
  7169. throw new Exception("请传入正确的Id");
  7170. }
  7171. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  7172. .SetColumns(x => new Grp_TravelList
  7173. {
  7174. Trip = item.Trip
  7175. }).ExecuteCommand();
  7176. }
  7177. _sqlSugar.CommitTran();
  7178. jw = JsonView(true);
  7179. }
  7180. catch (Exception ex)
  7181. {
  7182. _sqlSugar.RollbackTran();
  7183. jw.Msg = "程序异常!" + ex.Message;
  7184. }
  7185. }
  7186. else
  7187. {
  7188. jw.Msg = "请传入正确的参数!";
  7189. }
  7190. return Ok(jw);
  7191. }
  7192. /// <summary>
  7193. /// 导出行程单
  7194. /// </summary>
  7195. /// <param name="dto"></param>
  7196. /// <returns></returns>
  7197. [HttpPost]
  7198. public IActionResult ExportTravel(ExportTravelDto dto)
  7199. {
  7200. var jw = JsonView(false);
  7201. jw.Data = "";
  7202. int diid = 0;
  7203. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  7204. if (Find == null)
  7205. {
  7206. jw.Msg = "请选择正确的团组!";
  7207. return Ok(jw);
  7208. }
  7209. else
  7210. {
  7211. diid = Find.Id;
  7212. }
  7213. //数据源
  7214. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  7215. DataTable dtBlack = null;
  7216. try
  7217. {
  7218. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  7219. }
  7220. catch (Exception)
  7221. {
  7222. jw.Msg = "机票黑屏代码有误!";
  7223. return Ok(jw);
  7224. }
  7225. string CityStr = string.Empty;
  7226. if (dtBlack.Rows.Count == 0)
  7227. {
  7228. jw.Msg = "机票黑屏代码有误!";
  7229. return Ok(jw);
  7230. }
  7231. else
  7232. {
  7233. foreach (DataRow row in dtBlack.Rows)
  7234. {
  7235. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  7236. {
  7237. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  7238. return Ok(jw);
  7239. }
  7240. }
  7241. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  7242. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  7243. }
  7244. //创建数据源Table
  7245. DataTable dtSource = new DataTable();
  7246. dtSource.Columns.Add("Days", typeof(string));
  7247. dtSource.Columns.Add("Date", typeof(string));
  7248. dtSource.Columns.Add("Week", typeof(string));
  7249. dtSource.Columns.Add("Traffic", typeof(string));
  7250. dtSource.Columns.Add("Trip", typeof(string));
  7251. //获取数据,放到datatable
  7252. foreach (var item in _travelList)
  7253. {
  7254. DataRow dr = dtSource.NewRow();
  7255. dr["Days"] = item.Days;
  7256. dr["Date"] = item.Date;
  7257. dr["Week"] = item.WeekDay;
  7258. dr["Traffic"] = item.Traffic_First
  7259. + "\r\n"
  7260. + item.Traffic_Second;
  7261. dr["Trip"] = item.Trip;
  7262. dtSource.Rows.Add(dr);
  7263. }
  7264. Dictionary<string, string> dic = new Dictionary<string, string>();
  7265. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  7266. dic.Add("City", CityStr);
  7267. dic.Add("Days", Find.VisitDays.ToString());
  7268. dic.Add("DeleCode", Find.TourCode);
  7269. dic.Add("Pnum", Find.VisitPNumber.ToString());
  7270. //模板路径
  7271. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  7272. //载入模板
  7273. Document doc = null;
  7274. DocumentBuilder builder = null;
  7275. try
  7276. {
  7277. //载入模板
  7278. doc = new Document(tempPath);
  7279. builder = new DocumentBuilder(doc);
  7280. }
  7281. catch (Exception)
  7282. {
  7283. jw.Msg = "模板位置不存在!";
  7284. return Ok(jw);
  7285. }
  7286. foreach (var key in dic.Keys)
  7287. {
  7288. Bookmark bookmark = doc.Range.Bookmarks[key];
  7289. if (bookmark != null)
  7290. {
  7291. builder.MoveToBookmark(key);
  7292. builder.Write(dic[key]);
  7293. }
  7294. }
  7295. //获取word里所有表格
  7296. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7297. //获取所填表格的序数
  7298. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7299. try
  7300. {
  7301. //循环赋值
  7302. for (int i = 0; i < dtSource.Rows.Count; i++)
  7303. {
  7304. builder.MoveToCell(0, i + 1, 0, 0);
  7305. builder.Write(dtSource.Rows[i]["Days"].ToString());
  7306. builder.MoveToCell(0, i + 1, 1, 0);
  7307. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  7308. builder.MoveToCell(0, i + 1, 2, 0);
  7309. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  7310. var trip = dtSource.Rows[i]["Trip"].ToString();
  7311. builder.MoveToCell(0, i + 1, 3, 0);
  7312. builder.Write(trip);
  7313. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  7314. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7315. // 获取特定索引的段落
  7316. Paragraph paragraph = (Paragraph)paragraphs[0];
  7317. Run run = paragraph.Runs[0];
  7318. Aspose.Words.Font font = run.Font;
  7319. font.Name = "黑体";
  7320. //设置双休红色
  7321. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  7322. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  7323. paragraph = (Paragraph)paragraphs[1];
  7324. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  7325. {
  7326. run = paragraph.Runs[0];
  7327. font = run.Font;
  7328. font.Color = Color.Red;
  7329. }
  7330. }
  7331. }
  7332. catch (Exception ex)
  7333. {
  7334. }
  7335. //删除多余行
  7336. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  7337. {
  7338. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  7339. }
  7340. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  7341. if (!Directory.Exists(savePath))
  7342. {
  7343. try
  7344. {
  7345. Directory.CreateDirectory(savePath);
  7346. }
  7347. catch
  7348. {
  7349. }
  7350. }
  7351. string path = savePath + Find.TeamName + "出访日程";
  7352. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  7353. try
  7354. {
  7355. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  7356. string postfix = ".docx";
  7357. if (dto.IsPDF == 1)
  7358. {
  7359. saveFormat = Aspose.Words.SaveFormat.Pdf;
  7360. postfix = ".pdf";
  7361. }
  7362. doc.Save(path + postfix, saveFormat);
  7363. jw = JsonView(true, "导出成功", ftpPath + postfix);
  7364. }
  7365. catch (Exception)
  7366. {
  7367. jw = JsonView(false);
  7368. }
  7369. return Ok(jw);
  7370. }
  7371. /// <summary>
  7372. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  7373. /// </summary>
  7374. /// <param name="num"></param>
  7375. /// <returns></returns>
  7376. string GetNum(string num)
  7377. {
  7378. string str = "";
  7379. switch (num)
  7380. {
  7381. case "1":
  7382. str = "一";
  7383. break;
  7384. case "2":
  7385. str = "二";
  7386. break;
  7387. case "3":
  7388. str = "三";
  7389. break;
  7390. case "4":
  7391. str = "四";
  7392. break;
  7393. case "5":
  7394. str = "五";
  7395. break;
  7396. case "6":
  7397. str = "六";
  7398. break;
  7399. case "7":
  7400. str = "七";
  7401. break;
  7402. case "8":
  7403. str = "八";
  7404. break;
  7405. case "9":
  7406. str = "九";
  7407. break;
  7408. case "10":
  7409. str = "十";
  7410. break;
  7411. case "11":
  7412. str = "十一";
  7413. break;
  7414. case "12":
  7415. str = "十二";
  7416. break;
  7417. case "一":
  7418. str = "1";
  7419. break;
  7420. case "二":
  7421. str = "2";
  7422. break;
  7423. case "三":
  7424. str = "3";
  7425. break;
  7426. case "四":
  7427. str = "4";
  7428. break;
  7429. case "五":
  7430. str = "5";
  7431. break;
  7432. case "六":
  7433. str = "6";
  7434. break;
  7435. case "七":
  7436. str = "7";
  7437. break;
  7438. case "八":
  7439. str = "8";
  7440. break;
  7441. case "九":
  7442. str = "9";
  7443. break;
  7444. case "十":
  7445. str = "10";
  7446. break;
  7447. case "十一":
  7448. str = "11";
  7449. break;
  7450. case "十二":
  7451. str = "12";
  7452. break;
  7453. }
  7454. return str;
  7455. }
  7456. #endregion
  7457. #endregion
  7458. #region 团组成本
  7459. /// <summary>
  7460. /// 团组成本数据初始化
  7461. /// </summary>
  7462. /// <param name="dto"></param>
  7463. /// <returns></returns>
  7464. [HttpPost]
  7465. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  7466. {
  7467. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  7468. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  7469. WHEN COUNT(*) >= 0 THEN 'True'
  7470. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  7471. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  7472. ").ToList(); //团组列表
  7473. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  7474. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  7475. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  7476. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  7477. if (groupinfoValue != null)
  7478. {
  7479. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  7480. var spArr = new string[1] { countryArr };
  7481. if (countryArr.Contains("|"))
  7482. {
  7483. spArr = countryArr.Split("|");
  7484. }
  7485. else if (countryArr.Contains("、"))
  7486. {
  7487. spArr = countryArr.Split("、");
  7488. }
  7489. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  7490. {
  7491. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  7492. if (dbQueryCountry != null)
  7493. {
  7494. visaCountryInfoArr.Add(dbQueryCountry);
  7495. }
  7496. }
  7497. }
  7498. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  7499. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  7500. var create = _GroupCostRepository.
  7501. CreateGroupCostByBlackCode(dto.Diid);
  7502. if (groupCost.Count == 0 && create.Code == 0)
  7503. {
  7504. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  7505. }
  7506. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  7507. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  7508. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  7509. groupCostMap = groupCostMap.Select(x =>
  7510. {
  7511. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  7512. {
  7513. x.Date = dataForamt.ToString("yyyy-MM-dd");
  7514. }
  7515. return x;
  7516. }).ToList();
  7517. //GroupCostParameter.Add(new
  7518. // Grp_GroupCostParameter());
  7519. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  7520. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  7521. return Ok(JsonView(new
  7522. {
  7523. groupList,
  7524. groupInfo,
  7525. groupChecks,
  7526. groupCost = groupCostMap,
  7527. hotelNumber,
  7528. GroupCostParameter = GroupCostParameterMap,
  7529. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  7530. {
  7531. x.VisaCountry,
  7532. x.VisaPrice,
  7533. x.Id,
  7534. }).ToList(),
  7535. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  7536. blackCodeIsTrue = create.Code == 0 ? true : false,
  7537. hotelIsTrue = hotelIsTrue,
  7538. }));
  7539. }
  7540. /// <summary>
  7541. /// 团组成本信息保存
  7542. /// </summary>
  7543. /// <param name="dto"></param>
  7544. /// <returns></returns>
  7545. [HttpPost]
  7546. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  7547. {
  7548. if (dto.Diid <= 0 || dto.Userid <= 0)
  7549. {
  7550. return Ok(JsonView(false));
  7551. }
  7552. JsonView jw = null;
  7553. bool isTrue = false;
  7554. #region 复制团组成本
  7555. //if (dto.Diid == 2581)
  7556. //{
  7557. // dto.Diid = 2599;
  7558. // dto.CheckBoxs.ForEach(x =>
  7559. // {
  7560. // x.Diid = 2599;
  7561. // });
  7562. // dto.GroupCosts.ForEach(x =>
  7563. // {
  7564. // x.Diid = 2599;
  7565. // });
  7566. // dto.CostTypeHotelNumbers.ForEach(x =>
  7567. // {
  7568. // x.Diid = 2599;
  7569. // });
  7570. // dto.GroupCostParameters.ForEach(x =>
  7571. // {
  7572. // x.DiId = 2599;
  7573. // });
  7574. //}
  7575. #endregion
  7576. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  7577. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  7578. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  7579. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  7580. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  7581. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  7582. try
  7583. {
  7584. _sqlSugar.BeginTran();
  7585. isTrue = await _GroupCostRepository.
  7586. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  7587. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  7588. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  7589. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  7590. _sqlSugar.CommitTran();
  7591. jw = JsonView(true, "保存成功!", isTrue);
  7592. }
  7593. catch (Exception)
  7594. {
  7595. _sqlSugar.RollbackTran();
  7596. jw = JsonView(false);
  7597. }
  7598. return Ok(jw);
  7599. }
  7600. /// <summary>
  7601. /// 司兼导数据
  7602. /// </summary>
  7603. /// <param name="dto"></param>
  7604. /// <returns></returns>
  7605. [HttpPost]
  7606. public IActionResult GetCarGuides(CarGuidesDto dto)
  7607. {
  7608. JsonView jw = null;
  7609. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  7610. jw = JsonView(true, "获取成功!", Data);
  7611. return Ok(jw);
  7612. }
  7613. /// <summary>
  7614. /// 导游数据
  7615. /// </summary>
  7616. /// <param name="dto"></param>
  7617. /// <returns></returns>
  7618. [HttpPost]
  7619. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  7620. {
  7621. JsonView jw = null;
  7622. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  7623. // 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
  7624. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  7625. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  7626. jw = JsonView(true, "获取成功!", Data);
  7627. return Ok(jw);
  7628. }
  7629. /// <summary>
  7630. /// 成本车数据
  7631. /// </summary>
  7632. /// <param name="dto"></param>
  7633. /// <returns></returns>
  7634. [HttpPost]
  7635. public IActionResult GetCarInfo(CarGuidesDto dto)
  7636. {
  7637. JsonView jw = null;
  7638. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  7639. jw = JsonView(true, "获取成功!", Data);
  7640. return Ok(jw);
  7641. }
  7642. /// <summary>
  7643. /// 景点数据
  7644. /// </summary>
  7645. /// <param name="dto"></param>
  7646. /// <returns></returns>
  7647. [HttpPost]
  7648. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  7649. {
  7650. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  7651. return Ok(JsonView(true, "获取成功!", Data));
  7652. }
  7653. /// <summary>
  7654. /// 成本通知
  7655. /// </summary>
  7656. /// <param name="dto"></param>
  7657. /// <returns></returns>
  7658. [HttpPost]
  7659. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  7660. {
  7661. if (dto.Diid < 0)
  7662. {
  7663. return Ok(JsonView(false));
  7664. }
  7665. JsonView jw = null;
  7666. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  7667. if (GroupCostParameter != null)
  7668. {
  7669. int IsShare = 0;
  7670. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  7671. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  7672. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  7673. string msg = string.Empty;
  7674. if (isTrue)
  7675. {
  7676. if (IsShare == 0)
  7677. {
  7678. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  7679. }
  7680. else
  7681. {
  7682. #region 企微通知对应岗位用户
  7683. try
  7684. {
  7685. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  7686. }
  7687. catch (Exception ex)
  7688. {
  7689. }
  7690. #endregion
  7691. msg = "通知成功,其他模块操作人员可见此成本信息!";
  7692. }
  7693. jw = JsonView(isTrue, msg, new { IsShare });
  7694. }
  7695. else
  7696. {
  7697. msg = "修改失败!";
  7698. jw = JsonView(isTrue, msg);
  7699. }
  7700. }
  7701. else
  7702. {
  7703. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  7704. }
  7705. return Ok(jw);
  7706. }
  7707. /// <summary>
  7708. /// 导出报价单
  7709. /// </summary>
  7710. /// <param name="dto"></param>
  7711. /// <returns></returns>
  7712. [HttpPost]
  7713. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  7714. {
  7715. if (dto.Diid == 0)
  7716. {
  7717. return Ok(JsonView(false, "请传递团组id"));
  7718. }
  7719. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7720. if (deleInfo.Code != 0)
  7721. {
  7722. return Ok(JsonView(false, "团组信息查询失败!"));
  7723. }
  7724. var di = deleInfo.Data as DelegationInfoWebView;
  7725. if (di != null)
  7726. {
  7727. di.TeamName = di.TeamName.Replace("|", "、");
  7728. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  7729. //文件名
  7730. string strFileName = di.TeamName + "-收款账单.doc";
  7731. //获取模板
  7732. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  7733. //载入模板
  7734. Document doc = new Document(tmppath);
  7735. decimal TotalPrice = 0.00M;
  7736. string itemStr = string.Empty;
  7737. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  7738. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7739. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7740. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7741. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7742. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7743. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7744. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7745. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7746. foreach (var cost in groupCostType)
  7747. {
  7748. var List = cost.ToList();
  7749. if (cost.Key == "A")
  7750. {
  7751. foreach (var ListItem in List)
  7752. {
  7753. if (ListItem.number > 0)
  7754. {
  7755. if (ListItem.code.Contains("TBR"))
  7756. {
  7757. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7758. }
  7759. else
  7760. {
  7761. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7762. }
  7763. TotalPrice += (ListItem.number * ListItem.price);
  7764. }
  7765. }
  7766. }
  7767. else
  7768. {
  7769. itemStr = itemStr.Insert(0, "A段\r\n");
  7770. itemStr += "B段\r\n";
  7771. foreach (var ListItem in List)
  7772. {
  7773. if (ListItem.number > 0)
  7774. {
  7775. if (ListItem.code.Contains("TBR"))
  7776. {
  7777. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7778. }
  7779. else
  7780. {
  7781. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7782. }
  7783. TotalPrice += (ListItem.number * ListItem.price);
  7784. }
  7785. }
  7786. }
  7787. }
  7788. #region 替换Word模板书签内容
  7789. Dictionary<string, string> marks = new Dictionary<string, string>();
  7790. marks.Add("To", di.ClientUnit);//付款方
  7791. marks.Add("ToTel", di.TellPhone);//付款方电话
  7792. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7793. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7794. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7795. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7796. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7797. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7798. marks.Add("PayItemContent", itemStr);//详细信息
  7799. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7800. #endregion
  7801. ////注
  7802. //if (doc.Range.Bookmarks["Attention"] != null)
  7803. //{
  7804. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7805. // mark.Text = frList[0].Attention;
  7806. //}
  7807. foreach (var item in marks.Keys)
  7808. {
  7809. if (doc.Range.Bookmarks[item] != null)
  7810. {
  7811. Bookmark mark = doc.Range.Bookmarks[item];
  7812. mark.Text = marks[item];
  7813. }
  7814. }
  7815. byte[] bytes = null;
  7816. using (MemoryStream stream = new MemoryStream())
  7817. {
  7818. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7819. bytes = stream.ToArray();
  7820. }
  7821. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7822. return Ok(JsonView(true, "", new
  7823. {
  7824. Data = bytes,
  7825. strFileName,
  7826. }));
  7827. }
  7828. else
  7829. {
  7830. return Ok(JsonView(false, "团组信息不存在!"));
  7831. }
  7832. }
  7833. /// <summary>
  7834. /// 导出团组成本
  7835. /// </summary>
  7836. /// <param name="dto"></param>
  7837. /// <returns></returns>
  7838. [HttpPost]
  7839. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7840. {
  7841. var jw = JsonView(false);
  7842. if (dto.Diid == 0)
  7843. {
  7844. return Ok(JsonView(false, "请传递团组id"));
  7845. }
  7846. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7847. if (deleInfo.Code != 0)
  7848. {
  7849. return Ok(JsonView(false, "团组信息查询失败!"));
  7850. }
  7851. var di = deleInfo.Data as DelegationInfoWebView;
  7852. if (di == null)
  7853. {
  7854. return Ok(JsonView(false, "团组信息查询失败!"));
  7855. }
  7856. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7857. WorkbookDesigner designer = new WorkbookDesigner();
  7858. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7859. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7860. for (int i = 0; i < List_GC.Count; i++)
  7861. {
  7862. GroupCost_Excel gc = new GroupCost_Excel();
  7863. gc.Id = List_GC[i].Id;
  7864. gc.Diid = List_GC[i].Diid.ToString();
  7865. gc.DAY = List_GC[i].DAY;
  7866. string week = "";
  7867. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7868. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7869. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7870. gc.ITIN = List_GC[i].ITIN;
  7871. gc.CarType = List_GC[i].CarType;
  7872. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7873. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7874. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7875. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7876. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7877. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7878. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7879. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7880. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7881. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7882. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7883. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7884. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7885. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7886. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7887. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7888. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7889. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7890. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7891. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7892. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7893. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7894. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7895. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7896. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7897. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7898. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7899. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7900. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7901. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7902. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7903. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7904. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7905. List_GC1.Add(gc);
  7906. }
  7907. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7908. dt.TableName = "TB";
  7909. //报表标题等不用dt的值
  7910. designer.SetDataSource("TeamName", dto.title.TeamName);
  7911. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7912. designer.SetDataSource("Tax", dto.title.Tax);
  7913. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7914. designer.SetDataSource("Currency", dto.title.Currency);
  7915. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7916. designer.SetDataSource("Rate", dto.title.Rate);
  7917. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7918. var Aparams = hotels.Find(x => x.Type == "Default");
  7919. if (Aparams == null)
  7920. {
  7921. return Ok(jw);
  7922. }
  7923. //酒店数量
  7924. var txtSGRNumber = Aparams.SGR.ToString();
  7925. var txtTBRNumber = Aparams.TBR.ToString();
  7926. var txtJSESNumber = Aparams.JSES.ToString();
  7927. var txtSUITENumbe = Aparams.SUITE.ToString();
  7928. if (dto.costType == "B")
  7929. {
  7930. Aparams = hotels.Find(x => x.Type == "A");
  7931. var Bparams = hotels.Find(x => x.Type == "B");
  7932. if (Aparams == null || Bparams == null)
  7933. {
  7934. return Ok(jw);
  7935. }
  7936. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7937. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7938. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7939. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7940. }
  7941. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7942. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7943. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7944. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7945. var ws = designer.Workbook.Worksheets[0];
  7946. int Row = List_GC.Count;
  7947. int startIndex = 11;
  7948. int HideRows = 0;
  7949. List<int> hideRowsList = new List<int>();
  7950. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7951. #region A段left数据
  7952. var left = dto.leftInfo.Find(x => x.Type == "A");
  7953. if (left == null)
  7954. {
  7955. return Ok(jw);
  7956. }
  7957. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7958. if (leftBindData != null)
  7959. {
  7960. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7961. designer.SetDataSource("VisaRS", leftBindData.rs);
  7962. designer.SetDataSource("VisaXS", leftBindData.xs);
  7963. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7964. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7965. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7966. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7967. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7968. }
  7969. else
  7970. {
  7971. hideRowsList.Add(Row + startIndex + HideRows);
  7972. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7973. }
  7974. HideRows += 2;
  7975. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7976. if (leftBindData != null)
  7977. {
  7978. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7979. designer.SetDataSource("BXRS", leftBindData.rs);
  7980. designer.SetDataSource("BXXS", leftBindData.xs);
  7981. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7982. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7983. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7984. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7985. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7986. }
  7987. else
  7988. {
  7989. hideRowsList.Add(Row + startIndex + HideRows);
  7990. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7991. }
  7992. HideRows += 2;
  7993. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7994. if (leftBindData != null)
  7995. {
  7996. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7997. designer.SetDataSource("HSRS", leftBindData.rs);
  7998. designer.SetDataSource("HSXS", leftBindData.xs);
  7999. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8000. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8001. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8002. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8003. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8004. }
  8005. else
  8006. {
  8007. hideRowsList.Add(Row + startIndex + HideRows);
  8008. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8009. }
  8010. HideRows += 2;
  8011. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  8012. if (leftBindData != null)
  8013. {
  8014. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  8015. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  8016. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  8017. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8018. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8019. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8020. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8021. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8022. }
  8023. else
  8024. {
  8025. hideRowsList.Add(Row + startIndex + HideRows);
  8026. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8027. }
  8028. HideRows += 2;
  8029. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  8030. if (leftBindData != null)
  8031. {
  8032. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  8033. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  8034. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  8035. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8036. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8037. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8038. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8039. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8040. }
  8041. else
  8042. {
  8043. hideRowsList.Add(Row + startIndex + HideRows);
  8044. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8045. }
  8046. HideRows += 2;
  8047. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  8048. if (leftBindData != null)
  8049. {
  8050. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  8051. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  8052. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  8053. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8054. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8055. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8056. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8057. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8058. }
  8059. else
  8060. {
  8061. hideRowsList.Add(Row + startIndex + HideRows);
  8062. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8063. }
  8064. HideRows += 2;
  8065. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8066. if (leftBindData != null)
  8067. {
  8068. ////TBR
  8069. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  8070. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  8071. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  8072. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8073. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8074. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8075. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8076. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8077. }
  8078. else
  8079. {
  8080. hideRowsList.Add(Row + startIndex + HideRows);
  8081. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8082. }
  8083. HideRows += 2;
  8084. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8085. if (leftBindData != null)
  8086. {
  8087. ////SGR
  8088. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  8089. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  8090. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  8091. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8092. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8093. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8094. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8095. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8096. }
  8097. else
  8098. {
  8099. hideRowsList.Add(Row + startIndex + HideRows);
  8100. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8101. }
  8102. HideRows += 2;
  8103. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8104. if (leftBindData != null)
  8105. {
  8106. ////JS/ES
  8107. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  8108. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  8109. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  8110. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8111. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8112. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8113. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8114. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8115. }
  8116. else
  8117. {
  8118. hideRowsList.Add(Row + startIndex + HideRows);
  8119. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8120. }
  8121. HideRows += 2;
  8122. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8123. if (leftBindData != null)
  8124. {
  8125. ////SUITE
  8126. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  8127. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  8128. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  8129. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8130. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8131. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8132. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8133. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8134. }
  8135. else
  8136. {
  8137. hideRowsList.Add(Row + startIndex + HideRows);
  8138. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8139. }
  8140. HideRows += 2;
  8141. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  8142. if (leftBindData != null)
  8143. {
  8144. designer.SetDataSource("DJDRCB", leftBindData.cb);
  8145. designer.SetDataSource("DJRS", leftBindData.rs);
  8146. designer.SetDataSource("DJXS", leftBindData.xs);
  8147. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8148. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8149. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8150. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8151. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8152. }
  8153. else
  8154. {
  8155. hideRowsList.Add(Row + startIndex + HideRows);
  8156. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8157. }
  8158. HideRows += 2;
  8159. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  8160. if (leftBindData != null)
  8161. {
  8162. designer.SetDataSource("HCPCB", leftBindData.cb);
  8163. designer.SetDataSource("HCPRS", leftBindData.rs);
  8164. designer.SetDataSource("HCPXS", leftBindData.xs);
  8165. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8166. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8167. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8168. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8169. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8170. }
  8171. else
  8172. {
  8173. hideRowsList.Add(Row + startIndex + HideRows);
  8174. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8175. }
  8176. HideRows += 2;
  8177. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8178. if (leftBindData != null)
  8179. {
  8180. designer.SetDataSource("CPCB", leftBindData.cb);
  8181. designer.SetDataSource("CPRS", leftBindData.rs);
  8182. designer.SetDataSource("CPXS", leftBindData.xs);
  8183. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8184. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8185. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8186. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8187. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8188. }
  8189. else
  8190. {
  8191. hideRowsList.Add(Row + startIndex + HideRows);
  8192. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8193. }
  8194. HideRows += 2;
  8195. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8196. if (leftBindData != null)
  8197. {
  8198. designer.SetDataSource("GWDRCD", leftBindData.cb);
  8199. designer.SetDataSource("GWRS", leftBindData.rs);
  8200. designer.SetDataSource("GWXS", leftBindData.xs);
  8201. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8202. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8203. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8204. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8205. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8206. }
  8207. else
  8208. {
  8209. hideRowsList.Add(Row + startIndex + HideRows);
  8210. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8211. }
  8212. HideRows += 2;
  8213. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8214. if (leftBindData != null)
  8215. {
  8216. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  8217. designer.SetDataSource("LYJRS", leftBindData.rs);
  8218. designer.SetDataSource("LYJXS", leftBindData.xs);
  8219. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8220. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8221. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8222. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8223. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8224. }
  8225. else
  8226. {
  8227. hideRowsList.Add(Row + startIndex + HideRows);
  8228. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  8229. }
  8230. #endregion
  8231. #region A段Right信息
  8232. var right = dto.rightInfo.Find(x => x.Type == "A");
  8233. if (right == null)
  8234. {
  8235. return Ok(jw);
  8236. }
  8237. HideRows += 4;
  8238. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8239. if (rightBindData != null)
  8240. {
  8241. //经济舱 + 双人间 TBR
  8242. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  8243. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  8244. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8245. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  8246. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8247. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8248. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8249. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8250. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8251. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8252. }
  8253. else
  8254. {
  8255. hideRowsList.Add(Row + startIndex + HideRows);
  8256. }
  8257. HideRows += 2;
  8258. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8259. if (rightBindData != null)
  8260. {
  8261. //经济舱 + 单人间 SGR
  8262. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  8263. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  8264. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8265. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  8266. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8267. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8268. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8269. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8270. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8271. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8272. }
  8273. else
  8274. {
  8275. hideRowsList.Add(Row + startIndex + HideRows);
  8276. }
  8277. HideRows += 2;
  8278. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8279. if (rightBindData != null)
  8280. {
  8281. //公务舱 + 单人间 SGR
  8282. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  8283. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  8284. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8285. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  8286. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8287. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8288. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8289. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8290. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8291. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8292. }
  8293. else
  8294. {
  8295. hideRowsList.Add(Row + startIndex + HideRows);
  8296. }
  8297. HideRows += 2;
  8298. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8299. if (rightBindData != null)
  8300. {
  8301. //公务舱 + 小套房 JSES
  8302. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  8303. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  8304. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8305. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  8306. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8307. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8308. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8309. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8310. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8311. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8312. }
  8313. else
  8314. {
  8315. hideRowsList.Add(Row + startIndex + HideRows);
  8316. }
  8317. HideRows += 2;
  8318. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8319. if (rightBindData != null)
  8320. {
  8321. //公务舱 + 小套房 JSES
  8322. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  8323. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  8324. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8325. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  8326. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8327. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8328. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8329. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8330. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8331. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8332. }
  8333. else
  8334. {
  8335. hideRowsList.Add(Row + startIndex + HideRows);
  8336. }
  8337. HideRows += 2;
  8338. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8339. if (rightBindData != null)
  8340. {
  8341. //经济舱 + 大套房
  8342. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  8343. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  8344. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8345. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  8346. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8347. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8348. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8349. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8350. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8351. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8352. }
  8353. else
  8354. {
  8355. hideRowsList.Add(Row + startIndex + HideRows);
  8356. }
  8357. HideRows += 2;
  8358. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8359. if (rightBindData != null)
  8360. {
  8361. //头等舱 + 小套房 JSES
  8362. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  8363. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  8364. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8365. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  8366. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8367. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8368. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8369. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8370. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8371. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8372. }
  8373. else
  8374. {
  8375. hideRowsList.Add(Row + startIndex + HideRows);
  8376. }
  8377. HideRows += 2;
  8378. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8379. if (rightBindData != null)
  8380. {
  8381. //头等舱 + 大套房
  8382. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  8383. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  8384. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8385. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  8386. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8387. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8388. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8389. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8390. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8391. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8392. }
  8393. else
  8394. {
  8395. hideRowsList.Add(Row + startIndex + HideRows);
  8396. }
  8397. #endregion
  8398. #region B段标题清空
  8399. designer.SetDataSource("CostBDRCB", "");
  8400. designer.SetDataSource("CostBRS", "");
  8401. designer.SetDataSource("CostBXS", "");
  8402. designer.SetDataSource("CostBZCB", "");
  8403. designer.SetDataSource("CostBDRBJ", "");
  8404. designer.SetDataSource("CostBZBJ", "");
  8405. designer.SetDataSource("CostBDRLR", "");
  8406. designer.SetDataSource("CostBZLR", "");
  8407. designer.SetDataSource("CostBDRCBOM", "");
  8408. designer.SetDataSource("CostBRSOM", "");
  8409. designer.SetDataSource("CostBZCBOM", "");
  8410. designer.SetDataSource("CostBDRBJOM", "");
  8411. designer.SetDataSource("CostBZBJOM", "");
  8412. designer.SetDataSource("CostBDRLROM", "");
  8413. designer.SetDataSource("CostBZLROM", "");
  8414. #endregion
  8415. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  8416. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  8417. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  8418. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  8419. designer.SetDataSource("DJName", "地接(CNY)");
  8420. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  8421. designer.SetDataSource("CPName", "地接-船票(CNY)");
  8422. designer.SetDataSource("GWName", "公务(CNY)");
  8423. designer.SetDataSource("YQHName", "邀请函(CNY)");
  8424. designer.SetDataSource("LYJName", "零用金(CNY)");
  8425. designer.SetDataSource("HSName", "核酸检测(CNY)");
  8426. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  8427. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  8428. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  8429. designer.SetDataSource("BXName", "保险(CNY)");
  8430. designer.SetDataSource("VisaName", "签证(CNY)");
  8431. #region B段基本数据
  8432. if (dto.costType == "B")
  8433. {
  8434. left = dto.leftInfo.Find(x => x.Type == "B");
  8435. if (left == null)
  8436. {
  8437. return Ok(jw);
  8438. }
  8439. #region B段left数据
  8440. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  8441. if (leftBindData != null)
  8442. {
  8443. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  8444. designer.SetDataSource("BHSRS", leftBindData.rs);
  8445. designer.SetDataSource("BHSXS", leftBindData.xs);
  8446. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8447. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8448. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8449. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8450. designer.SetDataSource("BHSZLR", ((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("BJPJJCCB", leftBindData.cb);
  8456. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  8457. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  8458. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8459. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8460. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8461. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8462. designer.SetDataSource("BJPJJCZLR", ((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("BJPGWCCB", leftBindData.cb);
  8468. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  8469. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  8470. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8471. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8472. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8473. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8474. designer.SetDataSource("BJPGWCZLR", ((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("BJPTDCCB", leftBindData.cb);
  8480. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  8481. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  8482. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8483. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8484. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8485. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8486. designer.SetDataSource("BJPTDCZLR", ((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("BHCPCB", leftBindData.cb);
  8492. designer.SetDataSource("BHCPRS", leftBindData.rs);
  8493. designer.SetDataSource("BHCPXS", leftBindData.xs);
  8494. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8495. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8496. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8497. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8498. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8499. }
  8500. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  8501. if (leftBindData != null)
  8502. {
  8503. designer.SetDataSource("BCPCB", leftBindData.cb);
  8504. designer.SetDataSource("BCPRS", leftBindData.rs);
  8505. designer.SetDataSource("BCPXS", leftBindData.xs);
  8506. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8507. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8508. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8509. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8510. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8511. }
  8512. //TBR
  8513. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  8514. if (leftBindData != null)
  8515. {
  8516. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  8517. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  8518. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  8519. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8520. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8521. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8522. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8523. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8524. }
  8525. //SGR
  8526. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  8527. if (leftBindData != null)
  8528. {
  8529. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  8530. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  8531. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  8532. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8533. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8534. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8535. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8536. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8537. }
  8538. //JS/ES
  8539. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  8540. if (leftBindData != null)
  8541. {
  8542. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  8543. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  8544. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  8545. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8546. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8547. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8548. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8549. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8550. }
  8551. //SUITE
  8552. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  8553. if (leftBindData != null)
  8554. {
  8555. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  8556. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  8557. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  8558. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8559. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8560. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8561. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8562. designer.SetDataSource("BHotelSUITEZLR", ((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("BDJDRCB", leftBindData.cb);
  8568. designer.SetDataSource("BDJRS", leftBindData.rs);
  8569. designer.SetDataSource("BDJXS", leftBindData.xs);
  8570. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8571. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8572. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8573. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8574. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8575. }
  8576. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  8577. if (leftBindData != null)
  8578. {
  8579. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  8580. designer.SetDataSource("BGWRS", leftBindData.rs);
  8581. designer.SetDataSource("BGWXS", leftBindData.xs);
  8582. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8583. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8584. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8585. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8586. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8587. }
  8588. #region 优化方案
  8589. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  8590. //excelBind.Add("零用金", new {
  8591. //cb="",
  8592. //rs="",
  8593. //xs ="",
  8594. //zcb = "",
  8595. //});
  8596. #endregion
  8597. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  8598. if (leftBindData != null)
  8599. {
  8600. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  8601. designer.SetDataSource("BLYJRS", leftBindData.rs);
  8602. designer.SetDataSource("BLYJXS", leftBindData.xs);
  8603. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  8604. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  8605. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  8606. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  8607. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  8608. }
  8609. #endregion
  8610. #region B段Right信息
  8611. right = dto.rightInfo.Find(x => x.Type == "B");
  8612. if (right == null)
  8613. {
  8614. return Ok(jw);
  8615. }
  8616. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  8617. if (rightBindData != null)
  8618. {
  8619. //经济舱 + 双人间 TBR
  8620. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  8621. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  8622. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8623. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  8624. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8625. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8626. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8627. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8628. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8629. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8630. }
  8631. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  8632. if (rightBindData != null)
  8633. {
  8634. //经济舱 + 单人间 SGR
  8635. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  8636. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  8637. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8638. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  8639. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8640. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8641. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8642. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8643. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8644. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8645. }
  8646. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  8647. if (rightBindData != null)
  8648. {
  8649. //公务舱 + 单人间 SGR
  8650. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  8651. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  8652. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8653. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  8654. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8655. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8656. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8657. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8658. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8659. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8660. }
  8661. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  8662. if (rightBindData != null)
  8663. {
  8664. //公务舱 + 小套房 JSES
  8665. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  8666. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  8667. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8668. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  8669. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8670. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8671. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8672. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8673. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8674. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8675. }
  8676. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8677. if (rightBindData != null)
  8678. {
  8679. //公务舱 + 小套房 JSES
  8680. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  8681. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  8682. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8683. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  8684. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8685. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8686. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8687. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8688. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8689. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8690. }
  8691. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8692. if (rightBindData != null)
  8693. {
  8694. //经济舱 + 大套房
  8695. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  8696. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  8697. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8698. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  8699. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8700. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8701. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8702. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8703. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8704. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8705. }
  8706. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8707. if (rightBindData != null)
  8708. {
  8709. //头等舱 + 小套房 JSES
  8710. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  8711. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  8712. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8713. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  8714. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8715. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8716. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8717. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8718. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8719. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8720. }
  8721. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8722. if (rightBindData != null)
  8723. {
  8724. //头等舱 + 大套房
  8725. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  8726. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  8727. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8728. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  8729. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8730. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8731. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8732. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8733. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8734. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8735. }
  8736. #endregion
  8737. #region 标题
  8738. designer.SetDataSource("CostBDRCB", "单人成本");
  8739. designer.SetDataSource("CostBRS", "人数");
  8740. designer.SetDataSource("CostBXS", "系数");
  8741. designer.SetDataSource("CostBZCB", "总成本");
  8742. designer.SetDataSource("CostBDRBJ", "单人报价");
  8743. designer.SetDataSource("CostBZBJ", "总报价");
  8744. designer.SetDataSource("CostBDRLR", "单人利润");
  8745. designer.SetDataSource("CostBZLR", "总利润");
  8746. designer.SetDataSource("CostBDRCBOM", "单人成本");
  8747. designer.SetDataSource("CostBRSOM", "人数");
  8748. designer.SetDataSource("CostBZCBOM", "总成本");
  8749. designer.SetDataSource("CostBDRBJOM", "单人报价");
  8750. designer.SetDataSource("CostBZBJOM", "总报价");
  8751. designer.SetDataSource("CostBDRLROM", "单人利润");
  8752. designer.SetDataSource("CostBZLROM", "总利润");
  8753. #endregion
  8754. }
  8755. #endregion
  8756. designer.SetDataSource("TzZCB2", TzZCB2);
  8757. designer.SetDataSource("TzZBJ2", TzZBJ2);
  8758. designer.SetDataSource("TzZLR2", TzZLR2);
  8759. string[] dataSourceKeys = new string[]
  8760. {
  8761. "VF",
  8762. "TGS",
  8763. "TGOF",
  8764. "TGM",
  8765. "TGA",
  8766. "TGTF",
  8767. "TGEF",
  8768. "CFM",
  8769. "CFOF",
  8770. "B",
  8771. "L",
  8772. "D",
  8773. "TBR",
  8774. "SGR",
  8775. "JSES",
  8776. "Suite",
  8777. "TV",
  8778. "1L",
  8779. "IF",
  8780. "EF",
  8781. "BRF",
  8782. "TE",
  8783. "TGT",
  8784. "DRVT",
  8785. "PC",
  8786. "TLF",
  8787. "ECT"
  8788. };
  8789. foreach (var item in dataSourceKeys)
  8790. {
  8791. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8792. if (find != null)
  8793. {
  8794. designer.SetDataSource(item, find.text);
  8795. }
  8796. else
  8797. {
  8798. designer.SetDataSource(item, 0);
  8799. }
  8800. }
  8801. designer.SetDataSource(dt);
  8802. //根据数据源处理生成报表内容
  8803. designer.Process();
  8804. designer.Workbook.Worksheets[0].Name = "清单";
  8805. Worksheet sheet = designer.Workbook.Worksheets[0];
  8806. foreach (var Rowindex in hideRowsList)
  8807. {
  8808. ws.Cells.HideRows(Rowindex, 2);
  8809. }
  8810. byte[] bytes = null;
  8811. string strFileName = di.TeamName + "-团组-成本.xls";
  8812. using (MemoryStream stream = new MemoryStream())
  8813. {
  8814. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8815. bytes = stream.ToArray();
  8816. }
  8817. return Ok(JsonView(true, "", new
  8818. {
  8819. Data = bytes,
  8820. strFileName,
  8821. }));
  8822. }
  8823. /// <summary>
  8824. /// 导出客户报表
  8825. /// </summary>
  8826. /// <returns></returns>
  8827. [HttpPost]
  8828. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8829. {
  8830. var jw = JsonView(false);
  8831. if (dto.Diid == 0)
  8832. {
  8833. return Ok(JsonView(false, "请传递团组id"));
  8834. }
  8835. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8836. if (deleInfo.Code != 0)
  8837. {
  8838. return Ok(JsonView(false, "团组信息查询失败!"));
  8839. }
  8840. var di = deleInfo.Data as DelegationInfoWebView;
  8841. if (di == null)
  8842. {
  8843. return Ok(JsonView(false, "团组信息查询失败!"));
  8844. }
  8845. //文件名
  8846. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8847. //获取模板
  8848. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8849. //载入模板
  8850. Document doc = new Document(tmppath);
  8851. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8852. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8853. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8854. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8855. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8856. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8857. if (AParameter == null)
  8858. {
  8859. return Ok(JsonView(false, "系数不存在!"));
  8860. }
  8861. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8862. , TzAirDesc, TzZCost;
  8863. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8864. = TzAirDesc = TzZCost = string.Empty;
  8865. TzNumber = AParameter.CostTypenumber.ToString();
  8866. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8867. CarGuides1 = dto.CarGuides1;
  8868. Meal = dto.Meal;
  8869. SubsidizedMeals = dto.SubsidizedMeals;
  8870. NightRepair = dto.NightRepair;
  8871. AttractionsTickets = dto.AttractionsTickets;
  8872. MiscellaneousFees = dto.MiscellaneousFees;
  8873. ATip = dto.ATip;
  8874. TzHotelDesc = "";
  8875. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8876. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8877. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8878. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8879. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8880. TzAirDesc = "";
  8881. TzZCost = dto.TzZCost;
  8882. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8883. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8884. var index = 1;
  8885. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8886. foreach (var item in TzHotelDescArr)
  8887. {
  8888. if (AinfoArr != null)
  8889. {
  8890. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8891. if (Ainfo != null)
  8892. {
  8893. if (int.Parse(Ainfo.rs) <= 0)
  8894. {
  8895. continue;
  8896. }
  8897. var hotelText = string.Empty;
  8898. switch (item)
  8899. {
  8900. case "SGR":
  8901. hotelText = "单人间";
  8902. break;
  8903. case "JSES":
  8904. hotelText = "小套房";
  8905. break;
  8906. case "SUITE":
  8907. hotelText = "套房";
  8908. break;
  8909. case "TBR":
  8910. hotelText = "双人间";
  8911. break;
  8912. }
  8913. if (item != "TBR")
  8914. {
  8915. 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";
  8916. }
  8917. else
  8918. {
  8919. 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";
  8920. }
  8921. index++;
  8922. }
  8923. }
  8924. }
  8925. index = 1;
  8926. foreach (var item in TzAirDescArr)
  8927. {
  8928. if (AinfoArr != null)
  8929. {
  8930. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8931. if (Ainfo != null)
  8932. {
  8933. if (int.Parse(Ainfo.rs) <= 0)
  8934. {
  8935. continue;
  8936. }
  8937. 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";
  8938. index++;
  8939. }
  8940. }
  8941. }
  8942. if (dto.costType == "B")
  8943. {
  8944. if (BParameter == null)
  8945. {
  8946. return Ok(JsonView(false, "B段系数不存在!"));
  8947. }
  8948. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8949. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8950. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8951. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8952. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8953. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8954. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8955. foreach (var item in TzHotelDescArr)
  8956. {
  8957. if (AinfoArr != null)
  8958. {
  8959. TzHotelDesc += "B段信息 \r\n";
  8960. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8961. if (Ainfo != null)
  8962. {
  8963. if (int.Parse(Ainfo.rs) <= 0)
  8964. {
  8965. continue;
  8966. }
  8967. var hotelText = string.Empty;
  8968. switch (item)
  8969. {
  8970. case "SGR":
  8971. hotelText = "单人间";
  8972. break;
  8973. case "JSES":
  8974. hotelText = "小套房";
  8975. break;
  8976. case "SUITE":
  8977. hotelText = "套房";
  8978. break;
  8979. case "TBR":
  8980. hotelText = "双人间";
  8981. break;
  8982. }
  8983. if (item != "TBR")
  8984. {
  8985. 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";
  8986. }
  8987. else
  8988. {
  8989. 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";
  8990. }
  8991. index++;
  8992. }
  8993. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8994. }
  8995. }
  8996. index = 1;
  8997. foreach (var item in TzAirDescArr)
  8998. {
  8999. if (AinfoArr != null)
  9000. {
  9001. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  9002. if (Ainfo != null)
  9003. {
  9004. if (int.Parse(Ainfo.rs) <= 0)
  9005. {
  9006. continue;
  9007. }
  9008. 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";
  9009. index++;
  9010. }
  9011. }
  9012. }
  9013. }
  9014. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  9015. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  9016. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  9017. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  9018. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  9019. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  9020. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  9021. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  9022. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  9023. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  9024. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  9025. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  9026. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  9027. DickeyValue.Add("Visa", Visa); // 签证单人报价
  9028. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  9029. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  9030. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  9031. DickeyValue.Add("TzZCost", TzZCost);
  9032. foreach (var key in DickeyValue.Keys)
  9033. {
  9034. if (doc.Range.Bookmarks[key] != null)
  9035. {
  9036. Bookmark mark = doc.Range.Bookmarks[key];
  9037. mark.Text = DickeyValue[key];
  9038. }
  9039. }
  9040. byte[] bytes = null;
  9041. string strFileName = di.TeamName + "-客户报价.doc";
  9042. using (MemoryStream stream = new MemoryStream())
  9043. {
  9044. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  9045. bytes = stream.ToArray();
  9046. }
  9047. return Ok(JsonView(true, "", new
  9048. {
  9049. Data = bytes,
  9050. strFileName,
  9051. }));
  9052. }
  9053. /// <summary>
  9054. /// 团组成本 各模块(酒店,地接,机票)成本提示
  9055. /// </summary>
  9056. /// <param name="dto"></param>
  9057. /// <returns></returns>
  9058. [HttpPost]
  9059. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9060. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  9061. {
  9062. try
  9063. {
  9064. #region 参数验证
  9065. if (dto.DiId < 0)
  9066. {
  9067. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  9068. }
  9069. List<int> cTableIds = new List<int>() {
  9070. 76 ,//酒店预订
  9071. 77 ,//行程
  9072. 79 ,//车/导游地接
  9073. 80 ,//签证
  9074. 81 ,//邀请/公务活
  9075. 82 ,//团组客户保险
  9076. 85 ,//机票预订
  9077. 98 ,//其他款项
  9078. 285 ,//收款退还
  9079. 751 ,//酒店早餐
  9080. 1015 // 超支费用
  9081. };
  9082. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  9083. {
  9084. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  9085. }
  9086. #endregion
  9087. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  9088. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  9089. if (_GroupCostParameters.Count <= 0)
  9090. {
  9091. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  9092. }
  9093. if (_GroupCostParameters[0].IsShare == 0)
  9094. {
  9095. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  9096. }
  9097. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9098. //处理date为空问题
  9099. if (_GroupCosts.Count > 0)
  9100. {
  9101. for (int i = 0; i < _GroupCosts.Count; i++)
  9102. {
  9103. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  9104. {
  9105. if (i > 0)
  9106. {
  9107. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  9108. }
  9109. }
  9110. }
  9111. }
  9112. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  9113. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  9114. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  9115. string currCode = "";
  9116. #region currCode 验证
  9117. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  9118. if (isInt)
  9119. {
  9120. var currData = currDatas.Find(it => it.Id == intCurrency);
  9121. if (currData != null)
  9122. {
  9123. currCode = currData.Name;
  9124. }
  9125. }
  9126. else
  9127. {
  9128. currCode = _GroupCostParameters[0].Currency.Trim();
  9129. }
  9130. #endregion
  9131. //op,酒店单段模式存储
  9132. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  9133. {
  9134. CurrencyCode = currCode,
  9135. Rate = _GroupCostParameters[0].Rate,
  9136. CostType = _GroupCostParameters[0].CostType,
  9137. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  9138. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  9139. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  9140. };
  9141. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  9142. if (_GroupCostParameters.Count == 2)
  9143. {
  9144. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  9145. }
  9146. foreach (var item in _GroupCostParameters)
  9147. {
  9148. decimal _rate = 1;
  9149. decimal _rate1 = item.Rate;
  9150. decimal _scale = 1;
  9151. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  9152. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  9153. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  9154. //if (userInfo != null)
  9155. //{
  9156. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  9157. // {
  9158. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  9159. // {
  9160. // _scale = 1.00M;
  9161. // }
  9162. // }
  9163. //}
  9164. #endregion
  9165. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  9166. {
  9167. CurrencyCode = currCode,
  9168. Rate = _rate1,
  9169. CostType = item.CostType,
  9170. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  9171. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  9172. CostTypeNumber = item.CostTypenumber
  9173. };
  9174. if (_GroupCostParameters.Count > 1)
  9175. {
  9176. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  9177. }
  9178. else
  9179. {
  9180. modulePromptInfo.CostTypeNumber = item.LYJRS;
  9181. }
  9182. if (dto.CTable == 79)//
  9183. {
  9184. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  9185. modulePromptInfo.TotalCost = item.DJCB;
  9186. }
  9187. List<string> costTypes = new List<string>() { "A", "B" };
  9188. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  9189. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  9190. if (_GroupCostsDuplicates.Count() == 1)
  9191. {
  9192. _GroupCostsTypeData = _GroupCosts;
  9193. }
  9194. else
  9195. {
  9196. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  9197. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  9198. }
  9199. /*
  9200. * 76 酒店预订
  9201. * 77 行程
  9202. * 79 车/导游地接
  9203. * 80 签证
  9204. * 81 邀请/公务活动
  9205. * 82 团组客户保险
  9206. * 85 机票预订
  9207. * 98 其他款项
  9208. * 285 收款退还
  9209. * 751 酒店早餐
  9210. * 1015 超支费用
  9211. */
  9212. switch (dto.CTable)
  9213. {
  9214. case 76: // 酒店预订
  9215. _ModuleSubPromptInfo.AddRange(
  9216. _GroupCostsTypeData.Select(it => new
  9217. {
  9218. it.DAY,
  9219. it.Date,
  9220. it.ACCON,
  9221. it.ITIN,
  9222. it.SGR,
  9223. it.TBR,
  9224. it.JS_ES,
  9225. it.Suite
  9226. })
  9227. );
  9228. break;
  9229. case 79: // 车/导游地接
  9230. _ModuleSubPromptInfo.AddRange(
  9231. _GroupCostsTypeData.Select(it => new
  9232. {
  9233. Date = it.Date, //日期
  9234. CarFee = it.CarCost * _rate * _scale, //车费用
  9235. CarType = it.CarType, //车型
  9236. DriverFee = it.CFS * _rate * _scale, //司机工资
  9237. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  9238. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  9239. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  9240. GuideFee = it.TGS * _rate * _scale, //导游费用
  9241. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  9242. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  9243. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  9244. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  9245. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  9246. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  9247. Breakfast = it.B * _rate * _scale, //早餐费
  9248. Lunch = it.L * _rate * _scale, //午餐费
  9249. Dinner = it.D * _rate * _scale, //晚餐费
  9250. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  9251. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  9252. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  9253. TicketFee = it.EF * _rate * _scale, //门票费
  9254. TicketRemark = it.EFR, //门票费描述
  9255. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  9256. TravelSupplies = it.TE * _rate * _scale, //出行物资
  9257. SpentCash = it.PC * _rate * _scale, //零用金
  9258. LeadersFee = it.TLF * _rate * _scale, //领队费
  9259. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  9260. })
  9261. );
  9262. break;
  9263. case 85: // 机票
  9264. List<dynamic> datas = new List<dynamic>();
  9265. datas.Add(
  9266. new
  9267. {
  9268. AirType = "经济舱",
  9269. AirNum = item.JJCRS,
  9270. AirDRCB = item.JJCCB,
  9271. AirZCB = (item.JJCRS * item.JJCCB)
  9272. }
  9273. );
  9274. datas.Add(
  9275. new
  9276. {
  9277. AirType = "公务舱",
  9278. AirNum = item.GWCRS,
  9279. AirDRCB = item.GWCCB,
  9280. AirZCB = (item.GWCRS * item.GWCCB)
  9281. }
  9282. );
  9283. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  9284. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  9285. modulePromptInfo.Data = new
  9286. {
  9287. airFeeData = datas,
  9288. airInitData = initDatas
  9289. };
  9290. _ModulePromptInfos.Add(modulePromptInfo);
  9291. break;
  9292. default:
  9293. break;
  9294. }
  9295. }
  9296. if (dto.CTable != 85)
  9297. {
  9298. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  9299. _ModulePromptInfos.Add(_ModulePromptInfo);
  9300. }
  9301. _view.ModulePromptInfos = _ModulePromptInfos;
  9302. return Ok(JsonView(true, "操作成功!", _view));
  9303. }
  9304. catch (Exception ex)
  9305. {
  9306. return Ok(JsonView(false, ex.Message));
  9307. }
  9308. }
  9309. /// <summary>
  9310. /// 根据黑屏代码重新生成行程
  9311. /// </summary>
  9312. /// <param name="dto"></param>
  9313. /// <returns></returns>
  9314. [HttpPost]
  9315. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  9316. {
  9317. var jw = JsonView(false);
  9318. var Create = _GroupCostRepository.
  9319. CreateGroupCostByBlackCode(dto.Diid);
  9320. jw.Msg = Create.Msg;
  9321. if (Create.Code == 0)
  9322. {
  9323. jw.Code = 200;
  9324. jw.Data = new
  9325. {
  9326. groupCost = Create.Data,
  9327. blackCodeIsTrue = true
  9328. };
  9329. }
  9330. else
  9331. {
  9332. jw.Code = 400;
  9333. jw.Data = new
  9334. {
  9335. groupCost = Create.Data,
  9336. blackCodeIsTrue = false,
  9337. };
  9338. }
  9339. return Ok(jw);
  9340. }
  9341. /// <summary>
  9342. /// 成本获取OP历史车费用
  9343. /// </summary>
  9344. /// <param name="dto"></param>
  9345. /// <returns></returns>
  9346. [HttpPost]
  9347. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  9348. {
  9349. var jw = JsonView(false);
  9350. try
  9351. {
  9352. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  9353. //获取现有所有车的数据
  9354. if (!dto.Param.IsNullOrWhiteSpace())
  9355. {
  9356. string sql = $@"
  9357. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  9358. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  9359. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  9360. 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
  9361. AND gctggr.ServiceEndTime is not NULL
  9362. ORDER by gctggrc.id DESC
  9363. ";
  9364. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  9365. var numeberResult = await Task.Run(() =>
  9366. {
  9367. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  9368. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  9369. return numberArr;
  9370. });
  9371. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  9372. foreach (var item in numeberResult)
  9373. {
  9374. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  9375. {
  9376. Country = "数据异常!",
  9377. City = string.Empty,
  9378. };
  9379. item.Area = find.Country + " " + find.City;
  9380. }
  9381. dbResult.AddRange(numeberResult);
  9382. if (dto.Param.Contains("、"))
  9383. {
  9384. var sp = dto.Param.Split("、");
  9385. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9386. .Where(x =>
  9387. {
  9388. return System.Array.Exists(sp, e =>
  9389. {
  9390. bool where = false;
  9391. if (x.Area != null)
  9392. {
  9393. where = x.Area.Contains(e);
  9394. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9395. {
  9396. return false;
  9397. }
  9398. }
  9399. if (x.PriceName != null && !where)
  9400. {
  9401. where = x.PriceName.Contains(e);
  9402. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9403. {
  9404. return false;
  9405. }
  9406. }
  9407. return where;
  9408. });
  9409. }).ToList();
  9410. }
  9411. else
  9412. {
  9413. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  9414. .Where(x =>
  9415. {
  9416. bool where = false;
  9417. if (x.Area != null)
  9418. {
  9419. where = x.Area.Contains(dto.Param);
  9420. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  9421. {
  9422. return false;
  9423. }
  9424. }
  9425. if (x.PriceName != null && !where)
  9426. {
  9427. where = x.PriceName.Contains(dto.Param);
  9428. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  9429. {
  9430. return false;
  9431. }
  9432. }
  9433. return where;
  9434. }
  9435. )
  9436. .ToList();
  9437. }
  9438. }
  9439. var view = dbResult.Select(x =>
  9440. {
  9441. decimal dp = 0.00M;
  9442. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  9443. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  9444. if (string.IsNullOrWhiteSpace(x.DatePrice))
  9445. {
  9446. if (startB && endB)
  9447. {
  9448. var timesp = endD.Subtract(startD);
  9449. if ((timesp.Days + 1) != 0)
  9450. {
  9451. dp = x.Price / (timesp.Days + 1);
  9452. }
  9453. }
  9454. }
  9455. else
  9456. {
  9457. dp = x.Price;
  9458. }
  9459. return new
  9460. {
  9461. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  9462. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  9463. x.Area,
  9464. x.id,
  9465. price = x.Price.ToString("F2"),
  9466. x.PriceName,
  9467. x.PriceContent,
  9468. x.TeamName,
  9469. x.DatePrice,
  9470. dayPrice = dp.ToString("F2"),
  9471. };
  9472. }).OrderByDescending(x => x.id).ToList();
  9473. jw = JsonView(true, "获取成功!", view);
  9474. }
  9475. catch (Exception e)
  9476. {
  9477. jw = JsonView(false, e.Message);
  9478. }
  9479. return Ok(jw);
  9480. }
  9481. #endregion
  9482. #region 酒店预订 新 雷怡 2023-12-28 17:45
  9483. /// <summary>
  9484. /// 酒店预订
  9485. /// 酒店费用列表 根据团组Id查询
  9486. /// </summary>
  9487. /// <param name="_dto"></param>
  9488. /// <returns></returns>
  9489. [HttpPost]
  9490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9491. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  9492. {
  9493. #region 参数验证
  9494. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9495. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9496. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9497. #region 团组操作权限验证 76 酒店预定模块
  9498. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9499. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9500. #endregion
  9501. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9502. #region 页面操作权限验证
  9503. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9504. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9505. #endregion
  9506. #endregion
  9507. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  9508. }
  9509. /// <summary>
  9510. /// 酒店预订
  9511. /// 基础数据
  9512. /// </summary>
  9513. /// <param name="_dto"></param>
  9514. /// <returns></returns>
  9515. [HttpPost]
  9516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9517. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  9518. {
  9519. #region 参数验证
  9520. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9521. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9522. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9523. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9524. #region 页面操作权限验证
  9525. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9526. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9527. #endregion
  9528. #region 团组操作权限验证 76 酒店预定模块
  9529. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9530. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9531. #endregion
  9532. #endregion
  9533. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  9534. }
  9535. /// <summary>
  9536. /// 酒店预订
  9537. /// 创建 入住卷号码
  9538. /// </summary>
  9539. /// <param name="_dto"></param>
  9540. /// <returns></returns>
  9541. [HttpPost]
  9542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9543. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  9544. {
  9545. #region 参数验证
  9546. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9547. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9548. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9549. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9550. #region 页面操作权限验证
  9551. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9552. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9553. #endregion
  9554. #region 团组操作权限验证 76 酒店预定模块
  9555. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9556. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9557. #endregion
  9558. #endregion
  9559. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  9560. if (data.Code != 0)
  9561. {
  9562. return Ok(JsonView(false, data.Msg));
  9563. }
  9564. return Ok(JsonView(true, data.Msg, data.Data));
  9565. }
  9566. /// <summary>
  9567. /// 酒店预订
  9568. /// 详情
  9569. /// </summary>
  9570. /// <param name="_dto"></param>
  9571. /// <returns></returns>
  9572. [HttpPost]
  9573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9574. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  9575. {
  9576. #region 参数验证
  9577. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  9578. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9579. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  9580. #region 团组操作权限验证 76 酒店预定模块
  9581. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9582. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9583. #endregion
  9584. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9585. #region 页面操作权限验证
  9586. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9587. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9588. #endregion
  9589. #endregion
  9590. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  9591. }
  9592. /// <summary>
  9593. /// 酒店预订
  9594. /// Add Or Edit
  9595. /// </summary>
  9596. /// <param name="_dto"></param>
  9597. /// <returns></returns>
  9598. [HttpPost]
  9599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9600. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  9601. {
  9602. #region 参数验证
  9603. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9604. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9605. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9606. #region 团组操作权限验证 76 酒店预定模块
  9607. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9608. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9609. #endregion
  9610. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9611. #region 页面操作权限验证
  9612. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9613. if (_dto.Id == 0) // Add
  9614. {
  9615. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9616. }
  9617. else if (_dto.Id > 1) // Edit
  9618. {
  9619. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9620. }
  9621. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  9622. #endregion
  9623. #endregion
  9624. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  9625. if (_view.Code != 200)
  9626. {
  9627. return Ok(_view);
  9628. }
  9629. #region 应用推送
  9630. try
  9631. {
  9632. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  9633. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  9634. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  9635. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9636. //自动审核
  9637. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  9638. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  9639. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  9640. //2024-10-21 新增LZ UID
  9641. var userIds = new List<int>() { 21 };
  9642. string title = $"系统通知";
  9643. var diId = _dto.DiId;
  9644. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  9645. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  9646. string content = "";
  9647. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9648. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  9649. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  9650. }
  9651. catch (Exception ex)
  9652. {
  9653. }
  9654. #endregion
  9655. return Ok(_view);
  9656. }
  9657. /// <summary>
  9658. /// 酒店自动审核测试
  9659. /// Add Or Edit
  9660. /// </summary>
  9661. /// <param name="_dto"></param>
  9662. /// <returns></returns>
  9663. [HttpPost]
  9664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9665. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  9666. {
  9667. #region 应用推送
  9668. try
  9669. {
  9670. //自动审核
  9671. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  9672. }
  9673. catch (Exception ex)
  9674. {
  9675. return Ok(JsonView(false, "操作失败"));
  9676. }
  9677. #endregion
  9678. return Ok(JsonView(false, "操作成功"));
  9679. }
  9680. /// <summary>
  9681. /// 酒店预订
  9682. /// Del
  9683. /// </summary>
  9684. /// <param name="_dto"></param>
  9685. /// <returns></returns>
  9686. [HttpPost]
  9687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9688. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  9689. {
  9690. #region 参数验证
  9691. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9692. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9693. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9694. #region 团组操作权限验证 76 酒店预定模块
  9695. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9696. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9697. #endregion
  9698. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9699. #region 页面操作权限验证
  9700. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9701. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9702. #endregion
  9703. #endregion
  9704. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  9705. }
  9706. /// <summary>
  9707. /// 酒店预订
  9708. /// 生成VOUCHER
  9709. /// 2024.05.06 之前版本
  9710. /// </summary>
  9711. /// <param name="_dto"></param>
  9712. /// <returns></returns>
  9713. [HttpPost]
  9714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9715. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  9716. {
  9717. try
  9718. {
  9719. #region 参数验证
  9720. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9721. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9722. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9723. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  9724. #region 团组操作权限验证 76 酒店预定模块
  9725. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9726. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9727. #endregion
  9728. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9729. #region 页面操作权限验证
  9730. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9731. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9732. #endregion
  9733. #endregion
  9734. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  9735. //判断数据是否完整
  9736. if (hr != null)
  9737. {
  9738. if (!string.IsNullOrEmpty(hr.DetermineNo))
  9739. {
  9740. string strFileName = "HotelStatement/";
  9741. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9742. if (dele != null)
  9743. strFileName += dele.TourCode;
  9744. //载入模板
  9745. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  9746. Document doc = new Document(sss);
  9747. DocumentBuilder builder = new DocumentBuilder(doc);
  9748. #region 替换Word模板书签内容
  9749. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9750. //入住卷预定号码
  9751. if (doc.Range.Bookmarks["VNO"] != null)
  9752. {
  9753. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9754. mark.Text = hr.CheckNumber;
  9755. }
  9756. //酒店时间
  9757. if (doc.Range.Bookmarks["Date"] != null)
  9758. {
  9759. Bookmark mark = doc.Range.Bookmarks["Date"];
  9760. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9761. }
  9762. //团号
  9763. if (doc.Range.Bookmarks["TNo"] != null)
  9764. {
  9765. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9766. mark.Text = dele.TourCode;
  9767. }
  9768. //预定号码
  9769. if (doc.Range.Bookmarks["BookingId"] != null)
  9770. {
  9771. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9772. mark.Text = hr.ReservationsNo;
  9773. }
  9774. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9775. {
  9776. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9777. mark.Text = hr.DetermineNo;
  9778. }
  9779. //酒店城市
  9780. if (doc.Range.Bookmarks["City"] != null)
  9781. {
  9782. Bookmark mark = doc.Range.Bookmarks["City"];
  9783. mark.Text = hr.City;
  9784. }
  9785. //酒店名称
  9786. if (doc.Range.Bookmarks["HName"] != null)
  9787. {
  9788. Bookmark mark = doc.Range.Bookmarks["HName"];
  9789. mark.Text = hr.HotelName;
  9790. }
  9791. //酒店地址
  9792. if (doc.Range.Bookmarks["Address"] != null)
  9793. {
  9794. Bookmark mark = doc.Range.Bookmarks["Address"];
  9795. mark.Text = hr.HotelAddress;
  9796. }
  9797. //酒店电话
  9798. if (doc.Range.Bookmarks["Tel"] != null)
  9799. {
  9800. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9801. mark.Text = hr.HotelTel;
  9802. }
  9803. //酒店传真
  9804. if (doc.Range.Bookmarks["Fax"] != null)
  9805. {
  9806. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9807. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9808. {
  9809. mark.Text = hr.HotelFax;
  9810. }
  9811. }
  9812. //入住时间
  9813. if (doc.Range.Bookmarks["CIn"] != null)
  9814. {
  9815. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9816. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9817. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9818. }
  9819. //退房时间
  9820. if (doc.Range.Bookmarks["COut"] != null)
  9821. {
  9822. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9823. Bookmark mark = doc.Range.Bookmarks["COut"];
  9824. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9825. }
  9826. //客户名称
  9827. if (doc.Range.Bookmarks["GName"] != null)
  9828. {
  9829. string guestName = "";
  9830. string[] clients = new string[] { };
  9831. if (hr.GuestName.Contains(","))
  9832. {
  9833. clients = hr.GuestName.Split(",");
  9834. }
  9835. else
  9836. {
  9837. clients = new string[] { hr.GuestName };
  9838. }
  9839. List<int> clientIds_int = new List<int>();
  9840. if (clients.Length > 0)
  9841. {
  9842. foreach (var item in clients)
  9843. {
  9844. if (item.IsNumeric())
  9845. {
  9846. clientIds_int.Add(int.Parse(item));
  9847. }
  9848. }
  9849. }
  9850. if (clientIds_int.Count > 0)
  9851. {
  9852. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9853. foreach (var client in _clientDatas)
  9854. {
  9855. //男
  9856. if (client.Sex == 0) guestName += $"Mr.";
  9857. //女
  9858. else if (client.Sex == 1) guestName += $"Ms.";
  9859. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9860. {
  9861. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9862. }
  9863. //guestName += $"{client.Pinyin},";
  9864. }
  9865. if (guestName.Length > 0)
  9866. {
  9867. guestName = guestName.Substring(0, guestName.Length - 1);
  9868. }
  9869. }
  9870. else
  9871. {
  9872. guestName = hr.GuestName;
  9873. }
  9874. Bookmark mark = doc.Range.Bookmarks["GName"];
  9875. mark.Text = guestName;
  9876. }
  9877. //房间介绍
  9878. if (doc.Range.Bookmarks["ROOM"] != null)
  9879. {
  9880. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9881. mark.Text = hr.RoomExplanation;
  9882. }
  9883. //报价描述
  9884. if (doc.Range.Bookmarks["NOTE"] != null)
  9885. {
  9886. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9887. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9888. if (ss != null)
  9889. mark.Text = ss.Name;
  9890. }
  9891. //入住时间
  9892. if (doc.Range.Bookmarks["CheckIn"] != null)
  9893. {
  9894. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9895. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9896. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9897. }
  9898. //退房时间
  9899. if (doc.Range.Bookmarks["CheckOut"] != null)
  9900. {
  9901. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9902. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9903. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9904. }
  9905. //日期
  9906. if (doc.Range.Bookmarks["DT"] != null)
  9907. {
  9908. Bookmark mark = doc.Range.Bookmarks["DT"];
  9909. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9910. }
  9911. //名称
  9912. if (doc.Range.Bookmarks["VName"] != null)
  9913. {
  9914. Bookmark mark = doc.Range.Bookmarks["VName"];
  9915. mark.Text = hr.HotelName;
  9916. }
  9917. //号码
  9918. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9919. {
  9920. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9921. mark.Text = hr.CheckNumber;
  9922. }
  9923. #endregion
  9924. strFileName += "VOUCHER.doc";
  9925. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9926. doc.Save(fileDir);
  9927. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9928. return Ok(JsonView(true, "操作成功!", Url));
  9929. }
  9930. else
  9931. {
  9932. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9933. }
  9934. }
  9935. else
  9936. {
  9937. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9938. }
  9939. }
  9940. catch (Exception ex)
  9941. {
  9942. return Ok(JsonView(false, ex.Message));
  9943. }
  9944. }
  9945. /// <summary>
  9946. /// 酒店预订
  9947. /// 生成VOUCHER
  9948. /// 2024.05.06 之后版本
  9949. /// </summary>
  9950. /// <param name="_dto"></param>
  9951. /// <returns></returns>
  9952. [HttpPost]
  9953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9954. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9955. {
  9956. #region 参数验证
  9957. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9958. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9959. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9960. #region 团组操作权限验证 76 酒店预定模块
  9961. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9962. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9963. #endregion
  9964. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9965. #region 页面操作权限验证
  9966. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9967. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9968. #endregion
  9969. #endregion
  9970. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9971. //判断数据是否完整
  9972. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9973. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9974. string strFileName = "HotelStatement/";
  9975. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9976. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9977. #region 数据处理
  9978. List<int> guestIds = new List<int>();
  9979. int index = 0;
  9980. foreach (var item in hrDtas)
  9981. {
  9982. if (item.GuestName.Contains(","))
  9983. {
  9984. string[] guestIdArr = item.GuestName.Split(',');
  9985. foreach (var guestIdStr in guestIdArr)
  9986. {
  9987. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9988. if (guestBool)
  9989. {
  9990. guestIds.Add(guestId);
  9991. }
  9992. }
  9993. }
  9994. else guestNames += item.GuestName;
  9995. var voucherInfo = new HotelVoucherInfoView()
  9996. {
  9997. HotelName = item.HotelName,
  9998. CheckInDate = item.CheckInDate,
  9999. CheckOutDate = item.CheckOutDate,
  10000. ConfirmationNumber = item.DetermineNo.Trim(),
  10001. RoomType = item.RoomExplanation
  10002. };
  10003. vouchers.Add(voucherInfo);
  10004. }
  10005. if (guestIds.Count > 0)
  10006. {
  10007. guestIds = guestIds.Distinct().ToList();
  10008. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  10009. if (guestDatas.Count > 0)
  10010. {
  10011. guestNames = "";
  10012. foreach (var guest in guestDatas)
  10013. {
  10014. string guestName = "";
  10015. if (guest.Sex == 0) guestName += @"MR.";
  10016. else if (guest.Sex == 1) guestName += @"MS.";
  10017. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  10018. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  10019. guestNames += @$"{guestName.Trim()}、";
  10020. }
  10021. if (guestNames.Length > 0)
  10022. {
  10023. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  10024. }
  10025. }
  10026. }
  10027. #endregion
  10028. //载入模板
  10029. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  10030. Document doc = new Document(sss);
  10031. DocumentBuilder builder = new DocumentBuilder(doc);
  10032. if (doc.Range.Bookmarks["GuestName"] != null)
  10033. {
  10034. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  10035. mark.Text = guestNames;
  10036. }
  10037. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10038. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  10039. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  10040. for (int i = 1; i <= vouchers.Count; i++)
  10041. {
  10042. HotelVoucherInfoView hviv = vouchers[i - 1];
  10043. builder.MoveToCell(0, i, 0, 0);
  10044. builder.Write(hviv.HotelName);
  10045. builder.MoveToCell(0, i, 1, 0);
  10046. builder.Write(hviv.CheckInDate);
  10047. builder.MoveToCell(0, i, 2, 0);
  10048. builder.Write(hviv.CheckOutDate);
  10049. builder.MoveToCell(0, i, 3, 0);
  10050. builder.Write(hviv.RoomType);
  10051. builder.MoveToCell(0, i, 4, 0);
  10052. builder.Write(hviv.ConfirmationNumber);
  10053. }
  10054. //删除多余行
  10055. int currRowIndex = vouchers.Count + 1;
  10056. int delRows = 21 - currRowIndex;
  10057. if (delRows > 0)
  10058. {
  10059. for (int i = 0; i < delRows; i++)
  10060. {
  10061. table.Rows.RemoveAt(currRowIndex);
  10062. //cultivateRowIndex++;
  10063. }
  10064. }
  10065. strFileName += "VOUCHER.docx";
  10066. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10067. doc.Save(fileDir);
  10068. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10069. return Ok(JsonView(true, "操作成功!", Url));
  10070. }
  10071. /// <summary>
  10072. /// 酒店预订
  10073. /// 生成VOUCHER 批量生成
  10074. /// New
  10075. /// </summary>
  10076. /// <param name="_dto"></param>
  10077. /// <returns></returns>
  10078. [HttpPost]
  10079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10080. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  10081. {
  10082. #region 参数验证
  10083. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10084. if (_dto.PageId < 1) _dto.PageId = 28;
  10085. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10086. #region 团组操作权限验证 76 酒店预定模块
  10087. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10088. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10089. #endregion
  10090. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10091. #region 页面操作权限验证
  10092. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10093. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10094. #endregion
  10095. #endregion
  10096. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  10097. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  10098. .OrderBy(x => x.CheckInDate)
  10099. .ToListAsync();
  10100. //判断数据是否完整
  10101. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  10102. string strFileName = "HotelStatement/";
  10103. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  10104. if (dele != null)
  10105. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  10106. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  10107. for (int i = 0; i < hrDtas.Count; i++)
  10108. {
  10109. string guestNames = string.Empty;
  10110. List<int> guestIds = new List<int>();
  10111. var item = hrDtas[i];
  10112. //处理客户姓名
  10113. if (item.GuestName.Contains(","))
  10114. {
  10115. string[] guestIdArr = item.GuestName.Split(',');
  10116. foreach (var guestIdStr in guestIdArr)
  10117. if (int.TryParse(guestIdStr, out int guestId))
  10118. guestIds.Add(guestId);
  10119. }
  10120. else
  10121. {
  10122. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  10123. if (guestIdBool)
  10124. {
  10125. guestIds.Add(guestId);
  10126. }
  10127. //NaN
  10128. if (item.GuestName.Contains("NaN"))
  10129. {
  10130. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  10131. }
  10132. }
  10133. if (guestIds.Count > 0)
  10134. {
  10135. guestIds = guestIds.Distinct().ToList();
  10136. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  10137. if (guestDatas1.Count > 0)
  10138. {
  10139. guestNames = "";
  10140. foreach (var guest in guestDatas1)
  10141. {
  10142. string guestName = "";
  10143. if (guest.Sex == 0) guestName += @"MR.";
  10144. else if (guest.Sex == 1) guestName += @"MS.";
  10145. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  10146. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  10147. guestNames += @$"{guestName.Trim()}、";
  10148. }
  10149. if (guestNames.Length > 0)
  10150. {
  10151. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  10152. }
  10153. }
  10154. }
  10155. //if (!string.IsNullOrEmpty(guestNames))
  10156. //{
  10157. hrDtas[i].GuestName = guestNames;
  10158. //}
  10159. }
  10160. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  10161. Document doc = new Document();
  10162. DocumentBuilder builder = new DocumentBuilder(doc);
  10163. try
  10164. {
  10165. builder.MoveToDocumentStart();
  10166. foreach (var item in hrDtas)
  10167. {
  10168. //标题
  10169. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  10170. builder.ParagraphFormat.LineSpacing = 1;
  10171. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10172. builder.ParagraphFormat.Style.Font.Size = 9;
  10173. builder.ParagraphFormat.Style.Font.Bold = true;
  10174. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  10175. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  10176. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  10177. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  10178. builder.ParagraphFormat.LineSpacing = 1;
  10179. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10180. builder.ParagraphFormat.Style.Font.Size = 9;
  10181. builder.ParagraphFormat.Style.Font.Bold = true;
  10182. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  10183. builder.StartTable();
  10184. // 设置边框颜色
  10185. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  10186. //设置边框样式
  10187. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  10188. //表格
  10189. #region 第一行
  10190. builder.InsertCell();
  10191. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10192. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10193. //builder.CellFormat.AllowAutoFit = false;
  10194. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10195. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10196. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10197. builder.CellFormat.WrapText = true; //自动换行
  10198. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10199. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  10200. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10201. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10202. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10203. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10204. builder.Write("TOUR NO:");
  10205. builder.InsertCell();
  10206. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10207. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10208. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10209. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10210. builder.ParagraphFormat.Style.Font.Bold = false;
  10211. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10212. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10213. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10214. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10215. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10216. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10217. builder.Write($"{dele?.TourCode ?? "-"}");
  10218. builder.InsertCell();
  10219. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10220. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10221. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10222. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10223. builder.ParagraphFormat.Style.Font.Bold = false;
  10224. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10225. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10226. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10227. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10228. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10229. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10230. builder.Write($"CITY:");
  10231. builder.InsertCell();
  10232. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10233. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10234. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10235. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10236. builder.ParagraphFormat.Style.Font.Bold = false;
  10237. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10238. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10239. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10240. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10241. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10242. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10243. builder.Write($"{item.City}");
  10244. builder.EndRow();
  10245. #endregion
  10246. #region 第二行
  10247. builder.InsertCell();
  10248. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10249. builder.CellFormat.HorizontalMerge = CellMerge.None;
  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.Right;//对齐
  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.Write("CONFIRMATION NO:");
  10260. builder.InsertCell();
  10261. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10262. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10263. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10264. builder.ParagraphFormat.Style.Font.Bold = false;
  10265. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10266. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10267. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10268. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10269. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10270. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10271. builder.CellFormat.VerticalMerge = CellMerge.None;
  10272. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10273. builder.Write($"{item.DetermineNo}");
  10274. builder.InsertCell();
  10275. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10276. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10277. builder.InsertCell();
  10278. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10279. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10280. builder.EndRow();
  10281. #endregion
  10282. #region 第三行
  10283. builder.InsertCell();
  10284. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10285. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10286. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10287. builder.ParagraphFormat.Style.Font.Bold = false;
  10288. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10289. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10290. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10291. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10292. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10293. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10294. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10295. builder.Write($"HOTEL NAME:");
  10296. builder.InsertCell();
  10297. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10298. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10299. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10300. builder.ParagraphFormat.Style.Font.Bold = false;
  10301. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10302. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10303. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10304. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10305. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10306. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10307. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10308. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10309. builder.Write($"{item.HotelName}");
  10310. builder.InsertCell();
  10311. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10312. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10313. builder.InsertCell();
  10314. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10315. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10316. builder.EndRow();
  10317. #endregion
  10318. #region 第四行
  10319. builder.InsertCell();
  10320. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10321. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10322. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10323. builder.ParagraphFormat.Style.Font.Bold = false;
  10324. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10325. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10326. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10327. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10328. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10329. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10330. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10331. builder.Write($"HOTEL ADDRESS:");
  10332. builder.InsertCell();
  10333. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10334. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10335. builder.ParagraphFormat.Style.Font.Size = 8;
  10336. builder.ParagraphFormat.Style.Font.Bold = false;
  10337. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10338. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10339. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10340. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10341. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10342. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10343. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10344. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10345. builder.Write($"{item.HotelAddress}");
  10346. builder.InsertCell();
  10347. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10348. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10349. builder.InsertCell();
  10350. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10351. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10352. builder.EndRow();
  10353. #endregion
  10354. #region 第五行
  10355. builder.InsertCell();
  10356. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10357. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10358. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10359. builder.ParagraphFormat.Style.Font.Bold = false;
  10360. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10361. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10362. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10363. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10364. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10365. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10366. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10367. builder.Write("TEL:");
  10368. builder.InsertCell();
  10369. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10370. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10371. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10372. builder.ParagraphFormat.Style.Font.Bold = false;
  10373. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10374. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10375. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10376. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10377. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10378. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10379. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10380. builder.Write($"{item.HotelTel}");
  10381. builder.InsertCell();
  10382. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10383. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10384. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10385. builder.ParagraphFormat.Style.Font.Bold = false;
  10386. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10387. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10388. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10389. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10390. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10391. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10392. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10393. builder.Write($"FAX:");
  10394. builder.InsertCell();
  10395. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10396. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10397. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10398. builder.ParagraphFormat.Style.Font.Bold = false;
  10399. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10400. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10401. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10402. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10403. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10404. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10405. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10406. builder.Write($"{item.HotelFax}");
  10407. builder.EndRow();
  10408. #endregion
  10409. #region 第六行
  10410. builder.InsertCell();
  10411. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10412. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10413. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10414. builder.ParagraphFormat.Style.Font.Bold = false;
  10415. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10416. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10417. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10418. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10419. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10420. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10421. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10422. builder.Write("CHECK IN:");
  10423. builder.InsertCell();
  10424. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10425. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10426. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10427. builder.ParagraphFormat.Style.Font.Bold = false;
  10428. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10429. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10430. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10431. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10432. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10433. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10434. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10435. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  10436. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  10437. builder.Write($"{checkInStr}");
  10438. builder.InsertCell();
  10439. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10440. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10441. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10442. builder.ParagraphFormat.Style.Font.Bold = false;
  10443. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10444. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10445. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10446. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10447. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10448. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10449. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10450. builder.Write($"CHECK OUT:");
  10451. builder.InsertCell();
  10452. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10453. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10454. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10455. builder.ParagraphFormat.Style.Font.Bold = false;
  10456. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10457. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10458. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10459. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10460. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10461. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10462. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10463. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  10464. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  10465. builder.Write($"{checkOutStr}");
  10466. builder.EndRow();
  10467. #endregion
  10468. #region 第七行
  10469. builder.InsertCell();
  10470. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10471. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10472. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10473. builder.ParagraphFormat.Style.Font.Bold = false;
  10474. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10475. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10476. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10477. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10478. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10479. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10480. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10481. builder.Write($"GUEST NAME:");
  10482. builder.InsertCell();
  10483. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10484. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10485. builder.ParagraphFormat.Style.Font.Size = 8;
  10486. builder.ParagraphFormat.Style.Font.Bold = false;
  10487. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10488. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10489. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10490. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10491. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10492. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10493. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10494. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10495. builder.Write($"{item.GuestName}");
  10496. builder.InsertCell();
  10497. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10498. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10499. builder.InsertCell();
  10500. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10501. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10502. builder.EndRow();
  10503. #endregion
  10504. #region 第八行
  10505. builder.InsertCell();
  10506. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10507. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10508. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10509. builder.ParagraphFormat.Style.Font.Bold = false;
  10510. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10511. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10512. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10513. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10514. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10515. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10516. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10517. builder.Write($"ROOM TYPE:");
  10518. builder.InsertCell();
  10519. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10520. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10521. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10522. builder.ParagraphFormat.Style.Font.Bold = false;
  10523. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10524. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10525. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10526. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10527. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10528. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10529. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10530. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10531. builder.Write($"{item.RoomExplanation}");
  10532. builder.InsertCell();
  10533. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10534. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10535. builder.InsertCell();
  10536. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10537. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10538. builder.EndRow();
  10539. #endregion
  10540. #region 第九行
  10541. builder.InsertCell();
  10542. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10543. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10544. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10545. builder.ParagraphFormat.Style.Font.Bold = false;
  10546. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10547. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10548. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  10549. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  10550. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  10551. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  10552. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  10553. builder.Write($"NOTE:");
  10554. builder.InsertCell();
  10555. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10556. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  10557. builder.ParagraphFormat.Style.Font.Size = 7.5;
  10558. builder.ParagraphFormat.Style.Font.Bold = false;
  10559. builder.CellFormat.HorizontalMerge = CellMerge.None;
  10560. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  10561. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  10562. builder.CellFormat.HorizontalMerge = CellMerge.First;
  10563. 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.");
  10564. builder.InsertCell();
  10565. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  10566. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10567. builder.InsertCell();
  10568. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  10569. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  10570. builder.EndRow();
  10571. #endregion
  10572. builder.EndTable();
  10573. //换行
  10574. builder.Writeln("");
  10575. builder.Writeln("");
  10576. }
  10577. #region 获取文档中的所有表格 设置文字自适应
  10578. // 获取文档中的所有表格。
  10579. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  10580. {
  10581. // 遍历表格中的所有行。
  10582. foreach (Aspose.Words.Tables.Row row in table.Rows)
  10583. {
  10584. foreach (Cell cell in row.Cells)
  10585. {
  10586. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  10587. cellFormat.Width = 0;
  10588. }
  10589. }
  10590. }
  10591. #endregion
  10592. #region 设置页眉
  10593. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  10594. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  10595. if (System.IO.File.Exists(voucherHeaderPath))
  10596. {
  10597. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  10598. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  10599. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  10600. Shape shape = builder.InsertImage(imageBytes);
  10601. // 调整图片位置
  10602. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  10603. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  10604. shape.Top = 50; // 将图片距离页眉上边缘的距离
  10605. shape.Left = 0; // 将图片距离页面左边缘的距离
  10606. shape.Width = 81; // 设置图片宽度
  10607. shape.Height = 36; // 设置图片高度
  10608. }
  10609. //靠右
  10610. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  10611. //// 设置页脚上下边距
  10612. //builder.PageSetup.HeaderDistance = 42;
  10613. // 添加页眉线
  10614. Aspose.Words.Border borderHeader = null;
  10615. try
  10616. {
  10617. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  10618. }
  10619. catch (Exception e)
  10620. {
  10621. // TODO Auto-generated catch block
  10622. //e.printStackTrace();
  10623. }
  10624. borderHeader.Shadow = true;
  10625. borderHeader.DistanceFromText = 2;
  10626. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  10627. #endregion
  10628. }
  10629. catch (Exception ex)
  10630. {
  10631. }
  10632. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  10633. doc.Save(fileDir);
  10634. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  10635. return Ok(JsonView(true, "操作成功!", Url));
  10636. }
  10637. /// <summary>
  10638. /// 酒店预订
  10639. /// 生成 预定成本 Excel
  10640. /// </summary>
  10641. /// <param name="_dto"></param>
  10642. /// <returns></returns>
  10643. [HttpPost]
  10644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10645. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  10646. {
  10647. #region 参数验证
  10648. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  10649. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  10650. if (!vadalitorRes.IsValid)
  10651. {
  10652. var errors = new StringBuilder();
  10653. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  10654. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  10655. }
  10656. #region 团组操作权限验证 76 酒店预定模块
  10657. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10658. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10659. #endregion
  10660. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10661. #region 页面操作权限验证
  10662. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10663. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10664. #endregion
  10665. #endregion
  10666. decimal _rate = 1.00M;
  10667. string _currency = string.Empty;
  10668. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  10669. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10670. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  10671. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10672. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  10673. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  10674. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  10675. if (_GroupCostParameter == null)
  10676. {
  10677. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  10678. bool isIntType = int.TryParse(_currency, out int currId);
  10679. if (isIntType)
  10680. {
  10681. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  10682. }
  10683. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  10684. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  10685. if (currInfo == null)
  10686. {
  10687. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  10688. }
  10689. else _rate = currInfo.Rate;
  10690. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  10691. {
  10692. _rate = _GroupCostParameter.Rate;
  10693. }
  10694. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10695. string strFileName = "HotelStatement/";
  10696. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10697. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  10698. var rateDatas = new List<dynamic>();
  10699. #region 数据处理
  10700. foreach (var item in hrDtas)
  10701. {
  10702. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  10703. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  10704. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  10705. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  10706. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  10707. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  10708. {
  10709. continue;
  10710. }
  10711. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  10712. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  10713. string singleRoomFeeStr = string.Empty,
  10714. doubleRoomFeeStr = string.Empty,
  10715. suiteRoomFeeStr = string.Empty,
  10716. otherRoomFeeStr = string.Empty,
  10717. payMoneyStr = string.Empty,
  10718. cardPriceStr = string.Empty;
  10719. if (roomCurr.Equals("CNY"))
  10720. {
  10721. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  10722. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10723. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10724. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10725. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10726. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  10727. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  10728. }
  10729. else
  10730. {
  10731. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10732. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10733. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10734. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10735. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  10736. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  10737. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10738. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10739. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10740. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  10741. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  10742. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  10743. if (ccpPaymentCurrency.Equals("CNY"))
  10744. {
  10745. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  10746. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  10747. }
  10748. else
  10749. {
  10750. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  10751. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  10752. }
  10753. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  10754. if (hotelcardPriceCurrency.Equals("CNY"))
  10755. {
  10756. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  10757. }
  10758. else
  10759. {
  10760. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  10761. }
  10762. }
  10763. string breakfastPriceStr = string.Empty,
  10764. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  10765. governmentRentStr = string.Empty,
  10766. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  10767. cityTaxStr = string.Empty,
  10768. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  10769. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  10770. if (!string.IsNullOrEmpty(breakfastCurrency1))
  10771. {
  10772. if (breakfastCurrency1.Equals("CNY"))
  10773. {
  10774. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  10775. }
  10776. else
  10777. {
  10778. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  10779. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  10780. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  10781. }
  10782. }
  10783. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  10784. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  10785. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  10786. {
  10787. if (governmentRentCurrency.Equals("CNY"))
  10788. {
  10789. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  10790. }
  10791. else
  10792. {
  10793. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  10794. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  10795. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  10796. }
  10797. }
  10798. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  10799. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  10800. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  10801. {
  10802. if (cityTaxStrCurrency1.Equals("CNY"))
  10803. {
  10804. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  10805. }
  10806. else
  10807. {
  10808. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  10809. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  10810. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  10811. }
  10812. }
  10813. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  10814. int payDId = roomInfo?.PayDId ?? 0;
  10815. pcfds.Add(new HotelReservations_PCFD_View()
  10816. {
  10817. City = item.City,
  10818. HotelName = item.HotelName,
  10819. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  10820. // SingleRoomCount = item.SingleRoomCount,
  10821. SingleRoomPrice = singleRoomFeeStr,
  10822. // DoubleRoomCount = item.DoubleRoomCount,
  10823. DoubleRoomPrice = doubleRoomFeeStr,
  10824. //SuiteRoomCount = item.SuiteRoomCount,
  10825. SuiteRoomPrice = suiteRoomFeeStr,
  10826. OtherRoomPrice = otherRoomFeeStr,
  10827. //OtherRoomCount = item.OtherRoomCount,
  10828. BreakfastPrice = breakfastPriceStr,
  10829. GovernmentRent = governmentRentStr,
  10830. CityTax = cityTaxStr,
  10831. RoomExplanation = item.RoomExplanation,
  10832. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  10833. PayTime = roomInfo?.ConsumptionDate,
  10834. BankNo = roomInfo?.BankNo,
  10835. PayMoney = payMoneyStr,
  10836. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  10837. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  10838. CardPrice = cardPriceStr,
  10839. Remark = ccpInfo.Remark
  10840. });
  10841. }
  10842. #endregion
  10843. //载入模板
  10844. WorkbookDesigner designer = new WorkbookDesigner();
  10845. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  10846. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  10847. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  10848. designer.SetDataSource("TourNo", groupInfo.TourCode);
  10849. var rateDatas1 = rateDatas.Distinct();
  10850. var rateStr = string.Empty;
  10851. foreach (var item in rateDatas1)
  10852. {
  10853. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  10854. }
  10855. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  10856. designer.SetDataSource("Opertor", userInfo.CnName);
  10857. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  10858. dt.TableName = "ViewMyHotelReservations";
  10859. designer.SetDataSource(dt);
  10860. designer.Process();
  10861. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10862. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  10863. designer.Workbook.Save(serverPath);
  10864. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  10865. #region 删除指定行
  10866. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  10867. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  10868. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  10869. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  10870. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  10871. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  10872. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  10873. cssIndex = dt.Columns["CityTax"].Ordinal,
  10874. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  10875. remarkIndex = dt.Columns["Remark"].Ordinal;
  10876. //删除指定列
  10877. foreach (DataRow item in dt.Rows)
  10878. {
  10879. string singleStr = item["SingleRoomPrice"].ToString();
  10880. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  10881. if (containsDigitButNotZero1) singleDel = false;
  10882. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  10883. string doubleStr = item["DoubleRoomPrice"].ToString();
  10884. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10885. if (containsDigitButNotZero2) doubleDel = false;
  10886. string suiteStr = item["SuiteRoomPrice"].ToString();
  10887. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10888. if (containsDigitButNotZero3) suiteDel = false;
  10889. string otherStr = item["OtherRoomPrice"].ToString();
  10890. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  10891. if (containsDigitButNotZero4) otherDel = false;
  10892. string zcStr = item["BreakfastPrice"].ToString();
  10893. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  10894. if (containsDigitButNotZero5) zcDel = false;
  10895. string dsStr = item["GovernmentRent"].ToString();
  10896. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  10897. if (containsDigitButNotZero6) dsDel = false;
  10898. string cssStr = item["CityTax"].ToString();
  10899. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  10900. if (containsDigitButNotZero7) cssDel = false;
  10901. string cpStr = item["ConsumptionPatterns"].ToString();
  10902. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  10903. string remarkStr = item["Remark"].ToString();
  10904. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  10905. }
  10906. DeleteColumn(serverPath, remarkIndex, remarkDel);
  10907. DeleteColumn(serverPath, cpIndex, cpDel);
  10908. DeleteColumn(serverPath, dsIndex, dsDel);
  10909. DeleteColumn(serverPath, cssIndex, cssDel);
  10910. DeleteColumn(serverPath, zcIndex, zcDel);
  10911. DeleteColumn(serverPath, otherIndex, otherDel);
  10912. DeleteColumn(serverPath, suiteIndex, suiteDel);
  10913. DeleteColumn(serverPath, doubleIndex, doubleDel);
  10914. DeleteColumn(serverPath, singleIndex, singleDel);
  10915. #endregion
  10916. //只保留第一个表格
  10917. DeleteSheet(serverPath);
  10918. return Ok(JsonView(true, "操作成功", url = rst));
  10919. }
  10920. else
  10921. {
  10922. _currency = _GroupCostParameter.Currency;
  10923. bool isIntType = int.TryParse(_currency, out int currId);
  10924. if (isIntType)
  10925. {
  10926. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  10927. }
  10928. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  10929. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  10930. if (currInfo == null)
  10931. {
  10932. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  10933. }
  10934. if (!_currency.ToUpper().Equals("CNY"))
  10935. {
  10936. _rate = _GroupCostParameter.Rate;
  10937. }
  10938. _rate = currInfo.Rate;
  10939. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  10940. string strFileName = "HotelStatement/";
  10941. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10942. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  10943. #region 数据处理
  10944. foreach (var item in hrDtas)
  10945. {
  10946. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  10947. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  10948. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  10949. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  10950. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  10951. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  10952. string singleRoomFeeStr = string.Empty,
  10953. doubleRoomFeeStr = string.Empty,
  10954. suiteRoomFeeStr = string.Empty,
  10955. otherRoomFeeStr = string.Empty,
  10956. payMoneyStr = string.Empty,
  10957. cardPriceStr = string.Empty;
  10958. if (roomCurr.Equals(_currency))
  10959. {
  10960. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  10961. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  10962. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  10963. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  10964. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  10965. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  10966. }
  10967. else
  10968. {
  10969. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10970. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10971. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10972. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10973. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  10974. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  10975. }
  10976. string breakfastPriceStr = string.Empty,
  10977. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  10978. governmentRentStr = string.Empty,
  10979. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  10980. cityTaxStrStr = string.Empty,
  10981. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  10982. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  10983. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  10984. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  10985. int payDId = roomInfo?.PayDId ?? 0;
  10986. pcfds.Add(new HotelReservations_PCFD_View()
  10987. {
  10988. City = item.City,
  10989. HotelName = item.HotelName,
  10990. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  10991. // SingleRoomCount = item.SingleRoomCount,
  10992. SingleRoomPrice = singleRoomFeeStr,
  10993. // DoubleRoomCount = item.DoubleRoomCount,
  10994. DoubleRoomPrice = doubleRoomFeeStr,
  10995. //SuiteRoomCount = item.SuiteRoomCount,
  10996. SuiteRoomPrice = suiteRoomFeeStr,
  10997. OtherRoomPrice = otherRoomFeeStr,
  10998. //OtherRoomCount = item.OtherRoomCount,
  10999. BreakfastPrice = breakfastPriceStr,
  11000. GovernmentRent = governmentRentStr,
  11001. CityTax = cityTaxStrStr,
  11002. RoomExplanation = item.RoomExplanation,
  11003. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  11004. PayTime = roomInfo?.ConsumptionDate,
  11005. BankNo = roomInfo?.BankNo,
  11006. PayMoney = payMoneyStr,
  11007. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  11008. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  11009. CardPrice = cardPriceStr,
  11010. Remark = ccpInfo.Remark
  11011. });
  11012. }
  11013. #endregion
  11014. //载入模板
  11015. WorkbookDesigner designer = new WorkbookDesigner();
  11016. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  11017. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  11018. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  11019. designer.SetDataSource("TourNo", groupInfo.TourCode);
  11020. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  11021. designer.SetDataSource("Opertor", userInfo.CnName);
  11022. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  11023. dt.TableName = "ViewMyHotelReservations";
  11024. designer.SetDataSource(dt);
  11025. designer.Process();
  11026. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  11027. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  11028. designer.Workbook.Save(serverPath);
  11029. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  11030. #region 删除指定行
  11031. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  11032. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  11033. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  11034. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  11035. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  11036. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  11037. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  11038. cssIndex = dt.Columns["CityTax"].Ordinal,
  11039. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  11040. remarkIndex = dt.Columns["Remark"].Ordinal;
  11041. //删除指定列
  11042. foreach (DataRow item in dt.Rows)
  11043. {
  11044. string singleStr = item["SingleRoomPrice"].ToString();
  11045. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  11046. if (containsDigitButNotZero1) singleDel = false;
  11047. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  11048. string doubleStr = item["DoubleRoomPrice"].ToString();
  11049. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11050. if (containsDigitButNotZero2) doubleDel = false;
  11051. string suiteStr = item["SuiteRoomPrice"].ToString();
  11052. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  11053. if (containsDigitButNotZero3) suiteDel = false;
  11054. string otherStr = item["OtherRoomPrice"].ToString();
  11055. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  11056. if (containsDigitButNotZero4) otherDel = false;
  11057. string zcStr = item["BreakfastPrice"].ToString();
  11058. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  11059. if (containsDigitButNotZero5) zcDel = false;
  11060. string dsStr = item["GovernmentRent"].ToString();
  11061. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  11062. if (containsDigitButNotZero6) dsDel = false;
  11063. string cssStr = item["CityTax"].ToString();
  11064. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  11065. if (containsDigitButNotZero7) cssDel = false;
  11066. string cpStr = item["ConsumptionPatterns"].ToString();
  11067. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  11068. string remarkStr = item["Remark"].ToString();
  11069. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  11070. }
  11071. DeleteColumn(serverPath, remarkIndex, remarkDel);
  11072. DeleteColumn(serverPath, cpIndex, cpDel);
  11073. DeleteColumn(serverPath, dsIndex, dsDel);
  11074. DeleteColumn(serverPath, cssIndex, cssDel);
  11075. DeleteColumn(serverPath, zcIndex, zcDel);
  11076. DeleteColumn(serverPath, otherIndex, otherDel);
  11077. DeleteColumn(serverPath, suiteIndex, suiteDel);
  11078. DeleteColumn(serverPath, doubleIndex, doubleDel);
  11079. DeleteColumn(serverPath, singleIndex, singleDel);
  11080. #endregion
  11081. //只保留第一个表格
  11082. DeleteSheet(serverPath);
  11083. return Ok(JsonView(true, "操作成功", url = rst));
  11084. }
  11085. return Ok(JsonView(false));
  11086. }
  11087. /// <summary>
  11088. /// 删除指定列
  11089. /// </summary>
  11090. /// <param name="file"></param>
  11091. /// <param name="columnIndex"></param>
  11092. /// <param name="isDel"></param>
  11093. private void DeleteColumn(string file, int columnIndex, bool isDel)
  11094. {
  11095. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  11096. //wb.Save(file);
  11097. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  11098. if (sheet1 != null)
  11099. {
  11100. if (isDel)
  11101. {
  11102. Cells cells = sheet1.Cells;
  11103. cells.DeleteColumn(columnIndex);
  11104. }
  11105. }
  11106. wb.Save(file);
  11107. }
  11108. /// <summary>
  11109. /// 删除sheet
  11110. /// </summary>
  11111. /// <param name="file"></param>
  11112. /// <param name="sheetName"></param>
  11113. private void DeleteSheet(string file, string sheetName = "")
  11114. {
  11115. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  11116. //wb.Save(file);
  11117. List<string> sheets = new List<string>();
  11118. foreach (var item in wb.Worksheets)
  11119. {
  11120. sheets.Add(item.Name);
  11121. }
  11122. if (sheets.Count > 0)
  11123. {
  11124. sheets.RemoveAt(0);//不删除第一个sheet
  11125. foreach (var item in sheets)
  11126. {
  11127. wb.Worksheets.RemoveAt(item);
  11128. }
  11129. }
  11130. wb.Save(file);
  11131. }
  11132. /// <summary>
  11133. /// 酒店预订
  11134. /// 确认单
  11135. /// </summary>
  11136. /// <param name="_dto"></param>
  11137. /// <returns></returns>
  11138. [HttpPost]
  11139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11140. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  11141. {
  11142. try
  11143. {
  11144. #region 参数验证
  11145. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11146. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11147. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11148. #region 团组操作权限验证 76 酒店预定模块
  11149. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11150. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11151. #endregion
  11152. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11153. #region 页面操作权限验证
  11154. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11155. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11156. #endregion
  11157. #endregion
  11158. //团组信息
  11159. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  11160. //酒店数据
  11161. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  11162. if (listhoteldata.Count < 0)
  11163. {
  11164. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  11165. }
  11166. //利datatable存储
  11167. DataTable dt = new DataTable();
  11168. dt.Columns.Add("CheckInDate", typeof(string));
  11169. dt.Columns.Add("City", typeof(string));
  11170. dt.Columns.Add("Hotel", typeof(string));
  11171. dt.Columns.Add("Room", typeof(string));
  11172. for (int i = 0; i < listhoteldata.Count; i++)
  11173. {
  11174. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  11175. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  11176. while (dayStart < dayEnd)
  11177. {
  11178. string temp = "";
  11179. DataRow row = dt.NewRow();
  11180. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  11181. row["City"] = listhoteldata[i].City;
  11182. row["Hotel"] = listhoteldata[i].HotelName;
  11183. if (listhoteldata[i].SingleRoomCount > 0)
  11184. {
  11185. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  11186. }
  11187. if (listhoteldata[i].DoubleRoomCount > 0)
  11188. {
  11189. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  11190. }
  11191. if (listhoteldata[i].SuiteRoomCount > 0)
  11192. {
  11193. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  11194. }
  11195. if (listhoteldata[i].OtherRoomCount > 0)
  11196. {
  11197. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  11198. }
  11199. row["Room"] = temp;
  11200. dt.Rows.Add(row);
  11201. dayStart = dayStart.AddDays(1);
  11202. }
  11203. }
  11204. Dictionary<string, string> dic = new Dictionary<string, string>();
  11205. dic.Add("Dele", di.TeamName);
  11206. dic.Add("City", di.VisitCountry);
  11207. //模板路径
  11208. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  11209. //载入模板
  11210. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  11211. DocumentBuilder builder = new DocumentBuilder(doc);
  11212. foreach (var key in dic.Keys)
  11213. {
  11214. builder.MoveToBookmark(key);
  11215. builder.Write(dic[key]);
  11216. }
  11217. //获取word里所有表格
  11218. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11219. //获取所填表格的序数
  11220. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11221. var rowStart = tableOne.Rows[0]; //获取第1行
  11222. //循环赋值
  11223. for (int i = 0; i < dt.Rows.Count; i++)
  11224. {
  11225. builder.MoveToCell(0, i + 1, 0, 0);
  11226. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  11227. builder.MoveToCell(0, i + 1, 1, 0);
  11228. builder.Write(dt.Rows[i]["City"].ToString());
  11229. builder.MoveToCell(0, i + 1, 2, 0);
  11230. builder.Write(dt.Rows[i]["Hotel"].ToString());
  11231. builder.MoveToCell(0, i + 1, 3, 0);
  11232. builder.Write(dt.Rows[i]["Room"].ToString());
  11233. }
  11234. //删除多余行
  11235. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  11236. {
  11237. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  11238. }
  11239. string strFileName = di.TeamName + "酒店确认单.doc";
  11240. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  11241. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  11242. return Ok(JsonView(true, "成功", url));
  11243. }
  11244. catch (Exception ex)
  11245. {
  11246. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  11247. }
  11248. }
  11249. #endregion
  11250. #region 团组状态
  11251. /// <summary>
  11252. /// 团组状态列表 Page
  11253. /// </summary>
  11254. /// <param name="dto">团组列表请求dto</param>
  11255. /// <returns></returns>
  11256. [HttpPost]
  11257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11258. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  11259. {
  11260. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  11261. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  11262. {
  11263. string sqlWhere = string.Empty;
  11264. if (dto.IsSure == 0) //未完成
  11265. {
  11266. sqlWhere += string.Format(@" And IsSure = 0");
  11267. }
  11268. else if (dto.IsSure == 1) //已完成
  11269. {
  11270. sqlWhere += string.Format(@" And IsSure = 1");
  11271. }
  11272. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  11273. {
  11274. string tj = dto.SearchCriteria;
  11275. 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}%')",
  11276. tj, tj, tj, tj, tj);
  11277. }
  11278. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  11279. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  11280. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  11281. From (
  11282. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  11283. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  11284. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  11285. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  11286. From Grp_DelegationInfo gdi
  11287. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  11288. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  11289. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  11290. Where gdi.IsDel = 0 {0}
  11291. ) temp ", sqlWhere);
  11292. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  11293. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  11294. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  11295. }
  11296. else
  11297. {
  11298. return Ok(JsonView(false, "查询失败"));
  11299. }
  11300. }
  11301. /// <summary>
  11302. /// 团组状态
  11303. /// 设置操作完成
  11304. /// </summary>
  11305. /// <param name="dto">团组列表请求dto</param>
  11306. /// <returns></returns>
  11307. [HttpPost]
  11308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11309. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  11310. {
  11311. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  11312. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  11313. {
  11314. Id = dto.Id,
  11315. IsSure = 1
  11316. };
  11317. var result = await _sqlSugar.Updateable(_DelegationInfo)
  11318. .UpdateColumns(it => new { it.IsSure })
  11319. .WhereColumns(it => new { it.Id })
  11320. .ExecuteCommandAsync();
  11321. if (result > 0)
  11322. {
  11323. return Ok(JsonView(true, "操作完成!"));
  11324. }
  11325. return Ok(JsonView(false, "操作失败!"));
  11326. }
  11327. #endregion
  11328. #region 保险费用录入
  11329. /// <summary>
  11330. /// 根据团组Id查询保险费用列表
  11331. /// </summary>
  11332. /// <param name="dto"></param>
  11333. /// <returns></returns>
  11334. [HttpPost]
  11335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11336. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  11337. {
  11338. Result groupData = await _customersRep.CustomersByDiId(dto);
  11339. if (groupData.Code != 0)
  11340. {
  11341. return Ok(JsonView(false, groupData.Msg));
  11342. }
  11343. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11344. }
  11345. /// <summary>
  11346. /// 根据保险费用Id查询保险费用详细
  11347. /// </summary>
  11348. /// <param name="dto"></param>
  11349. /// <returns></returns>
  11350. [HttpPost]
  11351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11352. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  11353. {
  11354. try
  11355. {
  11356. Result groupData = await _customersRep.CustomersById(dto);
  11357. if (groupData.Code != 0)
  11358. {
  11359. return Ok(JsonView(false, groupData.Msg));
  11360. }
  11361. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11362. }
  11363. catch (Exception ex)
  11364. {
  11365. return Ok(JsonView(false, ex.Message));
  11366. }
  11367. }
  11368. /// <summary>
  11369. /// 保险费用录入页面初始化绑定
  11370. /// </summary>
  11371. /// <param name="dto"></param>
  11372. /// <returns></returns>
  11373. [HttpPost]
  11374. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11375. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  11376. {
  11377. try
  11378. {
  11379. Result groupData = await _customersRep.CustomersInitialize(dto);
  11380. if (groupData.Code != 0)
  11381. {
  11382. return Ok(JsonView(false, groupData.Msg));
  11383. }
  11384. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11385. }
  11386. catch (Exception ex)
  11387. {
  11388. return Ok(JsonView(false, ex.Message));
  11389. }
  11390. }
  11391. /// <summary>
  11392. /// 保险费用操作(Status:1.新增,2.修改)
  11393. /// </summary>
  11394. /// <param name="dto"></param>
  11395. /// <returns></returns>
  11396. [HttpPost]
  11397. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11398. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  11399. {
  11400. Result groupData = await _customersRep.OpCustomers(dto);
  11401. if (groupData.Code != 0)
  11402. {
  11403. return Ok(JsonView(false, groupData.Msg));
  11404. }
  11405. #region 应用推送
  11406. try
  11407. {
  11408. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11409. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11410. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11411. //2024-10-21 新增LZ UID
  11412. var userIds = new List<int>() { 21 };
  11413. string title = $"系统通知";
  11414. var diId = dto.DiId;
  11415. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11416. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11417. string content = "";
  11418. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11419. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  11420. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11421. }
  11422. catch (Exception ex)
  11423. {
  11424. }
  11425. #endregion
  11426. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11427. }
  11428. /// <summary>
  11429. /// 保险文件上传
  11430. /// </summary>
  11431. /// <param name="file"></param>
  11432. /// <returns></returns>
  11433. [HttpPost]
  11434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11435. public async Task<IActionResult> UploadCus(IFormFile file)
  11436. {
  11437. try
  11438. {
  11439. if (file != null)
  11440. {
  11441. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  11442. //文件名称
  11443. string projectFileName = file.FileName;
  11444. //上传的文件的路径
  11445. string filePath = "";
  11446. if (!Directory.Exists(fileDir))
  11447. {
  11448. Directory.CreateDirectory(fileDir);
  11449. }
  11450. //上传的文件的路径
  11451. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  11452. using (FileStream fs = System.IO.File.Create(filePath))
  11453. {
  11454. file.CopyTo(fs);
  11455. fs.Flush();
  11456. }
  11457. return Ok(JsonView(true, "上传成功!", projectFileName));
  11458. }
  11459. else
  11460. {
  11461. return Ok(JsonView(false, "上传失败!"));
  11462. }
  11463. }
  11464. catch (Exception ex)
  11465. {
  11466. return Ok(JsonView(false, "程序错误!"));
  11467. throw;
  11468. }
  11469. }
  11470. /// <summary>
  11471. /// 保险删除指定文件
  11472. /// </summary>
  11473. /// <param name="dto"></param>
  11474. /// <returns></returns>
  11475. [HttpPost]
  11476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11477. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  11478. {
  11479. try
  11480. {
  11481. string filePath = "";
  11482. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  11483. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  11484. //int id = 0;
  11485. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  11486. // 删除该文件
  11487. try
  11488. {
  11489. System.IO.File.Delete(filePath);
  11490. 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()
  11491. {
  11492. Attachment = "",
  11493. }).ExecuteCommandAsync();
  11494. if (result != 0)
  11495. {
  11496. return Ok(JsonView(true, "成功!"));
  11497. }
  11498. else
  11499. {
  11500. return Ok(JsonView(false, "失败!"));
  11501. }
  11502. }
  11503. catch (Exception)
  11504. {
  11505. 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()
  11506. {
  11507. Attachment = "",
  11508. }).ExecuteCommandAsync();
  11509. if (result != 0)
  11510. {
  11511. return Ok(JsonView(true, "成功!"));
  11512. }
  11513. else
  11514. {
  11515. return Ok(JsonView(false, "失败!"));
  11516. }
  11517. }
  11518. }
  11519. catch (Exception ex)
  11520. {
  11521. return Ok(JsonView(false, "程序错误!"));
  11522. throw;
  11523. }
  11524. }
  11525. /// <summary>
  11526. /// 保险费用操作(删除)
  11527. /// </summary>
  11528. /// <param name="dto"></param>
  11529. /// <returns></returns>
  11530. [HttpPost]
  11531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11532. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  11533. {
  11534. try
  11535. {
  11536. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  11537. if (!res)
  11538. {
  11539. return Ok(JsonView(false, "删除失败"));
  11540. }
  11541. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  11542. {
  11543. IsDel = 1,
  11544. DeleteUserId = dto.DeleteUserId,
  11545. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11546. }).ExecuteCommandAsync();
  11547. return Ok(JsonView(true, "删除成功!"));
  11548. }
  11549. catch (Exception ex)
  11550. {
  11551. return Ok(JsonView(false, "程序错误!"));
  11552. throw;
  11553. }
  11554. }
  11555. #endregion
  11556. #region 接团客户名单 PageId 104
  11557. /// <summary>
  11558. /// 接团客户名单
  11559. /// 迁移数据(慎用!)
  11560. /// </summary>
  11561. /// <param name="dto"></param>
  11562. /// <returns></returns>
  11563. [HttpPost]
  11564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11565. public async Task<IActionResult> PostTourClientListChange()
  11566. {
  11567. try
  11568. {
  11569. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  11570. //var groupClinetData1
  11571. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  11572. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  11573. int updateCount = 0;
  11574. if (oldOAClientList.Count > 0)
  11575. {
  11576. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  11577. _sqlSugar.BeginTran();
  11578. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  11579. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  11580. foreach (var item in oldOAClientList)
  11581. {
  11582. int comId = 0;
  11583. string format = "yyyy-MM-dd HH:mm:ss";
  11584. string data11 = "1990-01-01 00:00";
  11585. var data1 = IsValidDate(item.OPdate, format);
  11586. if (data1) data11 = item.OPdate;
  11587. //客户公司验证
  11588. if (!string.IsNullOrEmpty(item.Company))
  11589. {
  11590. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  11591. if (clientComInfo == null) // add
  11592. {
  11593. var addInfo = new Crm_CustomerCompany()
  11594. {
  11595. CompanyAbbreviation = "",
  11596. CompanyFullName = item.Company,
  11597. Address = "",
  11598. PostCodes = "",
  11599. LastedOpUserId = item.OPer,
  11600. LastedOpDt = Convert.ToDateTime(data11),
  11601. CreateUserId = item.OPer,
  11602. CreateTime = Convert.ToDateTime(data11),
  11603. IsDel = 0
  11604. };
  11605. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  11606. if (comId1 > 0) comId = comId1;
  11607. }
  11608. else comId = clientComInfo.Id;
  11609. }
  11610. //客户人员验证
  11611. int clientId = 0;
  11612. string name = item.LastName + item.Name;
  11613. if (!string.IsNullOrEmpty(name))
  11614. {
  11615. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  11616. if (clientInfo == null)
  11617. {
  11618. DateTime? dateTime = null;
  11619. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  11620. if (isDt) dateTime = birthDayDt;
  11621. var addInfo1 = new Crm_DeleClient()
  11622. {
  11623. CrmCompanyId = comId,
  11624. DiId = -1,
  11625. LastName = item.LastName,
  11626. FirstName = item.Name,
  11627. OldName = "",
  11628. Pinyin = item.Pinyin,
  11629. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  11630. Marriage = 0,
  11631. Phone = item.Phone,
  11632. Job = item.Job,
  11633. BirthDay = dateTime
  11634. };
  11635. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  11636. if (clientId1 > 0) clientId = clientId1;
  11637. }
  11638. else clientId = clientInfo.Id;
  11639. }
  11640. if (clientId < 1)
  11641. {
  11642. continue;
  11643. }
  11644. int airType = 0;
  11645. if (item.AirType == "超经舱") airType = 459;
  11646. else if (item.AirType == "公务舱") airType = 458;
  11647. else if (item.AirType == "经济舱") airType = 460;
  11648. else if (item.AirType == "其他") airType = 565;
  11649. else if (item.AirType == "头等舱") airType = 457;
  11650. var _TourClientListEntity = new Grp_TourClientList()
  11651. {
  11652. DiId = item.Diid,
  11653. ClientId = clientId,
  11654. CreateUserId = item.OPer,
  11655. CreateTime = Convert.ToDateTime(data11),
  11656. Remark = item.Remark,
  11657. IsDel = item.Isdel,
  11658. ShippingSpaceTypeId = airType,
  11659. ShippingSpaceSpecialNeeds = item.AirRemark,
  11660. HotelSpecialNeeds = item.RoomType
  11661. };
  11662. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  11663. if (_TourClientList > 0)
  11664. {
  11665. updateCount++;
  11666. }
  11667. }
  11668. _sqlSugar.CommitTran();
  11669. }
  11670. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  11671. }
  11672. catch (Exception ex)
  11673. {
  11674. _sqlSugar.RollbackTran();
  11675. return Ok(JsonView(false, ex.Message));
  11676. }
  11677. return Ok(JsonView(true));
  11678. }
  11679. private bool IsValidDate(string dateString, string format)
  11680. {
  11681. DateTime dateValue;
  11682. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  11683. return valid;
  11684. }
  11685. /// <summary>
  11686. /// 接团客户名单
  11687. /// 根据团组Id查询List
  11688. /// </summary>
  11689. /// <param name="dto"></param>
  11690. /// <returns></returns>
  11691. [HttpPost]
  11692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11693. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  11694. {
  11695. #region 参数验证
  11696. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  11697. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  11698. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  11699. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11700. #region 页面操作权限验证
  11701. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11702. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11703. #endregion
  11704. #endregion
  11705. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  11706. if (viewData.Code != 0)
  11707. {
  11708. return Ok(JsonView(false, viewData.Msg));
  11709. }
  11710. return Ok(JsonView(viewData.Data));
  11711. }
  11712. /// <summary>
  11713. /// 接团客户名单
  11714. /// 基础数据 Init
  11715. /// </summary>
  11716. /// <param name="_dto"></param>
  11717. /// <returns></returns>
  11718. [HttpPost]
  11719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11720. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  11721. {
  11722. #region 参数验证
  11723. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11724. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11725. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11726. #region 页面操作权限验证
  11727. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11728. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11729. #endregion
  11730. #endregion
  11731. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  11732. }
  11733. /// <summary>
  11734. /// 接团客户名单
  11735. /// 根据 Id查询 Details
  11736. /// </summary>
  11737. /// <param name="_dto"></param>
  11738. /// <returns></returns>
  11739. [HttpPost]
  11740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11741. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  11742. {
  11743. #region 参数验证
  11744. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11745. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11746. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11747. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11748. #region 页面操作权限验证
  11749. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11750. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  11751. #endregion
  11752. #endregion
  11753. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  11754. if (viewData.Code != 0)
  11755. {
  11756. return Ok(JsonView(false, viewData.Msg));
  11757. }
  11758. return Ok(JsonView(viewData.Data));
  11759. }
  11760. /// <summary>
  11761. /// 接团客户名单
  11762. /// Add Or Edit
  11763. /// </summary>
  11764. /// <param name="_dto"></param>
  11765. /// <returns></returns>
  11766. [HttpPost]
  11767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11768. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  11769. {
  11770. #region 参数验证
  11771. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11772. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11773. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  11774. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11775. #region 页面操作权限验证
  11776. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11777. if (_dto.Id == 0) //添加
  11778. {
  11779. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11780. }
  11781. else if (_dto.Id >= 0) //修改
  11782. {
  11783. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  11784. }
  11785. #endregion
  11786. #endregion
  11787. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  11788. if (viewData.Code != 0)
  11789. {
  11790. return Ok(JsonView(false, viewData.Msg));
  11791. }
  11792. return Ok(JsonView(true));
  11793. }
  11794. /// <summary>
  11795. /// 接团客户名单
  11796. /// AddMultiple(添加多个)
  11797. /// </summary>
  11798. /// <param name="_dto"></param>
  11799. /// <returns></returns>
  11800. [HttpPost]
  11801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11802. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  11803. {
  11804. #region 参数验证
  11805. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11806. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11807. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11808. #region 页面操作权限验证
  11809. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11810. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  11811. #endregion
  11812. #endregion
  11813. var viewData = await _tourClientListRep._AddMultiple(_dto);
  11814. if (viewData.Code != 0)
  11815. {
  11816. return Ok(JsonView(false, viewData.Msg));
  11817. }
  11818. return Ok(JsonView(true));
  11819. }
  11820. /// <summary>
  11821. /// 接团客户名单
  11822. /// Del
  11823. /// </summary>
  11824. /// <param name="_dto"></param>
  11825. /// <returns></returns>
  11826. [HttpPost]
  11827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11828. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  11829. {
  11830. #region 参数验证
  11831. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11832. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11833. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11834. #region 页面操作权限验证
  11835. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11836. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  11837. #endregion
  11838. #endregion
  11839. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  11840. if (viewData.Code != 0)
  11841. {
  11842. return Ok(JsonView(false, viewData.Msg));
  11843. }
  11844. return Ok(JsonView(true));
  11845. }
  11846. /// <summary>
  11847. /// 接团客户名单
  11848. /// 文件下载 客户名单
  11849. /// </summary>
  11850. /// <param name="_dto"></param>
  11851. /// <returns></returns>
  11852. [HttpPost]
  11853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11854. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  11855. {
  11856. #region 参数验证
  11857. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  11858. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  11859. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  11860. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11861. #region 页面操作权限验证
  11862. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11863. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11864. #endregion
  11865. #endregion
  11866. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  11867. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  11868. From Grp_TourClientList tcl
  11869. Left Join
  11870. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  11871. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  11872. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  11873. From Crm_DeleClient dc
  11874. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  11875. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  11876. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  11877. Where dc.IsDel = 0) temp
  11878. On temp.DcId =tcl.ClientId
  11879. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  11880. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  11881. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  11882. //载入模板
  11883. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  11884. if (_dto.Language == 1)
  11885. {
  11886. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  11887. }
  11888. //载入模板
  11889. var doc = new Document(tempPath);
  11890. DocumentBuilder builder = new DocumentBuilder(doc);
  11891. //获取word里所有表格
  11892. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11893. //获取所填表格的序数
  11894. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11895. var rowStart = tableOne.Rows[0]; //获取第1行
  11896. if (_dto.Language == 0)
  11897. {
  11898. //循环赋值
  11899. for (int i = 0; i < DcList.Count; i++)
  11900. {
  11901. builder.MoveToCell(0, i + 1, 0, 0);
  11902. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  11903. builder.MoveToCell(0, i + 1, 1, 0);
  11904. int sex = DcList[i].Sex;
  11905. string sexStr = string.Empty;
  11906. if (sex == 0) sexStr = "男";
  11907. else if (sex == 1) sexStr = "女";
  11908. else sexStr = "未设置";
  11909. builder.Write(sexStr);
  11910. builder.MoveToCell(0, i + 1, 2, 0);
  11911. string birthDay = DcList[i].BirthDay;
  11912. string birthDayStr = string.Empty;
  11913. if (!string.IsNullOrEmpty(birthDay))
  11914. {
  11915. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  11916. }
  11917. builder.Write(birthDayStr);
  11918. builder.MoveToCell(0, i + 1, 3, 0);
  11919. string company = "";
  11920. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11921. {
  11922. company = DcList[i].CompanyFullName.ToString();
  11923. }
  11924. builder.Write(company);
  11925. builder.MoveToCell(0, i + 1, 4, 0);
  11926. builder.Write(DcList[i].Job);
  11927. }
  11928. }
  11929. else if (_dto.Language == 1)
  11930. {
  11931. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  11932. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  11933. List<string> transArrayStr = new List<string>();
  11934. string transStrRes1 = "";
  11935. for (int i = 0; i < DcList.Count; i++)
  11936. {
  11937. var dc = DcList[i];
  11938. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  11939. if (dc.Job.Equals("暂无")) dc.Job = "-";
  11940. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  11941. if (DcList.Count - 1 == i) transStrRes1 += str1;
  11942. else transStrRes1 += $"{str1}|";
  11943. }
  11944. //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";
  11945. string transStrRes = "";
  11946. if (transStrRes1.Length > 0)
  11947. {
  11948. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  11949. }
  11950. //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
  11951. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  11952. //List<string> transArray = new List<string> { };
  11953. List<TranslateInfo> transArray = new List<TranslateInfo>();
  11954. if (transStrRes.Contains("|"))
  11955. {
  11956. string[] transArray1 = transStrRes.Split('|');
  11957. if (transArray1.Length > 0)
  11958. {
  11959. foreach (var item in transArray1)
  11960. {
  11961. if (item.Contains("&"))
  11962. {
  11963. string[] transArray2 = item.Split('&');
  11964. int index = 0;
  11965. string companyName = "", job = "";
  11966. if (transArray2.Length > 0)
  11967. {
  11968. bool success = int.TryParse(transArray2[0].Trim(), out index);
  11969. if (1 < transArray2.Length) companyName = transArray2[1];
  11970. if (2 < transArray2.Length) job = transArray2[2];
  11971. }
  11972. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  11973. }
  11974. }
  11975. }
  11976. }
  11977. //循环赋值
  11978. for (int i = 0; i < DcList.Count; i++)
  11979. {
  11980. string PYName = "";
  11981. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  11982. {
  11983. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  11984. string PY_First = DcList[i].Pinyin.Split('/')[1];
  11985. PYName = PY_First + " " + PY_Last;
  11986. }
  11987. else
  11988. {
  11989. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  11990. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  11991. PYName = PY_First + " " + PY_Last;
  11992. }
  11993. builder.MoveToCell(0, i + 1, 0, 0);
  11994. builder.Write(PYName);
  11995. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  11996. builder.MoveToCell(0, i + 1, 1, 0);
  11997. builder.Write(sex);
  11998. DateTime birthDt;
  11999. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  12000. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  12001. builder.MoveToCell(0, i + 1, 2, 0);
  12002. builder.Write(birthday);
  12003. string company = string.Empty, job = string.Empty;
  12004. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  12005. if (dcTransInfo != null)
  12006. {
  12007. company = dcTransInfo.CompanyName;
  12008. job = dcTransInfo.Job;
  12009. }
  12010. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  12011. {
  12012. //查询对照表
  12013. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  12014. if (tempCec != null)
  12015. {
  12016. company = tempCec.enName;
  12017. }
  12018. //翻译
  12019. else
  12020. {
  12021. }
  12022. }
  12023. builder.MoveToCell(0, i + 1, 3, 0);
  12024. builder.Write(company);
  12025. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  12026. {
  12027. //查询对照表
  12028. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  12029. if (tempPec != null)
  12030. {
  12031. job = tempPec.enName;
  12032. }
  12033. //翻译
  12034. else
  12035. {
  12036. }
  12037. }
  12038. builder.MoveToCell(0, i + 1, 4, 0);
  12039. builder.Write(job);
  12040. }
  12041. }
  12042. //删除多余行
  12043. while (tableOne.Rows.Count > DcList.Count + 1)
  12044. {
  12045. tableOne.Rows.RemoveAt(DcList.Count + 1);
  12046. }
  12047. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  12048. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  12049. doc.Save(fileDir);
  12050. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  12051. return Ok(JsonView(true, "操作成功!", Url));
  12052. }
  12053. private class TranslateInfo
  12054. {
  12055. public int Index { get; set; }
  12056. public string CompanyName { get; set; }
  12057. public string Job { get; set; }
  12058. }
  12059. #endregion
  12060. #region 团组倒推表
  12061. /// <summary>
  12062. /// 倒推表基础数据
  12063. /// Init
  12064. /// </summary>
  12065. /// <param name="dto"></param>
  12066. /// <returns></returns>
  12067. [HttpPost]
  12068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12069. public async Task<IActionResult> PostInvertedListInit()
  12070. {
  12071. var viewData = await _invertedListRep._Init();
  12072. if (viewData.Code != 0)
  12073. {
  12074. return Ok(JsonView(false, viewData.Msg));
  12075. }
  12076. return Ok(JsonView(viewData.Data));
  12077. }
  12078. /// <summary>
  12079. /// 倒推表
  12080. /// Info
  12081. /// </summary>
  12082. /// <param name="dto"></param>
  12083. /// <returns></returns>
  12084. [HttpPost]
  12085. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12086. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  12087. {
  12088. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  12089. if (viewData.Code != 0)
  12090. {
  12091. return Ok(JsonView(false, viewData.Msg));
  12092. }
  12093. return Ok(JsonView(viewData.Data));
  12094. }
  12095. /// <summary>
  12096. /// 倒推表
  12097. /// Create
  12098. /// </summary>
  12099. /// <param name="dto"></param>
  12100. /// <returns></returns>
  12101. [HttpPost]
  12102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12103. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  12104. {
  12105. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  12106. if (viewData.Code != 0)
  12107. {
  12108. return Ok(JsonView(false, viewData.Msg));
  12109. }
  12110. return Ok(JsonView(viewData.Data));
  12111. }
  12112. /// <summary>
  12113. /// 倒推表
  12114. /// Update
  12115. /// </summary>
  12116. /// <param name="dto"></param>
  12117. /// <returns></returns>
  12118. [HttpPost]
  12119. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12120. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  12121. {
  12122. var viewData = await _invertedListRep._Update(dto);
  12123. if (viewData.Code != 0)
  12124. {
  12125. return Ok(JsonView(false, viewData.Msg));
  12126. }
  12127. return Ok(JsonView(viewData.Data));
  12128. }
  12129. /// <summary>
  12130. /// 倒推表
  12131. /// File Download
  12132. /// </summary>
  12133. /// <param name="dto"></param>
  12134. /// <returns></returns>
  12135. [HttpPost]
  12136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12137. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  12138. {
  12139. var info2 = await _invertedListRep._Info(1, dto.DiId);
  12140. if (info2.Code != 0)
  12141. {
  12142. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  12143. }
  12144. var info1 = info2.Data as InvertedListInfoView;
  12145. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  12146. string teamName = "";
  12147. if (info != null) teamName = info.TeamName;
  12148. //载入模板
  12149. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  12150. DocumentBuilder builder = new DocumentBuilder(doc);
  12151. //利用键值对存放数据
  12152. Dictionary<string, string> dic = new Dictionary<string, string>();
  12153. dic.Add("TeamName", teamName);
  12154. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  12155. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  12156. dic.Add("BPRemark", info1.ApprovalDataRemark);
  12157. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  12158. dic.Add("SQRemark", info1.ApprovalRemark);
  12159. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  12160. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  12161. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  12162. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  12163. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  12164. dic.Add("QZRemark", info1.VisaInformationRemark);
  12165. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  12166. dic.Add("SQQZRemark", info1.SendVisaRemark);
  12167. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  12168. dic.Add("CQRemark", info1.IssueVisaRemark);
  12169. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  12170. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  12171. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  12172. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  12173. #region 填充word模板书签内容
  12174. foreach (var key in dic.Keys)
  12175. {
  12176. builder.MoveToBookmark(key);
  12177. builder.Write(dic[key]);
  12178. }
  12179. #endregion
  12180. var fileDir = AppSettingsHelper.Get("WordBasePath");
  12181. string fileName = $"{teamName}团出行准备流程表.doc";
  12182. string filePath = fileDir + $@"InvertedList/{fileName}";
  12183. doc.Save(filePath);
  12184. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  12185. return Ok(JsonView(true, "操作成功!", Url));
  12186. }
  12187. #endregion
  12188. #region 三公签证费用(签证费、代办费)
  12189. /// <summary>
  12190. /// 三公签证费用(签证费、代办费)
  12191. /// List
  12192. /// </summary>
  12193. /// <returns></returns>
  12194. [HttpPost]
  12195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12196. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  12197. {
  12198. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  12199. if (_view.Code != 0)
  12200. {
  12201. return Ok(JsonView(false, _view.Msg));
  12202. }
  12203. return Ok(JsonView(true, "操作成功!", _view.Data));
  12204. }
  12205. /// <summary>
  12206. /// 三公签证费用(签证费、代办费)
  12207. /// Add Or Update
  12208. /// </summary>
  12209. /// <returns></returns>
  12210. [HttpPost]
  12211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12212. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  12213. {
  12214. var _view = await _visaFeeInfoRep._Update(_dto);
  12215. if (_view.Code != 0)
  12216. {
  12217. return Ok(JsonView(false, _view.Msg));
  12218. }
  12219. return Ok(JsonView(true, _view.Msg));
  12220. }
  12221. #endregion
  12222. #region 酒店询价
  12223. /// <summary>
  12224. /// 酒店询价
  12225. /// Init
  12226. /// </summary>
  12227. /// <param name="dto"></param>
  12228. /// <returns></returns>
  12229. [HttpPost]
  12230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12231. public async Task<IActionResult> PostHotelInquiryInit()
  12232. {
  12233. var res = await _hotelInquiryRep._Init();
  12234. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12235. return Ok(JsonView(true, res.Msg, res.Data));
  12236. }
  12237. /// <summary>
  12238. /// 酒店询价
  12239. /// page Item
  12240. /// </summary>
  12241. /// <param name="_dto"></param>
  12242. /// <returns></returns>
  12243. [HttpPost]
  12244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12245. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  12246. {
  12247. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  12248. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12249. var view = res.Data as PageDataViewBase;
  12250. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  12251. }
  12252. /// <summary>
  12253. /// 酒店询价
  12254. /// info
  12255. /// </summary>
  12256. /// <param name="_dto"></param>
  12257. /// <returns></returns>
  12258. [HttpPost]
  12259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12260. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  12261. {
  12262. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  12263. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12264. return Ok(JsonView(true, res.Msg, res.Data));
  12265. }
  12266. /// <summary>
  12267. /// 酒店询价
  12268. /// Add Or Edit
  12269. /// </summary>
  12270. /// <param name="_dto"></param>
  12271. /// <returns></returns>
  12272. [HttpPost]
  12273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12274. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  12275. {
  12276. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  12277. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12278. return Ok(JsonView(true, res.Msg, res.Data));
  12279. }
  12280. /// <summary>
  12281. /// 酒店询价
  12282. /// Del
  12283. /// </summary>
  12284. /// <param name="_dto"></param>
  12285. /// <returns></returns>
  12286. [HttpPost]
  12287. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12288. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  12289. {
  12290. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  12291. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  12292. return Ok(JsonView(true, res.Msg, res.Data));
  12293. }
  12294. #endregion
  12295. #region 下载匹配op行程单
  12296. /// <summary>
  12297. /// 匹配op行程单
  12298. /// Init
  12299. /// </summary>
  12300. /// <param name="dto">团组列表请求dto</param>
  12301. /// <returns></returns>
  12302. [HttpPost]
  12303. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12304. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  12305. {
  12306. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  12307. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12308. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  12309. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  12310. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  12311. .Where(it => it.IsDel == 0)
  12312. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  12313. .OrderByDescending(it => it.CreateUserId)
  12314. .ToList();
  12315. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  12316. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12317. var diids = groupInfos.Select(it => it.Id).ToList();
  12318. List<string> countrys = new List<string>();
  12319. foreach (var item in country)
  12320. {
  12321. var data = _groupRepository.FormartTeamName(item);
  12322. var dataArray = _groupRepository.GroupSplitCountry(data);
  12323. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12324. }
  12325. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  12326. List<string> areaArray = new List<string>(); //GetGroupCityLine
  12327. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  12328. foreach (var item in areaItem)
  12329. {
  12330. string areaStr = item.Value;
  12331. if (!string.IsNullOrEmpty(areaStr))
  12332. {
  12333. string[] str1 = areaStr.Split("-");
  12334. if (str1.Length > 0)
  12335. {
  12336. areaArray.AddRange(str1);
  12337. }
  12338. }
  12339. }
  12340. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  12341. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  12342. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  12343. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  12344. .ToList();
  12345. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  12346. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  12347. .Where(it => countriesIds.Contains(it.Id))
  12348. .Select(it => new { it.Id, Name = it.Name_CN })
  12349. .ToList();
  12350. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  12351. .Select(it => it.TeamName).ToList();
  12352. stopwatch.Stop();
  12353. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  12354. }
  12355. ///// <summary>
  12356. ///// 匹配op行程单
  12357. ///// Init 查询区域数据
  12358. ///// </summary>
  12359. ///// <param name="dto">团组列表请求dto</param>
  12360. ///// <returns></returns>
  12361. //[HttpPost]
  12362. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12363. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  12364. //{
  12365. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  12366. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  12367. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  12368. // if (string.IsNullOrEmpty(countriesDataStr))
  12369. // {
  12370. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  12371. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  12372. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  12373. // }
  12374. // else
  12375. // {
  12376. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  12377. // }
  12378. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  12379. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  12380. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  12381. // List<dynamic> childList = new List<dynamic>();
  12382. // int parentId = dto.CountriesId;
  12383. // if (provinceData.Count > 1)
  12384. // {
  12385. // foreach (var item1 in provinceData)
  12386. // {
  12387. // List<dynamic> childList1 = new List<dynamic>();
  12388. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  12389. // foreach (var item2 in citiesData1)
  12390. // {
  12391. // List<dynamic> childList2 = new List<dynamic>();
  12392. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12393. // foreach (var item3 in countiesData1)
  12394. // {
  12395. // childList2.Add(new
  12396. // {
  12397. // id = item3.Id,
  12398. // parentId = item2.Id,
  12399. // level = "district",
  12400. // name = item3.Name_CN,
  12401. // });
  12402. // }
  12403. // childList1.Add(new
  12404. // {
  12405. // id = item2.Id,
  12406. // parentId = item1.Id,
  12407. // level = "city",
  12408. // name = item2.Name_CN,
  12409. // childList = childList2
  12410. // });
  12411. // }
  12412. // childList.Add(new
  12413. // {
  12414. // id = item1.Id,
  12415. // parentId = parentId,
  12416. // level = "province",
  12417. // name = item1.Name_CN,
  12418. // childList = childList1
  12419. // });
  12420. // }
  12421. // //城市
  12422. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  12423. // foreach (var item2 in citiesData2)
  12424. // {
  12425. // List<dynamic> childList22 = new List<dynamic>();
  12426. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12427. // foreach (var item3 in countiesData1)
  12428. // {
  12429. // childList22.Add(new
  12430. // {
  12431. // id = item3.Id,
  12432. // parentId = item2.Id,
  12433. // level = "district",
  12434. // name = item3.Name_CN,
  12435. // });
  12436. // }
  12437. // childList.Add(new
  12438. // {
  12439. // id = item2.Id,
  12440. // parentId = parentId,
  12441. // level = "city",
  12442. // name = item2.Name_CN,
  12443. // childList = childList22
  12444. // });
  12445. // }
  12446. // }
  12447. // else
  12448. // {
  12449. // foreach (var item2 in citiesData)
  12450. // {
  12451. // string cname = item2.Name_CN;
  12452. // List<dynamic> childList1 = new List<dynamic>();
  12453. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  12454. // foreach (var item3 in countiesData1)
  12455. // {
  12456. // childList1.Add(new
  12457. // {
  12458. // Id = item3.Id,
  12459. // parentId = item2.Id,
  12460. // level = "district",
  12461. // name = item3.Name_CN
  12462. // });
  12463. // }
  12464. // childList.Add(new
  12465. // {
  12466. // id = item2.Id,
  12467. // parentId = parentId,
  12468. // level = "city",
  12469. // name = item2.Name_CN,
  12470. // childList = childList1
  12471. // });
  12472. // }
  12473. // }
  12474. // stopwatch.Stop();
  12475. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  12476. //}
  12477. /// <summary>
  12478. /// 匹配op行程单
  12479. /// 接团信息列表 Page
  12480. /// </summary>
  12481. /// <param name="dto">团组列表请求dto</param>
  12482. /// <returns></returns>
  12483. [HttpPost]
  12484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12485. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  12486. {
  12487. var swatch = new Stopwatch();
  12488. swatch.Start();
  12489. #region 参数验证
  12490. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12491. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12492. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12493. #region 页面操作权限验证
  12494. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12495. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  12496. #endregion
  12497. #endregion
  12498. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12499. {
  12500. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  12501. string sqlWhere = "";
  12502. if (!string.IsNullOrEmpty(dto.Country))
  12503. {
  12504. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  12505. }
  12506. if (!string.IsNullOrEmpty(dto.Area))
  12507. {
  12508. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  12509. }
  12510. if (!string.IsNullOrEmpty(dto.TeamName))
  12511. {
  12512. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  12513. }
  12514. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  12515. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  12516. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  12517. swatch.Stop();
  12518. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  12519. }
  12520. else
  12521. {
  12522. return Ok(JsonView(false, "查询失败"));
  12523. }
  12524. }
  12525. /// <summary>
  12526. /// 匹配op行程单
  12527. /// 行程单下载
  12528. /// </summary>
  12529. /// <param name="dto">团组列表请求dto</param>
  12530. /// <returns></returns>
  12531. [HttpPost]
  12532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12533. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  12534. {
  12535. #region 参数验证
  12536. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12537. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  12538. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12539. #region 页面操作权限验证
  12540. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  12541. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  12542. #endregion
  12543. #endregion
  12544. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  12545. {
  12546. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  12547. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  12548. }
  12549. else
  12550. {
  12551. return Ok(JsonView(false, "下载失败!"));
  12552. }
  12553. }
  12554. #endregion
  12555. #region 国家信息 数据 注释
  12556. //[HttpPost]
  12557. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  12558. //{
  12559. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  12560. // foreach (var item in dto)
  12561. // {
  12562. // infos.Add(new Grp_GroupsTaskAssignment()
  12563. // {
  12564. // DIId = item,
  12565. // CTId = 82,
  12566. // UId = 248,
  12567. // IsEnable = 1,
  12568. // CreateUserId = 233,
  12569. // CreateTime = DateTime.Now,
  12570. // IsDel = 0
  12571. // });
  12572. // infos.Add(new Grp_GroupsTaskAssignment()
  12573. // {
  12574. // DIId = item,
  12575. // CTId = 82,
  12576. // UId = 286,
  12577. // IsEnable = 1,
  12578. // CreateUserId = 233,
  12579. // CreateTime = DateTime.Now,
  12580. // IsDel = 0
  12581. // });
  12582. // }
  12583. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  12584. // return Ok("操作成功");
  12585. //}
  12586. //public class paramJsonDto
  12587. //{
  12588. // public List<CountriesInfo> str { get; set; }
  12589. //}
  12590. //[HttpPost]
  12591. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  12592. //{
  12593. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  12594. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  12595. // List<Sys_Cities> cities = new List<Sys_Cities>();
  12596. // List<Sys_Cities> districts = new List<Sys_Cities>();
  12597. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12598. // _sqlSugar.BeginTran();
  12599. // int countitiesIndex = 0;
  12600. // foreach (var item in dto.str)
  12601. // {
  12602. // dynamic data = item.c;
  12603. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  12604. // if (data != null)
  12605. // {
  12606. // countitiesIndex++;
  12607. // foreach (var item1 in data)
  12608. // {
  12609. // string cnname = item1.cn;
  12610. // string enname = item1.en;
  12611. // Sys_Cities provinceInfo = new Sys_Cities()
  12612. // {
  12613. // CountriesId = countriesId,
  12614. // Name_CN = cnname,
  12615. // Name_EN = enname,
  12616. // ParentId = 0,
  12617. // IsCapital = 1,
  12618. // CreateUserId = 208,
  12619. // CreateTime = DateTime.Now,
  12620. // IsDel = 0
  12621. // };
  12622. // if (item1.lv == "province") //省份
  12623. // {
  12624. // provinceInfo.Level = 1;
  12625. // int provinceId = 0;
  12626. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  12627. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  12628. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12629. // var data1 = item1.c;
  12630. // foreach (var item2 in data1)
  12631. // {
  12632. // if (item2.lv == "city")
  12633. // {
  12634. // string citycnname = item2.cn;
  12635. // string cityenname = item2.en;
  12636. // Sys_Cities cityInfo = new Sys_Cities()
  12637. // {
  12638. // CountriesId = countriesId,
  12639. // ParentId = provinceId,
  12640. // Level = 2,
  12641. // Name_CN = citycnname,
  12642. // Name_EN = cityenname,
  12643. // IsCapital = 1,
  12644. // CreateUserId = 208,
  12645. // CreateTime = DateTime.Now,
  12646. // IsDel = 0
  12647. // };
  12648. // if (item2.c != null)
  12649. // {
  12650. // int cityId = 0;
  12651. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  12652. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12653. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  12654. // foreach (var item3 in item2.c)
  12655. // {
  12656. // if (item3.lv == "district")
  12657. // {
  12658. // var districtInfo = new Sys_Cities()
  12659. // {
  12660. // CountriesId = countriesId,
  12661. // Name_CN = item3.cn,
  12662. // Name_EN = item3.en,
  12663. // Level = 3,
  12664. // ParentId = cityId,
  12665. // IsCapital = 1,
  12666. // CreateUserId = 208,
  12667. // CreateTime = DateTime.Now,
  12668. // IsDel = 0
  12669. // };
  12670. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12671. // //{
  12672. // districts.Add(districtInfo);
  12673. // //}
  12674. // }
  12675. // }
  12676. // }
  12677. // else
  12678. // {
  12679. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  12680. // //{
  12681. // cities.Add(cityInfo);
  12682. // //}
  12683. // }
  12684. // }
  12685. // }
  12686. // }
  12687. // else if (item1.lv == "city")//城市
  12688. // {
  12689. // provinceInfo.Level = 2;
  12690. // if (item1.c != null)
  12691. // {
  12692. // int cityId = 0;
  12693. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  12694. // if (citiesInfo != null) cityId = citiesInfo.Id;
  12695. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  12696. // foreach (var item3 in item1.c)
  12697. // {
  12698. // if (item3.lv == "district")
  12699. // {
  12700. // var districtInfo = new Sys_Cities()
  12701. // {
  12702. // CountriesId = countriesId,
  12703. // Name_CN = item3.cn,
  12704. // Name_EN = item3.en,
  12705. // Level = 3,
  12706. // ParentId = cityId,
  12707. // IsCapital = 1,
  12708. // CreateUserId = 208,
  12709. // CreateTime = DateTime.Now,
  12710. // IsDel = 0
  12711. // };
  12712. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  12713. // //{
  12714. // districts.Add(districtInfo);
  12715. // //}
  12716. // }
  12717. // }
  12718. // }
  12719. // else
  12720. // {
  12721. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  12722. // //{
  12723. // cities.Add(provinceInfo);
  12724. // //}
  12725. // }
  12726. // }
  12727. // }
  12728. // }
  12729. // }
  12730. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  12731. // cities = cities.Distinct().ToList();
  12732. // districts = districts.Distinct().ToList();
  12733. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  12734. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  12735. // cities.AddRange(districts);
  12736. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  12737. // //_sqlSugar.RollbackTran();
  12738. // _sqlSugar.CommitTran();
  12739. // return Ok(JsonView(false, "操作成功!"));
  12740. //}
  12741. //[HttpPost]
  12742. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  12743. //{
  12744. // List<CountitiesInfo> infos = dto.MyProperty;
  12745. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  12746. // _sqlSugar.BeginTran();
  12747. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  12748. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  12749. // foreach (var item in infos)
  12750. // {
  12751. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  12752. // if (countryInfo != null)
  12753. // {
  12754. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  12755. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  12756. // if (cityInfo1 != null)
  12757. // {
  12758. // cityInfo1.IsCapital = 0;
  12759. // cityInfos.Add(cityInfo1);
  12760. // }
  12761. // }
  12762. // }
  12763. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  12764. // .UpdateColumns(it => it.IsCapital)
  12765. // .WhereColumns(it => it.Id)
  12766. // .ExecuteCommand();
  12767. // //_sqlSugar.RollbackTran();
  12768. // _sqlSugar.CommitTran();
  12769. // return Ok(JsonView(false, "操作成功!"));
  12770. //}
  12771. //public class CounrtiesDto
  12772. //{
  12773. // public List<CountitiesInfo> MyProperty { get; set; }
  12774. //}
  12775. //public class CountitiesInfo
  12776. //{
  12777. // /// <summary>
  12778. // /// 圣约翰
  12779. // /// </summary>
  12780. // public string capital_name_chinese { get; set; }
  12781. // /// <summary>
  12782. // ///
  12783. // /// </summary>
  12784. // public string capital_name { get; set; }
  12785. // /// <summary>
  12786. // ///
  12787. // /// </summary>
  12788. // public string country_type { get; set; }
  12789. // /// <summary>
  12790. // /// 安提瓜和巴布达
  12791. // /// </summary>
  12792. // public string country_name_chinese { get; set; }
  12793. // /// <summary>
  12794. // /// 安提瓜和巴布达
  12795. // /// </summary>
  12796. // public string country_name_chinese_short { get; set; }
  12797. // /// <summary>
  12798. // /// 安提瓜和巴布达
  12799. // /// </summary>
  12800. // public string country_name_chinese_UN { get; set; }
  12801. // /// <summary>
  12802. // ///
  12803. // /// </summary>
  12804. // public string country_name_english_abbreviation { get; set; }
  12805. // /// <summary>
  12806. // ///
  12807. // /// </summary>
  12808. // public string country_name_english_formal { get; set; }
  12809. // /// <summary>
  12810. // ///
  12811. // /// </summary>
  12812. // public string country_name_english_UN { get; set; }
  12813. // /// <summary>
  12814. // ///
  12815. // /// </summary>
  12816. // public string continent_name { get; set; }
  12817. // /// <summary>
  12818. // ///
  12819. // /// </summary>
  12820. // public string subregion_name { get; set; }
  12821. // /// <summary>
  12822. // ///
  12823. // /// </summary>
  12824. // public string country_code2 { get; set; }
  12825. // /// <summary>
  12826. // ///
  12827. // /// </summary>
  12828. // public string country_code3 { get; set; }
  12829. // /// <summary>
  12830. // ///
  12831. // /// </summary>
  12832. // public string phone_code { get; set; }
  12833. //}
  12834. //public class CountriesInfo : BasicInfo
  12835. //{
  12836. // public List<CitiesInfo> c { get; set; }
  12837. //}
  12838. //public class CitiesInfo : BasicInfo
  12839. //{
  12840. // public List<AreaInfo> c { get; set; }
  12841. //}
  12842. //public class AreaInfo : BasicInfo
  12843. //{
  12844. // public List<AreaInfo> c { get; set; }
  12845. //}
  12846. //public class BasicInfo
  12847. //{
  12848. // public string code { get; set; }
  12849. // public string cn { get; set; }
  12850. // public string lv { get; set; }
  12851. // public string en { get; set; }
  12852. //}
  12853. #endregion
  12854. #region 查看邀请方
  12855. /// <summary>
  12856. /// 查看邀请方
  12857. /// 邀请方信息 Init
  12858. /// </summary>
  12859. /// <param name="dto"></param>
  12860. /// <returns></returns>
  12861. [HttpPost]
  12862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12863. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  12864. {
  12865. string sqlWhere = string.Empty;
  12866. if (!string.IsNullOrEmpty(dto.Search))
  12867. {
  12868. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  12869. }
  12870. string sql = string.Format($@"Select
  12871. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  12872. Id,
  12873. UnitName
  12874. From Res_InvitationOfficialActivityData
  12875. Where IsDel = 0
  12876. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  12877. RefAsync<int> total = 0;
  12878. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12879. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  12880. }
  12881. /// <summary>
  12882. /// 查看邀请方
  12883. /// 国家信息 Init
  12884. /// </summary>
  12885. /// <param name="dto"></param>
  12886. /// <returns></returns>
  12887. [HttpPost]
  12888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12889. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  12890. {
  12891. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  12892. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  12893. var diids = groupInfos.Select(it => it.Id).ToList();
  12894. List<string> countrys = new List<string>();
  12895. foreach (var item in country)
  12896. {
  12897. var data = _groupRepository.FormartTeamName(item);
  12898. var dataArray = _groupRepository.GroupSplitCountry(data);
  12899. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  12900. }
  12901. countrys = countrys.Distinct().ToList();
  12902. for (int i = 0; i < countrys.Count; i++)
  12903. {
  12904. string item = countrys[i];
  12905. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  12906. {
  12907. countrys.Remove(item);
  12908. i--;
  12909. }
  12910. }
  12911. RefAsync<int> total = 0;
  12912. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  12913. .Where(it => countrys.Contains(it.Name_CN))
  12914. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12915. .Select(it => new { id = it.Id, name = it.Name_CN })
  12916. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12917. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12918. }
  12919. /// <summary>
  12920. /// 查看邀请方
  12921. /// 城市信息 Init
  12922. /// </summary>
  12923. /// <param name="dto"></param>
  12924. /// <returns></returns>
  12925. [HttpPost]
  12926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12927. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  12928. {
  12929. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  12930. RefAsync<int> total = 0;
  12931. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  12932. .Where(it => it.CountriesId == dto.CountiesId)
  12933. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12934. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  12935. .Select(it => new { id = it.Id, name = it.Name_CN })
  12936. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12937. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12938. }
  12939. /// <summary>
  12940. /// 查看邀请方
  12941. /// 团组名称 Init
  12942. /// </summary>
  12943. /// <param name="dto"></param>
  12944. /// <returns></returns>
  12945. [HttpPost]
  12946. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12947. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  12948. {
  12949. var watch = new Stopwatch();
  12950. watch.Start();
  12951. RefAsync<int> total = 0;
  12952. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  12953. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  12954. .Where((oa, di) => oa.IsDel == 0)
  12955. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  12956. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  12957. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  12958. .Distinct()
  12959. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12960. watch.Stop();
  12961. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  12962. }
  12963. /// <summary>
  12964. /// 查看邀请方
  12965. /// 团组 & 邀请方信息
  12966. /// </summary>
  12967. /// <param name="dto"></param>
  12968. /// <returns></returns>
  12969. [HttpPost]
  12970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12971. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  12972. {
  12973. var watch = new Stopwatch();
  12974. watch.Start();
  12975. RefAsync<int> total = 0;
  12976. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  12977. .AS("Grp_DelegationInfo")
  12978. .Includes(x => x.InvitingInfos)
  12979. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  12980. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  12981. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  12982. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  12983. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  12984. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  12985. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12986. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  12987. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  12988. infos.ForEach(x =>
  12989. {
  12990. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  12991. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  12992. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  12993. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  12994. });
  12995. watch.Stop();
  12996. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  12997. }
  12998. #endregion
  12999. #region 报批行程
  13000. /// <summary>
  13001. /// 报批行程初始化
  13002. /// </summary>
  13003. /// <param name="dto"></param>
  13004. /// <returns></returns>
  13005. [HttpPost]
  13006. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  13007. {
  13008. const int chiNumber = 5;
  13009. var jw = JsonView(false);
  13010. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  13011. var group = groupList.First();
  13012. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13013. group = groupList.First(x => x.Id == diid);
  13014. if (group == null)
  13015. {
  13016. jw.Msg = "暂无团组!";
  13017. return Ok(jw);
  13018. }
  13019. var data = new
  13020. {
  13021. groupList = groupList.Select(x => new
  13022. {
  13023. x.TeamName,
  13024. x.Id
  13025. }),
  13026. content = new ArrayList(),
  13027. groupInfo = new
  13028. {
  13029. group.VisitDays,
  13030. group.TourCode,
  13031. group.VisitPNumber,
  13032. group.TeamName,
  13033. group.Id,
  13034. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  13035. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  13036. },
  13037. };
  13038. var resultArr = new ArrayList();
  13039. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  13040. if (content.Count == 0)
  13041. {
  13042. var stay = "-";
  13043. var cityPath = "-";
  13044. //添加城市路径以及住宿地
  13045. //黑屏代码数据
  13046. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  13047. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  13048. {
  13049. jw = JsonView(true, "黑屏代码有误!", data);
  13050. return Ok(jw);
  13051. }
  13052. foreach (DataRow row in dtBlack.Rows)
  13053. {
  13054. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13055. {
  13056. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  13057. return Ok(jw);
  13058. }
  13059. }
  13060. //黑屏代码获取时间区间
  13061. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  13062. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  13063. _sqlSugar.BeginTran();
  13064. for (int i = 0; i < timeArr.Count; i++)
  13065. {
  13066. stay = "-";
  13067. cityPath = "-";
  13068. DateTime NewData = DateTime.Parse(timeArr[i]);
  13069. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  13070. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  13071. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  13072. if (tbSelect.Length > 0)
  13073. {
  13074. List<string> threeCodeStr = new List<string>();
  13075. foreach (var item in tbSelect)
  13076. {
  13077. var threeCode = item["Three"].ToString() ?? "";
  13078. if (threeCode.Length == 6)
  13079. {
  13080. var start = threeCode.Substring(0, 3);
  13081. var end = threeCode.Substring(3, 3);
  13082. if (threeCodeStr.Count == 0)
  13083. {
  13084. threeCodeStr.Add(start);
  13085. threeCodeStr.Add(end);
  13086. }
  13087. else
  13088. {
  13089. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  13090. {
  13091. threeCodeStr.Add(end);
  13092. }
  13093. else
  13094. {
  13095. threeCodeStr.Add(start);
  13096. threeCodeStr.Add(end);
  13097. }
  13098. }
  13099. }
  13100. }
  13101. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  13102. var last = threeCodeStr.Last();
  13103. foreach (var item in threeCodeStr)
  13104. {
  13105. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  13106. if (item.Equals(last))
  13107. {
  13108. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  13109. }
  13110. }
  13111. cityPath = cityPath.Trim('-');
  13112. }
  13113. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  13114. appro.Diid = diid ?? -1;
  13115. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  13116. appro.Id = thisId;
  13117. appro.CreateUserId = dto.UserId;
  13118. appro.CreateTime = DateTime.Now;
  13119. content.Add(appro);
  13120. }
  13121. _sqlSugar.CommitTran();
  13122. }
  13123. foreach (var x in content)
  13124. {
  13125. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  13126. if (chiList.Count < chiNumber)
  13127. {
  13128. for (int i = chiList.Count; i < chiNumber; i++)
  13129. {
  13130. chiList.Add(new Grp_ApprovalTravelDetails());
  13131. }
  13132. }
  13133. resultArr.Add(new
  13134. {
  13135. x.Id,
  13136. x.Date,
  13137. x.Diid,
  13138. chiList = chiList.Select(x1 => new
  13139. {
  13140. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  13141. x1.Details,
  13142. x1.ParentId,
  13143. x1.Id
  13144. })
  13145. });
  13146. }
  13147. data = data with
  13148. {
  13149. content = resultArr,
  13150. };
  13151. jw = JsonView(true, "获取成功!", data);
  13152. return Ok(jw);
  13153. }
  13154. /// <summary>
  13155. /// 报批行程删除
  13156. /// </summary>
  13157. /// <param name="dto"></param>
  13158. /// <returns></returns>
  13159. [HttpPost]
  13160. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  13161. {
  13162. var jw = JsonView(false);
  13163. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13164. if (group == null)
  13165. {
  13166. jw.Msg = "团组参数有误!";
  13167. return Ok(jw);
  13168. }
  13169. try
  13170. {
  13171. _sqlSugar.BeginTran();
  13172. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  13173. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  13174. {
  13175. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13176. DeleteUserId = dto.uesrId,
  13177. IsDel = 1
  13178. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  13179. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  13180. {
  13181. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13182. DeleteUserId = dto.uesrId,
  13183. IsDel = 1
  13184. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  13185. _sqlSugar.CommitTran();
  13186. jw = JsonView(true, "删除成功");
  13187. }
  13188. catch (Exception ex)
  13189. {
  13190. jw = JsonView(false, ex.Message);
  13191. }
  13192. return Ok(jw);
  13193. }
  13194. /// <summary>
  13195. /// 报批行程保存
  13196. /// </summary>
  13197. /// <param name="dto"></param>
  13198. /// <returns></returns>
  13199. [HttpPost]
  13200. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  13201. {
  13202. var jw = JsonView(false);
  13203. var Find = dto.Arr.Find(x => x.id == 0);
  13204. if (Find != null)
  13205. {
  13206. jw.Msg = "生成的ID为0!";
  13207. return Ok(jw);
  13208. }
  13209. foreach (var item in dto.Arr)
  13210. {
  13211. foreach (var chi in item.chiList)
  13212. {
  13213. if (chi.parentId == 0)
  13214. {
  13215. chi.parentId = item.id;
  13216. }
  13217. }
  13218. }
  13219. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  13220. _sqlSugar.BeginTran();
  13221. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  13222. {
  13223. var parentIds = dto.Arr.Select(x => x.id).ToList();
  13224. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  13225. {
  13226. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  13227. DeleteUserId = dto.UserId,
  13228. IsDel = 1
  13229. }).ExecuteCommand();
  13230. }
  13231. try
  13232. {
  13233. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  13234. {
  13235. CreateTime = DateTime.Now,
  13236. CreateUserId = dto.UserId,
  13237. Details = x.details,
  13238. ParentId = x.parentId,
  13239. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  13240. Remark = "",
  13241. IsDel = 0
  13242. }).ToList()).ExecuteCommand();
  13243. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  13244. {
  13245. Id = x.id,
  13246. Details = x.details,
  13247. ParentId = x.parentId,
  13248. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  13249. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  13250. {
  13251. Details = x.Details,
  13252. ParentId = x.ParentId,
  13253. Time = x.Time
  13254. }).ExecuteCommand();
  13255. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  13256. {
  13257. Id = x.id,
  13258. Date = x.date,
  13259. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  13260. {
  13261. Date = x.Date
  13262. }).ExecuteCommand();
  13263. _sqlSugar.CommitTran();
  13264. jw = JsonView(true, "保存成功!");
  13265. }
  13266. catch (Exception ex)
  13267. {
  13268. _sqlSugar.RollbackTran();
  13269. jw = JsonView(false, "保存失败!" + ex.Message);
  13270. }
  13271. return Ok(jw);
  13272. }
  13273. /// <summary>
  13274. /// 报批行程生成
  13275. /// </summary>
  13276. /// <param name="dto"></param>
  13277. /// <returns></returns>
  13278. [HttpPost]
  13279. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  13280. {
  13281. var jw = JsonView(false);
  13282. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13283. if (group == null)
  13284. {
  13285. jw.Msg = "暂无该团组!";
  13286. return Ok(jw);
  13287. }
  13288. //黑屏代码数据
  13289. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  13290. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  13291. {
  13292. jw.Msg = "黑屏代码有误!";
  13293. return Ok(jw);
  13294. }
  13295. foreach (DataRow row in dtBlack.Rows)
  13296. {
  13297. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13298. {
  13299. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  13300. return Ok(jw);
  13301. }
  13302. }
  13303. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13304. var resultArr = new ArrayList();
  13305. if (officialActivitiesArr.Count == 0)
  13306. {
  13307. jw.Msg = "暂无公务出访信息!";
  13308. return Ok(jw);
  13309. }
  13310. try
  13311. {
  13312. _sqlSugar.BeginTran();
  13313. DeleteApprovalJourney(new
  13314. Domain.Dtos.Groups.DeleteApprovalJourney
  13315. {
  13316. Diid = dto.Diid,
  13317. uesrId = dto.Userid
  13318. });
  13319. var stay = "-";
  13320. var cityPath = "-";
  13321. //添加城市路径以及住宿地
  13322. //黑屏代码获取时间区间
  13323. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  13324. var empty = "【未收入该三字码!请机票同事录入】";
  13325. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  13326. for (int i = 0; i < timeArr.Count; i++)
  13327. {
  13328. stay = "-";
  13329. cityPath = "-";
  13330. var chiarr = new List<Grp_ApprovalTravelDetails>();
  13331. DateTime NewData = DateTime.Parse(timeArr[i]);
  13332. 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();
  13333. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  13334. if (tbSelect.Length > 0)
  13335. {
  13336. List<string> threeCodeStr = new List<string>();
  13337. bool isTrade = false;
  13338. string trip = string.Empty;
  13339. var rowLast = tbSelect.Last();
  13340. var rowFirst = tbSelect.First();
  13341. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  13342. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  13343. var takeOffTime = DateTime.Parse(timeArr[i]);
  13344. var fallToTime = DateTime.Parse(timeArr[i]);
  13345. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  13346. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  13347. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  13348. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  13349. foreach (var item in tbSelect)
  13350. {
  13351. var start = string.Empty;
  13352. var end = string.Empty;
  13353. var threeCode = item["Three"].ToString() ?? "";
  13354. if (threeCode.Length == 6)
  13355. {
  13356. start = threeCode.Substring(0, 3);
  13357. end = threeCode.Substring(3, 3);
  13358. if (threeCodeStr.Count == 0)
  13359. {
  13360. threeCodeStr.Add(start);
  13361. threeCodeStr.Add(end);
  13362. }
  13363. else
  13364. {
  13365. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  13366. {
  13367. threeCodeStr.Add(end);
  13368. }
  13369. else
  13370. {
  13371. threeCodeStr.Add(start);
  13372. threeCodeStr.Add(end);
  13373. }
  13374. }
  13375. }
  13376. //处理机票信息
  13377. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  13378. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  13379. if (start_Object == null)
  13380. {
  13381. start_Object = new Res_ThreeCode()
  13382. {
  13383. AirPort = empty,
  13384. AirPort_En = empty,
  13385. City = empty,
  13386. Country = empty,
  13387. Four = empty,
  13388. Three = empty,
  13389. };
  13390. }
  13391. if (end_Object == null)
  13392. {
  13393. end_Object = new Res_ThreeCode()
  13394. {
  13395. AirPort = empty,
  13396. AirPort_En = empty,
  13397. City = empty,
  13398. Country = empty,
  13399. Four = empty,
  13400. Three = empty,
  13401. };
  13402. }
  13403. //机型判断
  13404. string airModel = item["AirModel"].ToString();
  13405. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  13406. string flightTime = item["FlightTime"].ToString();
  13407. if (flightTime!.Contains(":"))
  13408. {
  13409. flightTime = flightTime.Replace(":", "小时");
  13410. flightTime += "分钟";
  13411. }
  13412. if (flightTime.Contains("H"))
  13413. {
  13414. flightTime = flightTime.Replace("H", "小时");
  13415. }
  13416. if (flightTime.Contains("M"))
  13417. {
  13418. flightTime = flightTime.Replace("M", "分钟");
  13419. }
  13420. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  13421. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  13422. {
  13423. flightTime = flightDataTime.Hour > 0
  13424. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  13425. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  13426. ? flightDataTime.Minute.ToString() + "分钟" : "";
  13427. }
  13428. //航班号
  13429. string flightcode = item["Fliagtcode"].ToString();
  13430. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  13431. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  13432. if (aircompany == null)
  13433. {
  13434. aircompany = new Res_AirCompany
  13435. {
  13436. CnName = hsEmpty,
  13437. EnName = hsEmpty,
  13438. ShortCode = hsEmpty,
  13439. };
  13440. }
  13441. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  13442. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  13443. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  13444. if (isTrade)
  13445. {
  13446. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  13447. }
  13448. else
  13449. {
  13450. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  13451. }
  13452. }
  13453. chiarr.Add(new Grp_ApprovalTravelDetails
  13454. {
  13455. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  13456. CreateTime = DateTime.Now,
  13457. CreateUserId = dto.Userid,
  13458. ParentId = 0,
  13459. Details = trip
  13460. });
  13461. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  13462. var last = threeCodeStr.Last();
  13463. foreach (var item in threeCodeStr)
  13464. {
  13465. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  13466. if (item.Equals(last))
  13467. {
  13468. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  13469. }
  13470. }
  13471. cityPath = cityPath.Trim('-');
  13472. }
  13473. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  13474. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  13475. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  13476. appro.Diid = dto.Diid;
  13477. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  13478. appro.Id = thisId;
  13479. appro.CreateUserId = dto.Userid;
  13480. appro.CreateTime = DateTime.Now;
  13481. foreach (var item in gwinfo)
  13482. {
  13483. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  13484. chi.Details = "拜访" + item.Client;
  13485. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  13486. {
  13487. chi.Details += "," + item.ReqSample;
  13488. }
  13489. chi.ParentId = thisId;
  13490. chi.Time = item.Time;
  13491. chiarr.Add(chi);
  13492. }
  13493. if (chiarr.Count < 5)
  13494. {
  13495. for (int j = chiarr.Count; j < 5; j++)
  13496. {
  13497. chiarr.Add(new
  13498. Grp_ApprovalTravelDetails());
  13499. }
  13500. }
  13501. resultArr.Add(new
  13502. {
  13503. appro.Id,
  13504. appro.Date,
  13505. appro.Diid,
  13506. chiList = chiarr.Select(x1 => new
  13507. {
  13508. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  13509. x1.Details,
  13510. x1.ParentId,
  13511. x1.Id
  13512. })
  13513. });
  13514. }
  13515. _sqlSugar.CommitTran();
  13516. jw = JsonView(true, "生成成功!", resultArr);
  13517. }
  13518. catch (Exception ex)
  13519. {
  13520. jw.Code = 400;
  13521. jw.Msg = "生成失败!" + ex.Message;
  13522. }
  13523. return Ok(jw);
  13524. }
  13525. /// <summary>
  13526. /// 报批行程word导出
  13527. /// </summary>
  13528. /// <param name="dto"></param>
  13529. /// <returns></returns>
  13530. [HttpPost]
  13531. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  13532. {
  13533. var jw = JsonView(false);
  13534. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13535. if (group == null)
  13536. {
  13537. jw.Msg = "暂无该团组!";
  13538. return Ok(jw);
  13539. }
  13540. //模板路径
  13541. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  13542. //载入模板
  13543. Document doc = new Document(tempPath);
  13544. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13545. //获取所填表格的序数
  13546. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13547. Aspose.Words.Tables.Row titleRowClone = null;
  13548. Aspose.Words.Tables.Row CenterRowClone = null;
  13549. int index = 0;
  13550. int indexChi = 0;
  13551. int SetIndex = 0;
  13552. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  13553. //获取数据,放到datatable
  13554. foreach (var item in ApprovalTravelArr)
  13555. {
  13556. if (index > 0)
  13557. {
  13558. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  13559. tableOne.AppendChild(titleRowClone);
  13560. }
  13561. var textTime = item.Date;
  13562. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  13563. SetCells(tableOne, doc, SetIndex, 0, textTime);
  13564. SetIndex++;
  13565. if (ChiRep.Count > 0)
  13566. {
  13567. foreach (var itemChi in ChiRep)
  13568. {
  13569. var txtTime = itemChi.Time;
  13570. var txtDetail = itemChi.Details;
  13571. if (indexChi > 0)
  13572. {
  13573. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13574. tableOne.AppendChild(CenterRowClone);
  13575. }
  13576. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  13577. {
  13578. SetCells(tableOne, doc, SetIndex, 0, "");
  13579. SetCells(tableOne, doc, SetIndex, 1, "");
  13580. indexChi++;
  13581. SetIndex++;
  13582. break;
  13583. }
  13584. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  13585. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  13586. indexChi++;
  13587. SetIndex++;
  13588. }
  13589. }
  13590. else
  13591. {
  13592. if (indexChi > 0)
  13593. {
  13594. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  13595. tableOne.AppendChild(CenterRowClone);
  13596. }
  13597. SetCells(tableOne, doc, SetIndex, 0, "");
  13598. SetCells(tableOne, doc, SetIndex, 1, "");
  13599. indexChi++;
  13600. SetIndex++;
  13601. }
  13602. index++;
  13603. }
  13604. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  13605. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13606. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  13607. jw.Code = 200;
  13608. jw.Msg = "";
  13609. return Ok(jw);
  13610. }
  13611. private string intToString(int numberVal)
  13612. {
  13613. string numberval = numberVal.ToString();
  13614. Dictionary<char, string> Number = new Dictionary<char, string>();
  13615. Number.Add('1', "一");
  13616. Number.Add('2', "二");
  13617. Number.Add('3', "三");
  13618. Number.Add('4', "四");
  13619. Number.Add('5', "五");
  13620. Number.Add('6', "六");
  13621. Number.Add('7', "七");
  13622. Number.Add('8', "八");
  13623. Number.Add('9', "九");
  13624. string stringNumberVal = string.Empty;
  13625. for (int i = 0; i < numberval.Length; i++)
  13626. {
  13627. if (i == 0)
  13628. {
  13629. stringNumberVal += Number[numberval[i]];
  13630. }
  13631. else if (i >= 1)
  13632. {
  13633. if (numberval[i] == '0')
  13634. {
  13635. stringNumberVal = "十";
  13636. }
  13637. else
  13638. {
  13639. stringNumberVal += "十" + Number[numberval[i]];
  13640. }
  13641. }
  13642. }
  13643. return stringNumberVal;
  13644. }
  13645. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  13646. {
  13647. //获取table中的某个单元格,从0开始
  13648. Cell lshCell = table.Rows[rows].Cells[cells];
  13649. //将单元格中段落移除
  13650. foreach (Node item in lshCell.Paragraphs)
  13651. {
  13652. lshCell.Paragraphs.Remove(item);
  13653. }
  13654. if (val.Contains("\r\n"))
  13655. {
  13656. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  13657. foreach (var item in spArr)
  13658. {
  13659. //新建一个段落
  13660. Paragraph p = new Paragraph(doc);
  13661. var r = new Run(doc, item);
  13662. //把设置的值赋给之前新建的段落
  13663. p.AppendChild(r);
  13664. //将此段落加到单元格内
  13665. lshCell.AppendChild(p);
  13666. }
  13667. }
  13668. else
  13669. {
  13670. //新建一个段落
  13671. Paragraph p = new Paragraph(doc);
  13672. var r = new Run(doc, val);
  13673. //把设置的值赋给之前新建的段落
  13674. p.AppendChild(r);
  13675. //将此段落加到单元格内
  13676. lshCell.AppendChild(p);
  13677. }
  13678. }
  13679. [HttpPost]
  13680. public async Task<IActionResult> ServerHttp(string paramStr)
  13681. {
  13682. paramStr = paramStr.TrimEnd('\'');
  13683. paramStr = paramStr.TrimStart('\'');
  13684. JsonView jw = JsonView(false);
  13685. JObject param = JObject.Parse(paramStr);
  13686. if (!param.ContainsKey("url"))
  13687. {
  13688. jw.Msg = "url null";
  13689. return Ok(jw);
  13690. }
  13691. string url = param["url"]!.ToString();
  13692. var methon = "get";
  13693. Dictionary<string, string> headValues = null;
  13694. string bodyStr = string.Empty;
  13695. if (param.ContainsKey("methon"))
  13696. {
  13697. methon = param["methon"]!.ToString().ToLower();
  13698. }
  13699. if (param.ContainsKey("header"))
  13700. {
  13701. var header = param["header"]!.ToString();
  13702. JObject headerJobject = JObject.Parse(header);
  13703. headValues = new Dictionary<string, string>();
  13704. foreach (JProperty item in headerJobject.Properties())
  13705. {
  13706. var value = item.Value.ToString();
  13707. var head = item.Path;
  13708. headValues.Add(head, value);
  13709. }
  13710. }
  13711. HttpClient client = new HttpClient();
  13712. string responseString = string.Empty;
  13713. StringContent content = null;
  13714. if (headValues != null)
  13715. {
  13716. foreach (var item in headValues.Keys)
  13717. {
  13718. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  13719. {
  13720. if (param.ContainsKey("body"))
  13721. {
  13722. bodyStr = param["body"]!.ToString();
  13723. }
  13724. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  13725. }
  13726. else
  13727. {
  13728. client.DefaultRequestHeaders.Add(item, headValues[item]);
  13729. }
  13730. }
  13731. }
  13732. try
  13733. {
  13734. if (methon == "get")
  13735. {
  13736. responseString = await client.GetStringAsync(url);
  13737. }
  13738. else if (methon == "post")
  13739. {
  13740. var request = new HttpRequestMessage(HttpMethod.Post, url)
  13741. {
  13742. Content = content
  13743. };
  13744. var response = await client.SendAsync(request);
  13745. try
  13746. {
  13747. Stream responseStream = await response.Content.ReadAsStreamAsync();
  13748. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  13749. {
  13750. using (StreamReader reader = new StreamReader(gzipStream))
  13751. {
  13752. responseString = await reader.ReadToEndAsync();
  13753. }
  13754. }
  13755. }
  13756. catch (Exception)
  13757. {
  13758. responseString = await response.Content.ReadAsStringAsync();
  13759. }
  13760. }
  13761. else
  13762. {
  13763. responseString = "methon error";
  13764. }
  13765. jw = JsonView(true, "success", responseString);
  13766. }
  13767. catch (Exception ex)
  13768. {
  13769. jw.Msg = "error " + ex.Message;
  13770. jw.Data = ex.StackTrace;
  13771. }
  13772. finally
  13773. {
  13774. client.Dispose();
  13775. }
  13776. return Ok(jw);
  13777. }
  13778. #endregion
  13779. #region 团组接待意见调查 Grp_ReceptionOpinionSurvey
  13780. /// <summary>
  13781. /// 团组接待意见调查 - 信息管理
  13782. /// 基础数据(团组)
  13783. /// </summary>
  13784. /// <param name="dto"></param>
  13785. /// <returns></returns>
  13786. [HttpGet]
  13787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13788. public async Task<IActionResult> OpinionaireInit()
  13789. {
  13790. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  13791. .Select(x => new
  13792. {
  13793. x.Id,
  13794. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  13795. })
  13796. .OrderByDescending(x => x.Id)
  13797. .ToListAsync();
  13798. return Ok(JsonView(groupData, groupData.Count));
  13799. }
  13800. /// <summary>
  13801. /// 团组接待意见调查 - 信息管理
  13802. /// 列表
  13803. /// </summary>
  13804. /// <param name="groupId"></param>
  13805. /// <returns></returns>
  13806. [HttpGet("{groupId}")]
  13807. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13808. public async Task<IActionResult> OpinionaireManageList(int groupId)
  13809. {
  13810. if (groupId < 1) Ok(JsonView(false,"请传入有效的diId"));
  13811. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  13812. .Select(x => new
  13813. {
  13814. x.Id,
  13815. x.TourGuideName,
  13816. x.CityName,
  13817. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  13818. x.CreateTime
  13819. })
  13820. .OrderBy(x => x.Id)
  13821. .ToListAsync();
  13822. return Ok(JsonView(data));
  13823. }
  13824. /// <summary>
  13825. /// 团组接待意见调查 - 信息管理
  13826. /// 保存
  13827. /// </summary>
  13828. /// <param name="dto"></param>
  13829. /// <returns></returns>
  13830. [HttpPost]
  13831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13832. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  13833. {
  13834. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  13835. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  13836. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  13837. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  13838. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  13839. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  13840. _opinionaireRep.BeginTran();
  13841. if (addData != null && addData.Count > 0)
  13842. {
  13843. foreach (var item in addData)
  13844. {
  13845. item.CreateUserId = currUserInfo.UserId;
  13846. item.DiId = dto.DiId;
  13847. }
  13848. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  13849. }
  13850. if (updData != null && updData.Count > 0)
  13851. {
  13852. var upd = await _opinionaireRep._sqlSugar
  13853. .Updateable(updData)
  13854. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  13855. .WhereColumns(x =>new{ x.Id})
  13856. .ExecuteCommandAsync();
  13857. }
  13858. _opinionaireRep.CommitTran();
  13859. return Ok(JsonView("操作成功!"));
  13860. }
  13861. /// <summary>
  13862. /// 团组接待意见调查 - 信息管理
  13863. /// 删除
  13864. /// </summary>
  13865. /// <param name="id"></param>
  13866. /// <returns></returns>
  13867. [HttpDelete("{id}")]
  13868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13869. public async Task<IActionResult> OpinionaireManageDel(int id)
  13870. {
  13871. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  13872. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  13873. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  13874. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  13875. if (!del) return Ok(JsonView("操作失败!"));
  13876. return Ok(JsonView("操作成功!"));
  13877. }
  13878. /// <summary>
  13879. /// 团组接待意见调查 - 用户
  13880. /// 列表
  13881. /// </summary>
  13882. /// <param name="id"></param>
  13883. /// <returns></returns>
  13884. [HttpGet("{diId}")]
  13885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13886. public async Task<IActionResult> OpinionaireUserList(int diId)
  13887. {
  13888. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  13889. var sql = string.Format(@"
  13890. SELECT
  13891. o.Id,
  13892. o.DiId,
  13893. di.TeamName AS 'GroupName',
  13894. di.VisitPNumber AS 'PeopleNumber',
  13895. di.ClientName AS 'LeadGroup',
  13896. di.VisitCountry AS 'Travel',
  13897. di.VisitDays AS 'Days',
  13898. o.CityName,
  13899. o.TourGuideName,
  13900. o.Catering,
  13901. o.CateringReason,
  13902. o.Stay,
  13903. o.StayReason,
  13904. o.[Route],
  13905. o.RouteReason,
  13906. o.OfficialActivity,
  13907. o.OfficialActivityReason,
  13908. o.TourGuide,
  13909. o.TourGuideReason,
  13910. o.[Translate],
  13911. o.TranslateReason,
  13912. o.Trip,
  13913. o.TripReason,
  13914. o.ESFileName,
  13915. o.SignatureDate,
  13916. o.Remark
  13917. FROM
  13918. Grp_Opinionaire o
  13919. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  13920. WHERE
  13921. o.IsDel = 0
  13922. AND o.DiId = {0}
  13923. ORDER BY
  13924. o.Id ASC", diId);
  13925. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  13926. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  13927. return Ok(JsonView(data));
  13928. }
  13929. /// <summary>
  13930. /// 团组接待意见调查 - 用户
  13931. /// 保存
  13932. /// </summary>
  13933. /// <param name="id"></param>
  13934. /// <returns></returns>
  13935. [HttpPost]
  13936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13937. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  13938. {
  13939. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  13940. foreach (var item in dto)
  13941. {
  13942. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  13943. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  13944. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  13945. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  13946. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  13947. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  13948. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  13949. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  13950. }
  13951. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  13952. if (!Directory.Exists(filePathBase))
  13953. {
  13954. Directory.CreateDirectory(filePathBase);
  13955. }
  13956. #region 上传文件
  13957. var filePaths = new List<string>();
  13958. foreach (var item in dto)
  13959. {
  13960. var file = item.File;
  13961. // 将文件保存到指定位置
  13962. var filePath = Path.Combine(filePathBase, file.FileName);
  13963. using (var stream = new FileStream(filePath, FileMode.Create))
  13964. {
  13965. await file.CopyToAsync(stream);
  13966. }
  13967. //验证文件是否上传成功
  13968. if (!System.IO.File.Exists(filePath))
  13969. {
  13970. foreach (var filePathStr in filePaths)
  13971. {
  13972. System.IO.File.Delete(filePathStr);
  13973. }
  13974. return Ok(JsonView(false, "文件上传失败!"));
  13975. }
  13976. item.ESFileName = file.FileName;
  13977. }
  13978. #endregion
  13979. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  13980. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  13981. .UpdateColumns(x => new
  13982. {
  13983. x.Catering,
  13984. x.CateringReason,
  13985. x.Stay,
  13986. x.StayReason,
  13987. x.Route,
  13988. x.RouteReason,
  13989. x.OfficialActivity,
  13990. x.OfficialActivityReason,
  13991. x.TourGuide,
  13992. x.TourGuideReason,
  13993. x.Translate,
  13994. x.TranslateReason,
  13995. x.Trip,
  13996. x.TripReason,
  13997. x.ESFileName,
  13998. x.SignatureDate,
  13999. x.Remark
  14000. })
  14001. .WhereColumns(x => new { x.Id })
  14002. .ExecuteCommandAsync();
  14003. if (upd < 1)
  14004. {
  14005. foreach (var filePathStr in filePaths)
  14006. {
  14007. System.IO.File.Delete(filePathStr);
  14008. }
  14009. return Ok(JsonView(false));
  14010. }
  14011. return Ok(JsonView(true));
  14012. }
  14013. #endregion
  14014. // /// <summary>
  14015. // ///
  14016. // /// </summary>
  14017. // /// <param name="_dto"></param>
  14018. // /// <returns></returns>
  14019. // [HttpPost]
  14020. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14021. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  14022. // {
  14023. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  14024. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  14025. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  14026. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  14027. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  14028. // dic_psg.Add("客人", 974);
  14029. // dic_psg.Add("司机", 975);
  14030. // dic_psg.Add("导游", 976);
  14031. // dic_psg.Add("公司内部人员", 977);
  14032. // dic_psg.Add("司机/导游/公司内部人员", 978);
  14033. // foreach (var item in list_visa)
  14034. // {
  14035. // Grp_VisaInfo temp = new Grp_VisaInfo();
  14036. // temp.Id = item.Id;
  14037. // temp.DIId = item.DIId;
  14038. // temp.VisaClient = item.VisaClient;
  14039. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  14040. // temp.VisaCurrency = item.VisaCurrency;
  14041. // temp.IsThird = item.IsThird;
  14042. // if (dic_psg.ContainsKey(item.PassengerType))
  14043. // {
  14044. // temp.PassengerType = dic_psg[item.PassengerType];
  14045. // }
  14046. // else {
  14047. // temp.PassengerType = -1;
  14048. // }
  14049. // temp.VisaNumber = item.VisaNumber;
  14050. // temp.VisaFreeNumber = item.VisaFreeNumber;
  14051. // temp.CreateUserId = item.Operators;
  14052. // DateTime dt_ct;
  14053. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  14054. // if (b_ct)
  14055. // {
  14056. // temp.CreateTime = dt_ct;
  14057. // }
  14058. // else
  14059. // {
  14060. // temp.CreateTime = DateTime.Now;
  14061. // }
  14062. // temp.DeleteTime = "";
  14063. // temp.DeleteUserId = 0;
  14064. // temp.Remark = item.Remark;
  14065. // if (string.IsNullOrEmpty(temp.Remark)) {
  14066. // temp.Remark = "";
  14067. // }
  14068. // temp.IsDel = item.IsDel;
  14069. // temp.VisaDescription = item.VisaAttachment;
  14070. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  14071. //([Id]
  14072. // ,[DIId]
  14073. // ,[VisaClient]
  14074. // ,[VisaPrice]
  14075. // ,[VisaCurrency]
  14076. // ,[IsThird]
  14077. // ,[PassengerType]
  14078. // ,[VisaNumber]
  14079. // ,[VisaFreeNumber]
  14080. // ,[CreateUserId]
  14081. // ,[CreateTime]
  14082. // ,[DeleteTime]
  14083. // ,[DeleteUserId]
  14084. // ,[Remark]
  14085. // ,[IsDel]
  14086. // ,[visaDescription])
  14087. // VALUES
  14088. // ({0},{1},'{2}',{3},{4}
  14089. //,{5},{6},{7},{8},{9}
  14090. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  14091. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  14092. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  14093. //);
  14094. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  14095. // }
  14096. // return Ok(JsonView(true, "操作成功!"));
  14097. // }
  14098. /// <summary>
  14099. /// 123132123
  14100. /// </summary>
  14101. /// <param name="_dto"></param>
  14102. /// <returns></returns>
  14103. [HttpPost]
  14104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14105. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  14106. {
  14107. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  14108. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  14109. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  14110. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  14111. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  14112. dicDetail.Add(789, 1034);
  14113. dicDetail.Add(790, 1035);
  14114. dicDetail.Add(791, 1036);
  14115. dicDetail.Add(792, 1037);
  14116. dicDetail.Add(793, 1038);
  14117. dicDetail.Add(794, 1039);
  14118. dicDetail.Add(795, 1040);
  14119. dicDetail.Add(796, 1041);
  14120. dicDetail.Add(797, 1042);
  14121. dicDetail.Add(798, 1043);
  14122. dicDetail.Add(801, 1044);
  14123. dicDetail.Add(802, 1045);
  14124. dicDetail.Add(803, 1046);
  14125. Dictionary<int, int> dic = new Dictionary<int, int>();
  14126. dic.Add(806, 1027);
  14127. dic.Add(807, 1028);
  14128. dic.Add(808, 1029);
  14129. dic.Add(809, 1030);
  14130. dic.Add(810, 1031);
  14131. dic.Add(811, 1032);
  14132. dic.Add(812, 1033);
  14133. foreach (var item in list_visa)
  14134. {
  14135. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  14136. temp.Coefficient = item.coefficient;
  14137. DateTime dtCrt;
  14138. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  14139. if (b1)
  14140. {
  14141. temp.CreateTime = dtCrt;
  14142. }
  14143. else
  14144. {
  14145. temp.CreateTime = DateTime.Now;
  14146. }
  14147. temp.CreateUserId = item.Operators;
  14148. temp.DeleteTime = "";
  14149. temp.DeleteUserId = 0;
  14150. temp.DiId = int.Parse(item.DIID);
  14151. temp.FilePath = item.FilePath;
  14152. temp.IsDel = item.IsDel;
  14153. temp.Price = item.Price;
  14154. temp.PriceCount = 1;
  14155. temp.PriceCurrency = item.Currency;
  14156. int detailId = 0;
  14157. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  14158. {
  14159. detailId = dicDetail[item.PriceTypeDetail];
  14160. }
  14161. temp.PriceDetailType = detailId;
  14162. temp.PriceDt = DateTime.Now;
  14163. temp.PriceName = item.PriceName;
  14164. temp.PriceSum = item.Price;
  14165. int tid = 0;
  14166. if (dic.ContainsKey(item.PriceType))
  14167. {
  14168. tid = dic[item.PriceType];
  14169. }
  14170. temp.PriceType = tid;
  14171. temp.Remark = item.Remark;
  14172. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  14173. }
  14174. return Ok(JsonView(true, "操作成功!"));
  14175. }
  14176. }
  14177. }